android.os.Bundle.getBooleanArray()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中android.os.Bundle.getBooleanArray()方法的一些代码示例,展示了Bundle.getBooleanArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getBooleanArray()方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:getBooleanArray

Bundle.getBooleanArray介绍

暂无

代码示例

代码示例来源:origin: facebook/facebook-android-sdk

/**
 * Gets an array of boolean values out of the object.
 * @param key The key for the value.
 * @return The boolean values.
 */
@Nullable
public boolean[] getBooleanArray(final String key) {
  return this.bundle.getBooleanArray(key);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void booleanArray() {
 boolean [] arr = new boolean[] { false, true };
 bundle.putBooleanArray("foo", arr);
 assertThat(bundle.getBooleanArray("foo")).isEqualTo(arr);
 assertThat(bundle.getBooleanArray("bar")).isNull();
}

代码示例来源:origin: konmik/nucleus

when(bundle.getBooleanArray(anyString())).thenAnswer(get);

代码示例来源:origin: pockethub/PocketHub

@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
  selectedChoices = getArguments().getBooleanArray(ARG_SELECTED_CHOICES);
  ArrayList<Label> choices = getChoices();
  List<String> selected = new ArrayList<>();
  if (selectedChoices != null) {
    for (int i = 0; i < choices.size(); i++) {
      if (selectedChoices[i]) {
        selected.add(choices.get(i).name());
      }
    }
  }
  adapter = new GroupAdapter();
  for (Label label : getChoices()) {
    adapter.add(new LabelDialogItem(label, selected.contains(label.name())));
  }
  adapter.setOnItemClickListener(this);
  return createDialogBuilder()
      .adapter(adapter, null)
      .negativeText(R.string.cancel)
      .neutralText(R.string.clear)
      .positiveText(R.string.apply)
      .onNeutral((dialog, which) -> {
        Arrays.fill(getArguments().getBooleanArray(ARG_SELECTED_CHOICES), false);
        onResult(RESULT_OK);
      })
      .onPositive((dialog, which) -> onResult(RESULT_OK))
      .build();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getWrongType() {
 bundle.putFloat("foo", 5f);
 assertThat(bundle.getCharArray("foo")).isNull();
 assertThat(bundle.getInt("foo")).isEqualTo(0);
 assertThat(bundle.getIntArray("foo")).isNull();
 assertThat(bundle.getIntegerArrayList("foo")).isNull();
 assertThat(bundle.getShort("foo")).isEqualTo((short) 0);
 assertThat(bundle.getShortArray("foo")).isNull();
 assertThat(bundle.getBoolean("foo")).isFalse();
 assertThat(bundle.getBooleanArray("foo")).isNull();
 assertThat(bundle.getLong("foo")).isEqualTo(0);
 assertThat(bundle.getLongArray("foo")).isNull();
 assertThat(bundle.getFloatArray("foo")).isNull();
 assertThat(bundle.getDouble("foo")).isEqualTo(0.0);
 assertThat(bundle.getDoubleArray("foo")).isNull();
 assertThat(bundle.getString("foo")).isNull();
 assertThat(bundle.getStringArray("foo")).isNull();
 assertThat(bundle.getStringArrayList("foo")).isNull();
 assertThat(bundle.getBundle("foo")).isNull();
 assertThat((Parcelable) bundle.getParcelable("foo")).isNull();
 assertThat(bundle.getParcelableArray("foo")).isNull();
 assertThat(bundle.getParcelableArrayList("foo")).isNull();
 bundle.putInt("foo", 1);
 assertThat(bundle.getFloat("foo")).isEqualTo(0.0f);
}

代码示例来源:origin: thoughtbot/expandable-recycler-view

/**
 * Fetches the expandable state map from the saved instance state {@link Bundle}
 * and restores the expanded states of all of the list items.
 * <p>
 * Should be called from {@link Activity#onRestoreInstanceState(Bundle)}  in
 * the {@link Activity} that hosts the RecyclerView that this
 * {@link ExpandableRecyclerViewAdapter} is attached to.
 * <p>
 *
 * @param savedInstanceState The {@code Bundle} from which the expanded
 * state map is loaded
 */
public void onRestoreInstanceState(Bundle savedInstanceState) {
 if (savedInstanceState == null || !savedInstanceState.containsKey(EXPAND_STATE_MAP)) {
  return;
 }
 expandableList.expandedGroupIndexes = savedInstanceState.getBooleanArray(EXPAND_STATE_MAP);
 notifyDataSetChanged();
}

代码示例来源:origin: facebook/facebook-android-sdk

assertArrayEquals(originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY), cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY));
assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY));
assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY));

代码示例来源:origin: evernote/android-state

public boolean[] getBooleanArray(Bundle state, String key) {
  return state.getBooleanArray(key + mBaseKey);
}

代码示例来源:origin: fengdai/FragmentMaster

/**
 * Retrieve extended data from the request.
 *
 * @param name The name of the desired item.
 * @return the value of an item that previously added with putExtra() or
 * null if no boolean array value was found.
 * @see #putExtra(String, boolean[])
 */
public boolean[] getBooleanArrayExtra(String name) {
  return mExtras == null ? null : mExtras.getBooleanArray(name);
}

代码示例来源:origin: stackoverflow.com

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if ( savedInstanceState == null) return;
  //get your stuff from savedInstanceState
  //Example
  boolean[] array = savedInstanceState.getBooleanArray("yourkey");
}

代码示例来源:origin: Omega-R/OmegaRecyclerView

public void onRestoreInstanceState(Bundle savedInstanceState) {
  if (savedInstanceState == null || !savedInstanceState.containsKey(KEY_STATES)) {
    return;
  }
  mExpandStates = savedInstanceState.getBooleanArray(KEY_STATES);
  updateIndexes();
}

代码示例来源:origin: stackoverflow.com

@Override
protected void onSaveInstanceState (Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putBooleanArray(SOME_CONSTANT_STRING,this.savedSelection);
}

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (savedInstanceState!=null) {
   this.savedSelection=savedInstanceState.getBooleanArray(SOME_CONSTANT_STRING);
  }
}

代码示例来源:origin: consp1racy/android-support-preference

@Override
  @SuppressWarnings("unchecked")
  public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
      mNewValues.clear();
      mNewValues.addAll((Set<String>) savedInstanceState.getSerializable(TAG + ".mNewValues"));
      mSelectedItems = savedInstanceState.getBooleanArray(TAG + ".mSelectedItems");
      mPreferenceChanged = savedInstanceState.getBoolean(TAG + ".mPreferenceChanged");
      mRestoredState = true;
    }
  }
}

代码示例来源:origin: googlecodelabs/android-topeka

@Override
public void setUserInput(Bundle savedInput) {
  if (savedInput == null) {
    return;
  }
  final boolean[] answers = savedInput.getBooleanArray(KEY_ANSWER);
  if (null == answers) {
    return;
  }
  for (int i = 0; i < answers.length; i++) {
    mListView.setItemChecked(i, answers[i]);
  }
}

代码示例来源:origin: stackoverflow.com

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == 1) {
    Toast.makeText(this, "Productos Recibidos", Toast.LENGTH_SHORT)
        .show();
    if (data != null) {
      Bundle bundle = data.getExtras();
      child = bundle.getStringArrayList("child");
      isChecked = bundle.getBooleanArray("selected");
      // We will inflate the view with the table as a parent but not append it
      View newView = LayoutInflater.from(getBaseContext())
        .inflate(R.layout.your_row_layout, table, false);
      // Refresh the data in your view
      // ...
      // Finally add it to the table
      table.addView(newView); // here is my problem  
    }
  }
}

代码示例来源:origin: vanniktech/RxPermission

@Override protected void onCreate(final Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 if (savedInstanceState == null) {
  handleIntent(getIntent());
 } else {
  shouldShowRequestPermissionRationale = savedInstanceState.getBooleanArray(SAVE_RATIONALE);
 }
}

代码示例来源:origin: OceanLabs/Android-Print-SDK

/*****************************************************
 *
 * Called when the fragment is created.
 *
 *****************************************************/
@Override
public void onCreate( Bundle savedInstanceState )
 {
 super.onCreate( savedInstanceState );
 // See if we saved an "is checked" array
 if ( savedInstanceState != null )
  {
  boolean[] assetIsCheckedArray = savedInstanceState.getBooleanArray( BUNDLE_KEY_ASSET_IS_CHECKED_ARRAY );
  mAssetIsCheckedArrayList = BooleanUtils.arrayListFrom( assetIsCheckedArray );
  }
 }

代码示例来源:origin: googlecodelabs/android-topeka

@Override
public void setUserInput(Bundle savedInput) {
  if (savedInput == null) {
    return;
  }
  mAnswers = savedInput.getBooleanArray(KEY_ANSWERS);
  if (mAnswers == null) {
    return;
  }
  final ListAdapter adapter = mListView.getAdapter();
  for (int i = 0; i < mAnswers.length; i++) {
    mListView.performItemClick(mListView.getChildAt(i), i, adapter.getItemId(i));
  }
}

代码示例来源:origin: googlecodelabs/android-topeka

@Override
public void setUserInput(Bundle savedInput) {
  if (savedInput == null) {
    return;
  }
  mAnswers = savedInput.getBooleanArray(KEY_ANSWERS);
  if (mAnswers == null) {
    initAnswerSpace();
    return;
  }
  ListAdapter adapter = mListView.getAdapter();
  for (int i = 0; i < mAnswers.length; i++) {
    mListView.performItemClick(mListView.getChildAt(i), i, adapter.getItemId(i));
  }
}

代码示例来源:origin: proninyaroslav/libretorrent

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState)
{
  super.onActivityCreated(savedInstanceState);
  if (activity == null)
    activity = (AppCompatActivity) getActivity();
  HeavyInstanceStorage storage = HeavyInstanceStorage.getInstance(getFragmentManager());
  if (storage != null) {
    Bundle heavyInstance = storage.popData(HEAVY_STATE_TAG);
    if (heavyInstance != null)
      pieces = heavyInstance.getBooleanArray(TAG_PIECES);
  }
  if (savedInstanceState != null) {
    allPiecesCount = savedInstanceState.getInt(TAG_ALL_PIECES_COUNT);
    pieceSize = savedInstanceState.getInt(TAG_PIECE_SIZE);
    downloadedPieces = savedInstanceState.getInt(TAG_DOWNLOADED_PIECES);
  }
  pieceMap.setPieces(pieces);
  updatePieceCounter();
}

相关文章

Bundle类方法