Example usage for android.os Bundle putBooleanArray

List of usage examples for android.os Bundle putBooleanArray

Introduction

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

Prototype

public void putBooleanArray(@Nullable String key, @Nullable boolean[] value) 

Source Link

Document

Inserts a boolean array value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

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

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    try {//from w  w w .  j  av a2  s  .  c om
        boolean[] booleans = getCheckedBooleanArray();
        outState.putBooleanArray(getTitle(), booleans);
    } catch (Exception e) {
        Log.e(TAG, "onSaveInstanceState ", e);
    }
}

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

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable(ARG_ACCEL, mAccelData);
    outState.putParcelable(ARG_GYRO, mGyroData);
    outState.putParcelable(ARG_RV, mRotVectorData);
    outState.putBooleanArray(ARG_RHS, mResultHoldersState);
    outState.putIntArray(ARG_HAM, mHolderToAnimatorMap);
}

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

@Override
public final void onItemClick(final AdapterView<?> parent, final View v, final int position, final long id) {
    if (position < mapInfo.size()) {
        Intent intent = new Intent(this, PlayerSelectActivity.class);
        Bundle b = new Bundle();
        b.putString("mapFileName", mapInfo.get(position).getPath());
        b.putString("mapName", mapInfo.get(position).getName());

        int numPlayers = mapInfo.get(position).getPlayers();
        b.putBooleanArray("isAi", new boolean[numPlayers]);
        // boolean defaults to false, what could possibly go wrong?
        b.putInt("numPlayers", numPlayers);

        /* Make a fake player list for now, again */
        String[] playerNames = new String[numPlayers];

        for (Integer i = 0; i < numPlayers; ++i) {
            playerNames[i] = ("Player " + (i + 1));
        }/* w  ww  .  j a va2s.com*/

        b.putStringArray("playerNames", playerNames);

        intent.putExtras(b);
        startActivity(intent);
    }
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.dialogs.ServicesChooserDialogFragment.java

/**
 * {@inheritDoc}// www  .  j ava  2  s .c om
 */
@Override
public void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);

    // Save the state.
    outState.putBooleanArray(ARG_CHECK_BOXES, checkBoxes);
}

From source file:me.xiaopan.android.inject.sample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    listView = new ListView(getBaseContext());
    setContentView(listView);//from   w ww . j a  v a 2s . c o  m

    // SharedPreferences?
    PreferenceUtils.putBoolean(getBaseContext(), KEY_BOOLEAN, true);
    PreferenceUtils.putFloat(getBaseContext(), KEY_FLOAT, 10000f);
    PreferenceUtils.putInt(getBaseContext(), KEY_INT, 2000);
    PreferenceUtils.putLong(getBaseContext(), KEY_LONG, 50000);
    PreferenceUtils.putString(getBaseContext(), KEY_STRING, "Preference String");
    Set<String> stringSet = new HashSet<String>();
    stringSet.add("String Set 1");
    stringSet.add("String Set 2");
    stringSet.add("String Set 3");
    stringSet.add("String Set 4");
    PreferenceUtils.putStringSet(getBaseContext(), KEY_STRING_SET, stringSet);
    MyBean bean2 = new MyBean();
    bean2.setEmail("sky@xiaopan.me2");
    bean2.setName("?2");
    bean2.setSex("2");
    PreferenceUtils.putObject(getBaseContext(), KEY_JSON, bean2);
    PreferenceUtils.putString(getBaseContext(), KEY_ENUM, Sex.WOMAN.name());

    // ??
    String[] items = new String[] { "", "?", "FragmentDialog",
            "InjectAdapter", "InjectExpandableListAdapter" };
    listView.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1,
            android.R.id.text1, items));
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position <= 2) {
                Bundle bundle = new Bundle();
                bundle.putBoolean(MainActivity.PARAM_BOOLEAN, true);
                bundle.putBooleanArray(MainActivity.PARAM_BOOLEAN_ARRAY, new boolean[] { true, false, true });
                bundle.putByte(MainActivity.PARAM_BYTE, (byte) 110);
                bundle.putByteArray(MainActivity.PARAM_BYTE_ARRAY, new byte[] { 111, 112, 113 });
                bundle.putChar(MainActivity.PARAM_CHAR, 'R');
                bundle.putCharArray(MainActivity.PARAM_CHAR_ARRAY, new char[] { 'c', 'h', 'a', 'r' });
                bundle.putCharSequence(MainActivity.PARAM_CHAR_SEQUENCE, "CharSequence");
                bundle.putCharSequenceArray(MainActivity.PARAM_CHAR_SEQUENCE_ARRAY,
                        new CharSequence[] { "Char", " ", "Sequence" });
                bundle.putDouble(MainActivity.PARAM_DOUBLE, 12.00d);
                bundle.putDoubleArray(MainActivity.PARAM_DOUBLE_ARRAY, new double[] { 12.01d, 12.02d, 12.03d });
                bundle.putFloat(MainActivity.PARAM_FLOAT, 13.00f);
                bundle.putFloatArray(MainActivity.PARAM_FLOAT_ARRAY, new float[] { 13.01f, 13.02f, 13.03f });
                bundle.putInt(MainActivity.PARAM_INT, 120);
                bundle.putIntArray(MainActivity.PARAM_INT_ARRAY, new int[] { 121, 122, 123, });
                bundle.putLong(MainActivity.PARAM_LONG, 12345);
                bundle.putLongArray(MainActivity.PARAM_LONG_ARRAY, new long[] { 12346, 12347, 12348 });
                bundle.putShort(MainActivity.PARAM_SHORT, (short) 2);
                bundle.putShortArray(MainActivity.PARAM_SHORT_ARRAY, new short[] { 3, 4, 5 });
                bundle.putString(MainActivity.PARAM_STRING, "String");
                bundle.putStringArray(MainActivity.PARAM_STRING_ARRAY,
                        new String[] { "String1", "String2", "String3" });

                // ??JSONBundle
                MyBean bean = new MyBean();
                bean.setEmail("sky@xiaopan.me");
                bean.setName("?");
                bean.setSex("");
                bundle.putString(PARAM_STRING_JSON, new Gson().toJson(bean));

                bundle.putString(MainActivity.PARAM_STRING_ENUM, Sex.WOMAN.name());

                // 
                ArrayList<String> stringList = new ArrayList<String>();
                stringList.add("ArrayList String 1");
                stringList.add("ArrayList String 2");
                stringList.add("ArrayList String 3");
                bundle.putStringArrayList(MainActivity.PARAM_STRING_ARRAY_LIST, stringList);
                switch (position) {
                case 0:
                    Second.SECOND_CHRONOGRAPH.lap();
                    Intent intent = new Intent(getBaseContext(), InjectTestActivity.class);
                    intent.putExtras(bundle);
                    startActivity(intent);
                    break;
                case 1:
                    Second.SECOND_CHRONOGRAPH.lap();
                    Intent intent2 = new Intent(getBaseContext(), NormalActivity.class);
                    intent2.putExtras(bundle);
                    startActivity(intent2);
                    break;
                case 2:
                    Second.SECOND_CHRONOGRAPH.lap();
                    new TestDialogFragment().show(getSupportFragmentManager(), "");
                    break;
                }
            } else {
                Class<?> targetClass = null;
                if (position == 3) {
                    targetClass = InjectAdapterActivity.class;
                } else if (position == 4) {
                    targetClass = InjectExpandableListAdapterActivity.class;
                }
                if (targetClass != null) {
                    startActivity(new Intent(getBaseContext(), targetClass));
                }
            }
        }
    });
}

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

/**
 * Launch a new ChordFragment.//from  ww  w  .ja va2s. c  om
 */
private void launchChordFragment() {
    // Create fragment
    ChordFragment chordFragment = new ChordFragment();
    // set arguments for any previously saved Chord
    if (savedChordArray != null) {
        Bundle args = new Bundle();
        args.putIntArray(ARG_CHORD, savedChordArray);
        args.putBooleanArray(ARG_CHORDADD, savedChordAddArray);
        chordFragment.setArguments(args);
    }
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    // Replace whatever is in the fragment_container view with this fragment
    transaction.replace(R.id.fragment_container, chordFragment, NO_SWIPE);
    // and add the transaction to the back stack so the user can navigate back
    transaction.addToBackStack(null);
    // Commit the transaction
    transaction.commit();
}

From source file:com.sftoolworks.nfcoptions.SelectActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

    ListView list = (ListView) findViewById(R.id.listView1);
    if (list.getCount() > 0) {
        savedInstanceState.putBooleanArray(CHECKBOX_STATE,
                ((OptionListAdapter) list.getAdapter()).getCheckState());
    }/*from w ww.j a  v  a 2  s.  c o  m*/
    if (null != selectKey)
        savedInstanceState.putString(KEY_STATE, selectKey);

    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.dnielfe.manager.AppManager.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBooleanArray(STAR_STATES, mStarStates);
}

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

protected void putSparseBooleanArray(Bundle bundle, String prefix, SparseBooleanArray array) {
    int size = array.size();
    int keys[] = new int[size];
    boolean values[] = new boolean[size];

    for (int i = 0; i < size; i++) {
        keys[i] = array.keyAt(i);//  w w  w  . j  a v  a2 s  . c om
        values[i] = array.valueAt(i);
    }

    bundle.putIntArray(prefix + "_keys", keys);
    bundle.putBooleanArray(prefix + "_values", values);
}

From source file:com.billooms.harppedals.chords.ChordFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    //      Log.d(TAG, "ChordFragment.onSaveInstanceState");
    super.onSaveInstanceState(outState);
    if (outState == null) {
        return;/* w  w  w. ja v  a 2s  .  co m*/
    }

    outState.putIntArray(ARG_CHORD, getChordArray());
    outState.putBooleanArray(ARG_CHORDADD, getChordAddArray());
    // must update any arguments sent to this fragment as well
    Bundle args = getArguments();
    if (args != null) {
        args.putIntArray(ARG_CHORD, getChordArray());
        args.putBooleanArray(ARG_CHORDADD, getChordAddArray());
    }
}