Android Open Source - minecraft-connect-4 Mc Group






From Project

Back to project page minecraft-connect-4.

License

The source code is released under:

MIT License

If you think the Android project minecraft-connect-4 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* COPYRIGHT (C) 2014 Aleksandr Belkin. All Rights Reserved. */
package sq.squ1rr.mcc4.layout;
/*from  w  w  w  . j ava 2 s  .com*/
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

/**
 * Allows to group views horizontally or vertically with margins and paddings.
 * @author Aleksandr Belkin
 */
public class McGroup extends LinearLayout {
    /** child layout parameters */
    private LayoutParams childParams = null;
    
    /**
     * Create group
     * @param context
     */
    public McGroup(Context context) {
        super(context);
        setOrientation(LinearLayout.HORIZONTAL);
    }
    
    /**
     * Sets child layout parameters, weight is default
     * @param width
     * @param height
     */
    public void setChildParams(int width, int height) {
        childParams = new LayoutParams(width, height);
    }
    
    /**
     * Sets child layout parameters including weight
     * @param width
     * @param height
     * @param weight
     */
    public void setChildParams(int width, int height, float weight) {
        childParams = new LayoutParams(width, height, weight);
    }
    
    /*
     * (non-Javadoc)
     * @see android.view.ViewGroup#addView(android.view.View)
     */
    @Override
    public void addView(View view) {
        // if no child parameters set use default
        if(childParams == null) {
            childParams = new LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT
            );
        }
        
        // if more than one child add margin
        if(getChildCount() > 0) {
            int spacing = McStyle.getMenuWidgetSpacing(getContext());
            if(getOrientation() == LinearLayout.HORIZONTAL) {
                childParams.setMargins(spacing, 0, 0, 0);
            } else childParams.setMargins(0, spacing, 0, 0);
        } else {
            childParams.setMargins(0, 0, 0, 0);
        }
        
        // add view
        view.setLayoutParams(childParams);
        super.addView(view);
    }
}




Java Source Code List

sq.squ1rr.mcc4.AboutMenu.java
sq.squ1rr.mcc4.BaseActivity.java
sq.squ1rr.mcc4.GameActivity.java
sq.squ1rr.mcc4.MainMenuActivity.java
sq.squ1rr.mcc4.MainMenu.java
sq.squ1rr.mcc4.MenuLayout.java
sq.squ1rr.mcc4.OptionsMenu.java
sq.squ1rr.mcc4.QuickGameMenu.java
sq.squ1rr.mcc4.StatsMenu.java
sq.squ1rr.mcc4.Stats.java
sq.squ1rr.mcc4.ai.Ai.java
sq.squ1rr.mcc4.ai.EasyAi.java
sq.squ1rr.mcc4.ai.HardAi.java
sq.squ1rr.mcc4.ai.NormalAi.java
sq.squ1rr.mcc4.ai.PeacefulAi.java
sq.squ1rr.mcc4.board.BoardDialogue.java
sq.squ1rr.mcc4.board.BoardLogic.java
sq.squ1rr.mcc4.board.BoardRenderer.java
sq.squ1rr.mcc4.board.BoardView.java
sq.squ1rr.mcc4.board.GameBoard.java
sq.squ1rr.mcc4.board.Texture.java
sq.squ1rr.mcc4.gl.Rectangle.java
sq.squ1rr.mcc4.gl.SpriteBatch.java
sq.squ1rr.mcc4.gl.SpriteString.java
sq.squ1rr.mcc4.gl.Sprite.java
sq.squ1rr.mcc4.layout.LayoutManager.java
sq.squ1rr.mcc4.layout.McButton.java
sq.squ1rr.mcc4.layout.McGroup.java
sq.squ1rr.mcc4.layout.McSelector.java
sq.squ1rr.mcc4.layout.McStyle.java
sq.squ1rr.mcc4.layout.McText.java
sq.squ1rr.mcc4.layout.McToggler.java
sq.squ1rr.mcc4.layout.McToken.java
sq.squ1rr.mcc4.rules.GameRules.java
sq.squ1rr.mcc4.rules.Player.java
sq.squ1rr.mcc4.rules.Rule.java
sq.squ1rr.mcc4.util.GlobalConstants.java