下面列出了android.os.Bundle#putSerializable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 用于手机内存不足,进程被系统回收时的状态保存
*/
public void saveInstanceState(Bundle outState) {
outState.putSerializable("cropCacheFolder", cropCacheFolder);
outState.putSerializable("takeImageFile", takeImageFile);
outState.putSerializable("imageLoader", imageLoader);
outState.putSerializable("style", style);
outState.putBoolean("multiMode", multiMode);
outState.putBoolean("crop", crop);
outState.putBoolean("showCamera", showCamera);
outState.putBoolean("isSaveRectangle", isSaveRectangle);
outState.putInt("selectLimit", selectLimit);
outState.putInt("outPutX", outPutX);
outState.putInt("outPutY", outPutY);
outState.putInt("focusWidth", focusWidth);
outState.putInt("focusHeight", focusHeight);
}
public static void showDialog(FragmentManager fragmentManager, PermissifyManager.PendingPermissionCall pendingPermissionCall) {
if (fragmentManager.findFragmentByTag(TAG) != null) {
Log.w(TAG, "Dialog is already on screen - rejecting show command");
return;
}
Bundle args = new Bundle();
args.putSerializable(ARG_PENDING_CALL, pendingPermissionCall);
PermissionRationaleDialogFragment dialog = new PermissionRationaleDialogFragment();
dialog.setArguments(args);
dialog.setCancelable(false);
fragmentManager
.beginTransaction()
.add(dialog, TAG)
.commitAllowingStateLoss();
}
public static RMBTTermsCheckFragment newInstance(final CheckType followedBy) {
final RMBTTermsCheckFragment f = new RMBTTermsCheckFragment();
final Bundle bdl = new Bundle(1);
bdl.putSerializable("followedByType", followedBy);
f.setArguments(bdl);
return f;
}
public static DialogNewAndroidResource newInstance(@NonNull JavaProjectFolder p, @Nullable File currentFolder) {
Bundle args = new Bundle();
args.putSerializable(KEY_PROJECT_FILE, p);
args.putSerializable(KEY_PARENT_FILE, currentFolder);
DialogNewAndroidResource fragment = new DialogNewAndroidResource();
fragment.setArguments(args);
return fragment;
}
/**
* Start service to copy the database. It will be copied to the app's directory
*
* @param context : Context to start service
* @param database : File with the database that we want to copy
*/
public static void startService(Context context, File database) {
Bundle bundle = new Bundle();
bundle.putSerializable(EXTRA_FILE, database);
Intent intent = new Intent(context, CopyDbIntentService.class);
intent.putExtras(bundle);
context.startService(intent);
}
private void onAuthClientCompleted(AuthorizationClient.Result outcome) {
request = null;
int resultCode = (outcome.code == AuthorizationClient.Result.Code.CANCEL) ?
RESULT_CANCELED : RESULT_OK;
Bundle bundle = new Bundle();
bundle.putSerializable(RESULT_KEY, outcome);
Intent resultIntent = new Intent();
resultIntent.putExtras(bundle);
setResult(resultCode, resultIntent);
finish();
}
public static DialogLayoutPreview newInstance(File content) {
Bundle args = new Bundle();
args.putSerializable("file", content);
DialogLayoutPreview fragment = new DialogLayoutPreview();
fragment.setArguments(args);
return fragment;
}
/**
* fragment构建
*
* @param imageListener 图片视频选择回调
*/
public MultiImageCropFragment pickWithFragment(OnImagePickCompleteListener imageListener) {
checkVideoAndImage();
MultiImageCropFragment mFragment = new MultiImageCropFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(MultiImageCropActivity.INTENT_KEY_DATA_PRESENTER, presenter);
bundle.putSerializable(MultiImageCropActivity.INTENT_KEY_SELECT_CONFIG, selectConfig);
mFragment.setArguments(bundle);
mFragment.setOnImagePickCompleteListener(imageListener);
return mFragment;
}
public static AlbumListFragment newInstance(ArrayList<AlbumWrappedBean> albumBeans) {
Bundle bundle = new Bundle();
bundle.putSerializable(Constant.DATA, albumBeans);
AlbumListFragment albumListFragment = new AlbumListFragment();
albumListFragment.setArguments(bundle);
return albumListFragment;
}
private void onAuthClientCompleted(AuthorizationClient.Result outcome) {
request = null;
int resultCode = (outcome.code == AuthorizationClient.Result.Code.CANCEL) ?
RESULT_CANCELED : RESULT_OK;
Bundle bundle = new Bundle();
bundle.putSerializable(RESULT_KEY, outcome);
Intent resultIntent = new Intent();
resultIntent.putExtras(bundle);
setResult(resultCode, resultIntent);
finish();
}
public static FoldersFragment newInstance(File directory) {
FoldersFragment frag = new FoldersFragment();
Bundle b = new Bundle();
b.putSerializable(PATH, directory);
frag.setArguments(b);
return frag;
}
private void navigateToDetail(News item) {
Bundle args = new Bundle(2);
args.putSerializable(EXTRA_NEWS, item);
if (getIntent().hasExtra(EXTRA_EDITABLE)) {
args.putBoolean(EXTRA_EDITABLE, getIntent().getBooleanExtra(EXTRA_EDITABLE, false));
}
NewsDetailFragment fragment = NewsDetailFragment.newInstance(args);
getSupportFragmentManager().beginTransaction()
.replace(getSearchFragmentContainerId(), fragment, TAG_FRAG_DETAIL)
.addToBackStack(null)
.commit();
}
public void cashPayment(TotalModel totalModel) {
FragmentManager fragmentManager = ((AppCompatActivity) context).getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
Fragment fragment;
fragment = fragmentManager.findFragmentByTag(CashFragment.class.getSimpleName());
if (fragment == null)
fragment = new CashFragment();
Bundle bundle = new Bundle();
bundle.putSerializable("total", totalModel);
fragment.setArguments(bundle);
fragmentTransaction.add(((Checkout) context).checkoutBinding.frameLayout.getId(), fragment, fragment.getClass().getSimpleName());
fragmentTransaction.addToBackStack(fragment.getClass().getSimpleName()).commit();
}
public static ImageZoomFragment newInstance(RestaurantImage contentItem, int pos) {
ImageZoomFragment f = new ImageZoomFragment();
Bundle args = new Bundle();
args.putSerializable("content", contentItem);
args.putInt("pos", pos);
f.setArguments(args);
return f;
}
public void setupCurrentFriends()
{
Log.d(TAG,"Setting Up Current Friend");
FriendFrame f=new FriendFrame();
Bundle args=new Bundle();
args.putSerializable("Friend_1",friend_detail_list.get(0));
f.setArguments(args);
viewall_currentfriends.setEnabled(true);
getChildFragmentManager().beginTransaction().replace(R.id.currentFriendsFrame,f).commit();
}
public static Bundle getArgs(Type type, long id, String title, String showTitle) {
Bundle args = new Bundle();
args.putSerializable(ARG_TYPE, type);
args.putLong(ARG_ID, id);
args.putString(ARG_TITLE, title);
args.putString(ARG_SHOW_TITLE, showTitle);
return args;
}
public static SearchFragment newInstance(@NonNull Locale locale) {
Bundle args = new Bundle();
args.putSerializable(EXTRA_LOCALE, locale);
SearchFragment fragment = new SearchFragment();
fragment.setArguments(args);
return fragment;
}
public void notifyMediaStatusChanged(MediaStatus status) {
Bundle bundle = new Bundle();
bundle.putSerializable("media_changed", status);
ObservableManager.getDefaultObserable().sendToTarget(VenvyObservableTarget.TAG_MEDIA_CHANGED, bundle);
}
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
ResultReceiver channelResultReceiver = intent
.getParcelableExtra(getStringById(R.string.FETCHCHANNELRESULTRECEIVER_STR));
Gson gson = new Gson();
SettingsData settingsData = gson.fromJson(intent
.getStringExtra(getStringById(R.string.SETTINGSDATA_STR)), SettingsData.class);
Utils.SiteType siteType = (Utils.SiteType) intent.getSerializableExtra(getStringById(R.string.SITETYPE_STR));
if (siteType == Utils.SiteType.Pooq) {
mSiteProcessor = new PooqSiteProcessor(getApplicationContext());
} else if (siteType == Utils.SiteType.Tving) {
mSiteProcessor = new TvingSiteProcessor(getApplicationContext());
} else if (siteType == Utils.SiteType.Oksusu) {
mSiteProcessor = new OksusuSiteProcessor(getApplicationContext());
}
String authkey = (String) intent.getSerializableExtra(getStringById(R.string.AUTHKEY_STR));
if (authkey == null || authkey.length() == 0) {
mSiteProcessor.setAuthKey("");
} else {
mSiteProcessor.setAuthKey(authkey);
}
String mode = (String) intent.getSerializableExtra(getStringById(R.string.FETCHMODE_STR));
ArrayList<ChannelData> channels = new ArrayList<>();
ArrayList<CategoryData> category = new ArrayList<>();
boolean error = false;
if(mode.equals("create")) {
if (mSiteProcessor.doProcess(settingsData)) {
channels = mSiteProcessor.getChannelList();
category = mSiteProcessor.getCategorylList();
} else {
error = true;
}
} else if(mode.equals("refresh")) {
channels = intent.getParcelableArrayListExtra(getStringById(R.string.CHANNELS_STR));
category = intent.getParcelableArrayListExtra(getStringById(R.string.CATEGORY_STR));
mSiteProcessor.setChannelList(channels);
mSiteProcessor.setCategorylList(category);
if(!mSiteProcessor.updateProcess()) {
error = true;
}
}
Bundle retBundle = new Bundle();
retBundle.putParcelableArrayList(getStringById(R.string.CHANNELS_STR), channels);
retBundle.putParcelableArrayList(getStringById(R.string.CATEGORY_STR), category);
retBundle.putString(getStringById(R.string.AUTHKEY_STR), mSiteProcessor.getAuthKey());
retBundle.putSerializable(getStringById(R.string.SITETYPE_STR), siteType);
retBundle.putString(getStringById(R.string.FETCHMODE_STR), mode);
int retCode;
if(error) retCode = Utils.Code.ServiceIntent_Fail.ordinal();
else retCode = Utils.Code.ServiceIntent_OK.ordinal();
channelResultReceiver.send(retCode, retBundle);
}
}
public void setActionToBeAssigned(Action actionToBeAssigned) {
this.actionToBeAssigned = actionToBeAssigned;
Bundle args = new Bundle();
args.putSerializable(ACTION_KEY, actionToBeAssigned);
setArguments(args);
}