本文整理汇总了Java中android.os.Bundle.getParcelableArray方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.getParcelableArray方法的具体用法?Java Bundle.getParcelableArray怎么用?Java Bundle.getParcelableArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Bundle
的用法示例。
在下文中一共展示了Bundle.getParcelableArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: StackRemoteViewsFactory
import android.os.Bundle; //导入方法依赖的package包/类
public StackRemoteViewsFactory(Context applicationContext, Intent intent) {
Log.v(TAG, "StackRemoteViewsFactory");
intent.setExtrasClassLoader(GitHubJourneyWidgetDataEntry.class.getClassLoader());
this.context = applicationContext;
appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 1);
Bundle bundle = intent.getBundleExtra("bundle");
Parcelable[] items = bundle.getParcelableArray("parcelables");
Log.v(TAG, "items size = " + items.length);
if (items.length != 0) {
widgetDatas = new ArrayList<>(items.length);
for (Parcelable item : items) {
widgetDatas.add((GitHubJourneyWidgetDataEntry) item);
}
} else {
widgetDatas = new ArrayList<>(0);
}
Log.v(TAG, "widgetDatas" + widgetDatas.size());
}
示例2: onCreateDialog
import android.os.Bundle; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle args = getArguments();
final AspectRatio[] ratios = (AspectRatio[]) args.getParcelableArray(ARG_ASPECT_RATIOS);
if (ratios == null) {
throw new RuntimeException("No ratios");
}
Arrays.sort(ratios);
final AspectRatio current = args.getParcelable(ARG_CURRENT_ASPECT_RATIO);
final AspectRatioAdapter adapter = new AspectRatioAdapter(ratios, current);
return new AlertDialog.Builder(getActivity())
.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
mListener.onAspectRatioSelected(ratios[position]);
}
})
.create();
}
示例3: onCreate
import android.os.Bundle; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Drawable> drawables = new ArrayList<>();
if(savedInstanceState != null) {
Resources resources = getResources();
Parcelable[] parcelables = savedInstanceState.getParcelableArray(BITMAPS);
for (int i = 0, n = parcelables.length; i < n; i++) {
drawables.add(new BitmapDrawable(resources, (Bitmap) parcelables[i]));
}
} else {
addDefaultImages(drawables);
}
imageViewPagerAdapter = new ImageViewPagerAdapter(drawables);
viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setOffscreenPageLimit(3);
viewPager.setAdapter(imageViewPagerAdapter);
}
示例4: d
import android.os.Bundle; //导入方法依赖的package包/类
public d(Bundle bundle) {
this.h = bundle.getString("ext_to");
this.i = bundle.getString("ext_from");
this.j = bundle.getString("ext_chid");
this.g = bundle.getString("ext_pkt_id");
Parcelable[] parcelableArray = bundle.getParcelableArray("ext_exts");
if (parcelableArray != null) {
this.l = new ArrayList(parcelableArray.length);
for (Parcelable parcelable : parcelableArray) {
a a = a.a((Bundle) parcelable);
if (a != null) {
this.l.add(a);
}
}
}
Bundle bundle2 = bundle.getBundle("ext_ERROR");
if (bundle2 != null) {
this.n = new h(bundle2);
}
}
示例5: onCreate
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
alertAdapter = new AlertAdapter(getActivity());
} else {
Alert[] alerts = (Alert[]) savedInstanceState.getParcelableArray(BUNDLE_KEY);
List<Alert> alertsList = new ArrayList<>();
for (Alert alert : alerts) {
alertsList.add(alert);
}
alertAdapter = new AlertAdapter(getActivity(), alertsList);
}
alertDAO = new AlertDAO(getActivity());
alertDAO.open();
if (alertAdapter.getCount() == 0) {
alertAdapter.addAllItems(alertDAO.getAllAlerts());
}
setListAdapter(alertAdapter);
setHasOptionsMenu(true);
}
示例6: restoreState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
mSavedState.clear();
mFragments.clear();
String lastMode = bundle.getString("mode", "");
if (!mode.equals(lastMode)) {
cleanupOldFragments(bundle);
return;
}
Parcelable[] fss = bundle.getParcelableArray("states");
if (fss != null) {
for (Parcelable fs : fss) {
mSavedState.add((Fragment.SavedState) fs);
}
}
Iterable<String> keys = bundle.keySet();
for (String key : keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (mFragments.size() <= index) {
mFragments.add(null);
}
f.setMenuVisibility(false);
mFragments.set(index, f);
} else {
Timber.w("Bad fragment at key %s", key);
}
}
}
}
}
示例7: onRestoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
currentIndex = bundle.getInt("currentIndex");
menuStatus = bundle.getInt("menuStatus");
lastIndex = bundle.getInt("lastIndex");
clickIndex = bundle.getInt("clickIndex");
state = bundle.getParcelable("superState");
runningPoints = (PathPoint[]) bundle.getParcelableArray("runningPoints");
endPathPoints = (PathPoint[]) bundle.getParcelableArray("endPoints");
}
super.onRestoreInstanceState(state);
}
示例8: onCreateView
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View view = inflater.inflate(R.layout.fragment_profiletab3, container, false);
nodata = (TextView) view.findViewById(R.id.nodata);
recyclerView = (RecyclerView) view.findViewById(R.id.news_list);
progress = (ProgressBar) view.findViewById(R.id.progress);
list = new ArrayList<>();
adapter = new NewsFeedAdapter(getContext());
recyclerView.setAdapter(adapter);
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(linearLayoutManager);
sharedPref = new SharedPref(getContext());
Log.d("id",sharedPref.getUserId());
if(savedInstanceState==null){
getData(1,sharedPref.getUserId());
progress.setVisibility(View.VISIBLE);
}
else{
if(savedInstanceState.getParcelableArray(USER_POST)!=null){
recyclerView.setVisibility(View.VISIBLE);
list = savedInstanceState.getParcelableArrayList(USER_POST);
adapter.refresh(list);
}
else{
nodata.setVisibility(View.VISIBLE);
nodata.setText("No Post Uploaded");
}
}
return view;
}
示例9: getNotificationArrayFromBundle
import android.os.Bundle; //导入方法依赖的package包/类
private static Notification[] getNotificationArrayFromBundle(Bundle bundle, String key) {
Parcelable[] array = bundle.getParcelableArray(key);
if ((array instanceof Notification[]) || array == null) {
return (Notification[]) array;
}
Notification[] typedArray = new Notification[array.length];
for (int i = 0; i < array.length; i++) {
typedArray[i] = (Notification) array[i];
}
bundle.putParcelableArray(key, typedArray);
return typedArray;
}
示例10: restoreState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
fragments.clear();
if (enableSavedStates) {
Parcelable[] fss = bundle.getParcelableArray("states");
savedState.clear();
if (fss != null) {
for (Parcelable fs : fss) {
savedState.add((Fragment.SavedState) fs);
}
}
}
Iterable<String> keys = bundle.keySet();
for (String key : keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = fragmentManager.getFragment(bundle, key);
if (f != null) {
setItemVisible(f, false);
fragments.put(index, f);
} else {
Log.w(TAG, "Bad fragment at key " + key);
}
}
}
}
}
示例11: restoreState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
Parcelable[] fss = bundle.getParcelableArray("states");
mSavedState.clear();
mFragments.clear();
if (fss != null) {
for (int i = 0; i < fss.length; i++) {
mSavedState.add((Fragment.SavedState) fss[i]);
}
}
Iterable<String> keys = bundle.keySet();
for (String key : keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (mFragments.size() <= index) {
mFragments.add(null);
}
f.setMenuVisibility(false);
mFragments.set(index, f);
} else {
Log.w(TAG, "Bad fragment at key " + key);
}
}
}
}
}
示例12: getParcelableArray
import android.os.Bundle; //导入方法依赖的package包/类
public Parcelable[] getParcelableArray(Bundle state, String key) {
return state.getParcelableArray(key + baseKey);
}
示例13: getParcelableArray
import android.os.Bundle; //导入方法依赖的package包/类
public Parcelable[] getParcelableArray(Bundle state, String key) {
return state.getParcelableArray(key + mBaseKey);
}
示例14: onCreate
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
// save some items we use frequently
final Intent intent = getIntent();
if (savedInstanceState != null) {
mPendingRequest = savedInstanceState.getInt(KEY_INSTANCE_STATE_PENDING_REQUEST);
mExistingAccounts =
savedInstanceState.getParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS);
// Makes sure that any user selection is preserved across orientation changes.
mSelectedAccountName = savedInstanceState.getString(
KEY_INSTANCE_STATE_SELECTED_ACCOUNT_NAME);
mSelectedAddNewAccount = savedInstanceState.getBoolean(
KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT, false);
mAccounts = savedInstanceState.getParcelableArrayList(KEY_INSTANCE_STATE_ACCOUNT_LIST);
mCallingUserId = savedInstanceState.getInt(KEY_USER_ID);
} else {
mPendingRequest = REQUEST_NULL;
mExistingAccounts = null;
mCallingUserId = intent.getIntExtra(KEY_USER_ID, -1);
// If the selected account as specified in the intent matches one in the list we will
// show is as pre-selected.
Account selectedAccount = intent.getParcelableExtra(EXTRA_SELECTED_ACCOUNT);
if (selectedAccount != null) {
mSelectedAccountName = selectedAccount.name;
}
}
VLog.v(TAG, "selected account name is " + mSelectedAccountName);
mSetOfAllowableAccounts = getAllowableAccountSet(intent);
mSetOfRelevantAccountTypes = getReleventAccountTypes(intent);
mDescriptionOverride = intent.getStringExtra(EXTRA_DESCRIPTION_TEXT_OVERRIDE);
mAccounts = getAcceptableAccountChoices(VAccountManager.get());
if (mDontShowPicker) {
super.onCreate(savedInstanceState);
return;
}
// In cases where the activity does not need to show an account picker, cut the chase
// and return the result directly. Eg:
// Single account -> select it directly
// No account -> launch add account activity directly
if (mPendingRequest == REQUEST_NULL) {
// If there are no relevant accounts and only one relevant account type go directly to
// add account. Otherwise let the user choose.
if (mAccounts.isEmpty()) {
setNonLabelThemeAndCallSuperCreate(savedInstanceState);
if (mSetOfRelevantAccountTypes.size() == 1) {
runAddAccountForAuthenticator(mSetOfRelevantAccountTypes.iterator().next());
} else {
startChooseAccountTypeActivity();
}
}
}
String[] listItems = getListOfDisplayableOptions(mAccounts);
mSelectedItemIndex = getItemIndexToSelect(
mAccounts, mSelectedAccountName, mSelectedAddNewAccount);
super.onCreate(savedInstanceState);
setContentView(R.layout.choose_type_and_account);
overrideDescriptionIfSupplied(mDescriptionOverride);
populateUIAccountList(listItems);
// Only enable "OK" button if something has been selected.
mOkButton = (Button) findViewById(android.R.id.button2);
mOkButton.setEnabled(mSelectedItemIndex != SELECTED_ITEM_NONE);
}
示例15: onCreate
import android.os.Bundle; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(savedInstanceState != null)
videos = (MovieObservableResult[]) savedInstanceState.getParcelableArray(VIDEOS_KEY);
//Dagger
((TgbApp) getApplication()).getAppComponent().inject(this);
//Butter knife
ButterKnife.bind(this);
//Toolbar
setSupportActionBar(toolbar);
//Gallery adapter
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
screenDimensions = new Point();
display.getSize(screenDimensions);
mAdapter = new GalleryAdapter(
this,
screenDimensions,
getResources().getConfiguration().orientation
);
//Recycler view grid
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(),
getResources().getInteger(R.integer.gallery_columns));
appbarParams = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new SpacesItemDecoration(5));
recyclerView.setAdapter(mAdapter);
swipeRefreshLayout.setOnRefreshListener(() -> {
videos = null;
loadingDialog.show(view -> refresh());
});
refresh();
}