Example usage for android.os Bundle getBooleanArray

List of usage examples for android.os Bundle getBooleanArray

Introduction

In this page you can find the example usage for android.os Bundle getBooleanArray.

Prototype

@Nullable
public boolean[] getBooleanArray(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.group7.dragonwars.GameActivity.java

@Override
protected final void onStart() {
    super.onStart();
    Bundle b = getIntent().getExtras();
    String mapFileName = b.getString("mapFileName");
    boolean[] isAi = b.getBooleanArray("isAi");
    GameMap map = null;//  www  .  j  av a2s .com

    try {
        map = MapReader.readMapFromFile(mapFileName, this, isAi);
    } catch (JSONException e) {
        Log.d(TAG, "Failed to load the map: " + e.getMessage());
    }

    if (map == null) {
        Log.d(TAG, "map is null");
        System.exit(1);
    }

    setContentView(R.layout.activity_game);
    GameView gameView = (GameView) this.findViewById(R.id.gameView);
    state = new GameState(map, new Logic(), map.getPlayers(), gameView);
    Button menuButton = (Button) this.findViewById(R.id.menuButton);
    menuButton.setOnClickListener(gameView);
    gameView.setState(state, this);
}

From source file:net.reichholf.dreamdroid.fragment.dialogs.MultiChoiceDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    init();/*from  w  w w  .  jav a2  s. c o  m*/
    if (savedInstanceState != null) {
        boolean[] checked = savedInstanceState.getBooleanArray("checkedItems");
        if (checked != null)
            mCheckedItems = checked;
    }
    ArrayList<Integer> selectedList = new ArrayList<>();
    for (int i = 0; i < mCheckedItems.length; ++i) {
        if (mCheckedItems[i])
            selectedList.add(i);
    }
    Integer[] selected = new Integer[selectedList.size()];
    selectedList.toArray(selected);

    MaterialDialog.Builder builder;
    builder = new MaterialDialog.Builder(getActivity());
    builder.title(mTitleId).items(mItems)
            .itemsCallbackMultiChoice(selected, new MaterialDialog.ListCallbackMulti() {
                @Override
                public void onSelection(MaterialDialog materialDialog, Integer[] selected,
                        CharSequence[] charSequences) {
                    ((MultiChoiceDialogListener) getActivity()).onMultiChoiceDialogSelection(getTag(),
                            materialDialog, selected);
                    ((MultiChoiceDialogListener) getActivity()).onMultiChoiceDialogFinish(getTag(),
                            Activity.RESULT_OK);
                }
            }).positiveText(mPositiveStringId);

    return builder.build();
}

From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentPiecesFragment.java

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        pieces = savedInstanceState.getBooleanArray(TAG_PIECES);
        allPiecesCount = savedInstanceState.getInt(TAG_ALL_PIECES_COUNT);
        pieceSize = savedInstanceState.getInt(TAG_PIECE_SIZE);
        downloadedPieces = savedInstanceState.getInt(TAG_DOWNLOADED_PIECES);
    }// w  w w .  j ava 2 s  .  c  o m
}

From source file:org.akop.crosswords.fragment.BaseFragment.java

protected void readSparseBooleanArray(Bundle bundle, String prefix, SparseBooleanArray array) {
    int keys[] = bundle.getIntArray(prefix + "_keys");
    boolean values[] = bundle.getBooleanArray(prefix + "_values");

    if (keys != null && values != null) {
        for (int i = 0, n = keys.length; i < n; i++) {
            array.put(keys[i], values[i]);
        }/*from  w  ww  . j a v  a2s.c  om*/
    }
}

From source file:net.reichholf.dreamdroid.fragment.dialogs.MultiChoiceDialog.java

public void init() {
    Bundle args = getArguments();
    mTitleId = args.getInt(KEY_TITLE_ID);
    mItems = BundleHelper.toCharSequenceArray(args.getStringArrayList((KEY_ITEMS)));
    mCheckedItems = args.getBooleanArray(KEY_CHECKED_ITEMS);
    mPositiveStringId = args.getInt(KEY_POSITIVE_STRING_ID);
}

From source file:br.com.PartoHumanizado.fragment.base.ResStringArrayListFragment.java

@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);
    if (savedInstanceState == null)
        return;//w w  w  . j  a v  a 2  s.c om
    boolean[] booleans = savedInstanceState.getBooleanArray(getTitle());
    ListView listView = getListView();
    for (int i = 0; i < booleans.length; i++) {
        listView.setItemChecked(i, booleans[i]);
    }
}

From source file:uk.co.fuuzetsu.turnofwar.GameActivity.java

@SuppressLint("NewApi")
@Override/*from   w w  w .  ja v a  2  s  .c om*/
public void onResume() {
    super.onResume();
    int currentApiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentApiVersion >= 19) {
        final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        final View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(flags);
    }
    if (ranFlag == 0) {
        Bundle b = getIntent().getExtras();
        String mapFileName = b.getString("mapFileName");
        boolean[] isAi = b.getBooleanArray("isAi");
        GameMap map = null;

        try {
            map = MapReader.readMapFromFile(mapFileName, this, isAi);
        } catch (JSONException e) {
            Log.d(TAG, "Failed to load the map: " + e.getMessage());
        }

        if (map == null) {
            Log.d(TAG, "map is null");
            System.exit(1);
        }
        // getWindow().setFormat(PixelFormat.RGBA_8888); //fix banding which
        // ruined all my nice images
        setContentView(R.layout.activity_game);
        GameView gameView = (GameView) this.findViewById(R.id.gameView);
        state = new GameState(map, new Logic(), map.getPlayers(), gameView);
        Button menuButton = (Button) this.findViewById(R.id.menuButton);
        menuButton.setOnClickListener(gameView);
        gameView.setState(state, this);
    }
}

From source file:eu.trentorise.smartcampus.eb.fragments.experience.AssignCollectionFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final List<ExpCollection> collections = EBHelper.getUserPreference().getCollections();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.expmenu_assign_collection);

    if (savedInstanceState != null) {
        selected = savedInstanceState.getBooleanArray("selected");
        selectedIds = new HashSet<String>(savedInstanceState.getStringArrayList("selectedIds"));
        items = savedInstanceState.getStringArray("items");
    } else {//from   www  .j  a  v a  2  s .  co  m
        items = new String[collections.size()];
        selected = new boolean[collections.size()];
        for (int i = 0; i < items.length; i++) {
            items[i] = collections.get(i).getName();
            boolean b = false;
            if (getArguments().getStringArrayList(ARG_COLLS) != null) {
                for (String s : getArguments().getStringArrayList(ARG_COLLS)) {
                    if (s.equals(collections.get(i).getId())) {
                        b = true;
                        break;
                    }
                }
            }
            selected[i] = b;
        }
        selectedIds = new HashSet<String>();
        if (getArguments().getStringArrayList(ARG_COLLS) != null)
            selectedIds.addAll(getArguments().getStringArrayList(ARG_COLLS));
    }

    builder.setMultiChoiceItems(items, selected, new OnMultiChoiceClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked)
                selectedIds.add(collections.get(which).getId());
            else
                selectedIds.remove(collections.get(which).getId());
        }
    });

    builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //            exp.setCollectionIds(new ArrayList<String>(selectedIds));
            //            Fragment f = getFragmentManager().findFragmentById(containerId);
            AssignCollectionsCallback c = ((DialogCallbackContainer) getActivity())
                    .getAssignCollectionsCallback();
            c.onCollectionsAssigned(getArguments().getString(ARG_ID), new ArrayList<String>(selectedIds));
            dialog.dismiss();
        }
    });
    builder.setPositiveButton(R.string.dialog_collection_add, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            DialogFragment newCollFragment = new NewCollectionDialogFragment();
            newCollFragment.setArguments(NewCollectionDialogFragment.prepare(null));
            newCollFragment.show(getActivity().getSupportFragmentManager(), "exp_coll");
            //
            //             NewCollectionDialogFragment.saveCollectionDialog(getActivity(), null, new CollectionSavedHandler() {
            //               @Override
            //               public void onCollectionSaved(ExpCollection coll) {
            ////                  exp.setCollectionIds(Collections.singletonList(coll.getId()));
            //                  ((AssignCollectionsCallback)getFragmentManager().findFragmentById(android.R.id.content)).onCollectionsAssigned(getArguments().getString(ARG_ID), Collections.singletonList(coll.getId()));
            //               }
            //            }).show();
            dialog.dismiss();
        }
    });

    return builder.create();
}

From source file:com.actinarium.kinetic.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (savedInstanceState != null) {
        mAccelData = savedInstanceState.getParcelable(ARG_ACCEL);
        mGyroData = savedInstanceState.getParcelable(ARG_GYRO);
        mRotVectorData = savedInstanceState.getParcelable(ARG_RV);
        mResultHoldersState = savedInstanceState.getBooleanArray(ARG_RHS);
        mHolderToAnimatorMap = savedInstanceState.getIntArray(ARG_HAM);
        return;//  www .j  av a2s .  c  om
    } else {
        mResultHoldersState = new boolean[] { true, true, true, true, true, true };
        mHolderToAnimatorMap = new int[] { PreviewHolder.ANIMATOR_X, PreviewHolder.ANIMATOR_Y,
                PreviewHolder.NO_ANIMATOR, PreviewHolder.NO_ANIMATOR, PreviewHolder.NO_ANIMATOR,
                PreviewHolder.ANIMATOR_ROTATION, };
    }

    getSupportFragmentManager().beginTransaction()
            .add(R.id.root_container, new RecordFragment(), RecordFragment.TAG).commit();
}

From source file:com.billooms.harppedals.HarpPedalsActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    //      Log.d(TAG, "HarpPedalsActivity.onRestoreInstanceState");
    super.onRestoreInstanceState(savedInstanceState);

    savedChordArray = savedInstanceState.getIntArray(ARG_CHORD);
    savedChordAddArray = savedInstanceState.getBooleanArray(ARG_CHORDADD);
    savedKey = new Key(
            KeySignature.values()[savedInstanceState.getInt(ARG_KEY, KeySignature.DEFAULT.ordinal())],
            Scale.values()[savedInstanceState.getInt(ARG_SCALE, Scale.DEFAULT.ordinal())]);
}