Example usage for android.widget RelativeLayout.LayoutParams RelativeLayout.LayoutParams

List of usage examples for android.widget RelativeLayout.LayoutParams RelativeLayout.LayoutParams

Introduction

In this page you can find the example usage for android.widget RelativeLayout.LayoutParams RelativeLayout.LayoutParams.

Prototype

public LayoutParams(LayoutParams source) 

Source Link

Document

Copy constructor.

Usage

From source file:com.mischivous.wormysharpyloggy.wsl.GameScreen.java

/**
 * Initialize a new Game instance of the selected game type.
 *
 * @param type The type of Game to initialize
 *//*www  .  jav  a  2  s.  c  o m*/
@TargetApi(17)
private void StartGame(@NonNull GameType type) {
    if (type == null) {
        throw new IllegalArgumentException("Game type cannot be null.");
    }

    game = new Game(type, OptionsHelper.GetSetCount(this), OptionsHelper.GetMinDiff(this),
            OptionsHelper.GetMaxDiff(this));

    game.AddGameOverListener(this);
    ClearTilesSelected();

    for (int i = 0; i < tiles.length; i++) {
        Drawable d = game.GetTileAt(i).GetDrawable(this);
        if (d == null) {
            Log.e(TAG, String.format("Failed to get drawable for tile %d. Value is null.", i));
        } else {
            tiles[i].setImageDrawable(d);
            Log.d(TAG, String.format("Set tile image for tiles[%d]", i));
        }
    }

    // Initialize the blanks at the top for normal/time attack modes
    if (type == GameType.Normal || type == GameType.TimeAttack) {
        if (found.length > 3) {
            for (int set = 3; set < found.length; set++)
                for (int tile = 0; tile < found[set].length; tile++)
                    found[set][tile].setImageDrawable(
                            ResourcesCompat.getDrawable(getResources(), R.mipmap.tile_small_blank, null));
        }
        // Center the Found Sets string
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                findViewById(R.id.foundSetsTitle).getLayoutParams());

        int id = getResources().getIdentifier(String.format("FoundSet%d_1", found.length), "id",
                getPackageName());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            lp.addRule(RelativeLayout.ALIGN_END, id);
        } else {
            lp.addRule(RelativeLayout.ALIGN_RIGHT, id);
        }
        findViewById(R.id.foundSetsTitle).setLayoutParams(lp);
    } else {
        // Place the first join in the correct location
        int id = getResources().getIdentifier("joinImage", "id", getPackageName());

        ImageView iv = (ImageView) findViewById(id);
        if (iv == null) {
            Log.e(TAG, "Failed to set joinImage. Value is null.");
        } else {
            iv.setImageDrawable(game.GetNextJoin().GetDrawable(this));
        }
    }

    // Change elapsed time string to time remaining string for Time Attack
    if (type == GameType.TimeAttack) {
        ((TextView) findViewById(R.id.timeTitle)).setText(getString(R.string.remainingString));
    }
}