List of usage examples for android.os Bundle putParcelableArrayList
public void putParcelableArrayList(@Nullable String key, @Nullable ArrayList<? extends Parcelable> value)
From source file:de.mrapp.android.preference.activity.PreferenceActivity.java
@CallSuper @Override/*from w w w . j a va 2s . c o m*/ protected void onSaveInstanceState(final Bundle outState) { super.onSaveInstanceState(outState); outState.putBundle(CURRENT_BUNDLE_EXTRA, currentBundle); outState.putCharSequence(CURRENT_TITLE_EXTRA, currentTitle); outState.putCharSequence(CURRENT_SHORT_TITLE_EXTRA, currentShortTitle); outState.putParcelable(CURRENT_PREFERENCE_HEADER_EXTRA, currentHeader); outState.putParcelableArrayList(PREFERENCE_HEADERS_EXTRA, getListAdapter().getAllItems()); if (preferenceScreenFragment != null && preferenceScreenFragment.isAdded()) { getFragmentManager().putFragment(outState, PREFERENCE_SCREEN_FRAGMENT_EXTRA, preferenceScreenFragment); } }
From source file:com.filemanager.free.activities.MainActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { //super.onSaveInstanceState(outState); if (select != null) outState.putInt("selectitem", select); if (COPY_PATH != null) outState.putParcelableArrayList("COPY_PATH", COPY_PATH); if (MOVE_PATH != null) outState.putParcelableArrayList("MOVE_PATH", MOVE_PATH); if (oppathe != null) { outState.putString("oppathe", oppathe); outState.putString("oppathe1", oppathe1); outState.putParcelableArrayList("oparraylist", (oparrayList)); outState.putInt("operation", operation); }/*from w w w . j a va 2s . c o m*/ mainActivity.getFragmentManager().beginTransaction().commitAllowingStateLoss(); }
From source file:fr.openbike.android.service.SyncService.java
@SuppressWarnings("unchecked") @Override/*from w w w . j a va2 s. co m*/ protected void onHandleIntent(Intent intent) { NetworkInfo activeNetwork = ((ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo(); final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); Bundle bundle = new Bundle(); int status = STATUS_ERROR; if (activeNetwork == null || !activeNetwork.isConnectedOrConnecting()) { bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, "No network connectivity"); receiver.send(STATUS_ERROR, bundle); return; } String action = intent.getAction(); try { if (ACTION_SYNC.equals(action)) { if (receiver != null) { receiver.send(STATUS_SYNC_STATIONS, Bundle.EMPTY); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Object result = mRemoteExecutor.executeGet( mPreferences.getString(AbstractPreferencesActivity.UPDATE_SERVER_URL, "") + "/v2/stations", new RemoteStationsSyncHandler( prefs.getLong(AbstractPreferencesActivity.STATIONS_VERSION, 0)), this); if (result == null) { // Need stations update action = ACTION_UPDATE; } else { String message = (String) result; status = STATUS_SYNC_STATIONS_FINISHED; if (!"".equals(message)) { bundle.putString(EXTRA_RESULT, message); } prefs.edit().putLong(AbstractPreferencesActivity.LAST_UPDATE, System.currentTimeMillis()) .commit(); } } if (ACTION_UPDATE.equals(action)) { if (receiver != null) { receiver.send(STATUS_UPDATE_STATIONS, Bundle.EMPTY); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Object result = mRemoteExecutor .executeGet(mPreferences.getString(AbstractPreferencesActivity.UPDATE_SERVER_URL, "") + "/v2/stations/list", new RemoteStationsUpdateHandler(), this); status = STATUS_UPDATE_STATIONS_FINISHED; if (result != null) { bundle.putString(EXTRA_RESULT, (String) result); } prefs.edit().putLong(AbstractPreferencesActivity.LAST_UPDATE, System.currentTimeMillis()).commit(); } if (ACTION_CHOOSE_NETWORK.equals(action)) { if (receiver != null) { receiver.send(STATUS_SYNC_NETWORKS, Bundle.EMPTY); bundle = new Bundle(); bundle.putParcelableArrayList(EXTRA_RESULT, (ArrayList<Network>) mRemoteExecutor .executeGet(NETWORKS_URL, new RemoteNetworksHandler(), this)); status = STATUS_SYNC_NETWORKS_FINISHED; } } if (receiver != null) { receiver.send(status, bundle); } } catch (HandlerException e) { if (receiver != null) { // Pass back error to surface listener bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } } catch (Exception e) { if (receiver != null) { // Pass back error to surface listener e.printStackTrace(); bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, "Une erreur est survenue. Veuillez ressayer."); receiver.send(STATUS_ERROR, bundle); } } }
From source file:com.amaze.filemanager.activities.MainActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (select != null) outState.putInt("selectitem", select); if (COPY_PATH != null) outState.putParcelableArrayList("COPY_PATH", COPY_PATH); if (MOVE_PATH != null) outState.putParcelableArrayList("MOVE_PATH", MOVE_PATH); if (oppathe != null) { outState.putString("oppathe", oppathe); outState.putString("oppathe1", oppathe1); outState.putParcelableArrayList("oparraylist", (oparrayList)); outState.putInt("operation", operation); }// w ww. j a va2 s .c o m /*if (mainFragment!=null) { outState.putParcelable("main_fragment", mainFragment); }*/ }
From source file:org.opendatakit.survey.activities.MainMenuActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { // TODO Auto-generated method stub super.onSaveInstanceState(outState); if (dispatchStringWaitingForData != null) { outState.putString(DISPATCH_STRING_WAITING_FOR_DATA, dispatchStringWaitingForData); }//from w w w.ja va 2s . co m if (actionWaitingForData != null) { outState.putString(ACTION_WAITING_FOR_DATA, actionWaitingForData); } outState.putString(CURRENT_FRAGMENT, currentFragment.name()); if (getCurrentForm() != null) { outState.putString(FORM_URI, getCurrentForm().formUri.toString()); } if (getInstanceId() != null) { outState.putString(INSTANCE_ID, getInstanceId()); } if (getUploadTableId() != null) { outState.putString(UPLOAD_TABLE_ID, getUploadTableId()); } if (getScreenPath() != null) { outState.putString(SCREEN_PATH, getScreenPath()); } if (getControllerState() != null) { outState.putString(CONTROLLER_STATE, getControllerState()); } if (getAuxillaryHash() != null) { outState.putString(AUXILLARY_HASH, getAuxillaryHash()); } if (getAppName() != null) { outState.putString(IntentConsts.INTENT_KEY_APP_NAME, getAppName()); } outState.putBundle(SESSION_VARIABLES, sessionVariables); outState.putParcelableArrayList(SECTION_STATE_SCREEN_HISTORY, sectionStateScreenHistory); if (!queuedActions.isEmpty()) { String[] actionOutcomesArray = new String[queuedActions.size()]; queuedActions.toArray(actionOutcomesArray); outState.putStringArray(QUEUED_ACTIONS, actionOutcomesArray); } if (!queueResponseJSON.isEmpty()) { String[] qra = queueResponseJSON.toArray(new String[queueResponseJSON.size()]); outState.putStringArray(RESPONSE_JSON, qra); } if (mConflictTables != null && !mConflictTables.isEmpty()) { outState.putBundle(CONFLICT_TABLES, mConflictTables); } }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void openStatuses(final Activity activity, final List<ParcelableStatus> statuses) { if (activity == null || statuses == null) return;// w w w.ja va 2s . co m final Bundle extras = new Bundle(); extras.putParcelableArrayList(EXTRA_STATUSES, new ArrayList<ParcelableStatus>(statuses)); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWITTNUKER); builder.authority(AUTHORITY_STATUSES); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.putExtras(extras); SwipebackActivityUtils.startSwipebackActivity(activity, intent); }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void openUsers(final Activity activity, final List<ParcelableUser> users) { if (activity == null || users == null) return;/* w w w. java 2 s . co m*/ final Bundle extras = new Bundle(); extras.putParcelableArrayList(EXTRA_USERS, new ArrayList<ParcelableUser>(users)); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWITTNUKER); builder.authority(AUTHORITY_USERS); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.putExtras(extras); SwipebackActivityUtils.startSwipebackActivity(activity, intent); }
From source file:com.ushahidi.android.ui.fragment.ListDeploymentFragment.java
private void swipeToDeleteUndo() { mListViewTouchListener = new SwipeDismissRecyclerViewTouchListener(mDeploymentRecyclerView, new SwipeDismissRecyclerViewTouchListener.DismissCallbacks() { @Override/* w w w . j ava 2s. c o m*/ public boolean canDismiss(int position) { return true; } @Override public void onDismiss(RecyclerView listView, int[] reverseSortedPositions) { isDismissToDelete = true; mInteractiveToast .setInteractiveToastListener(new InteractiveToast.InteractiveToastListener() { @Override public void onPressed(Parcelable token) { Bundle b = (Bundle) token; final ArrayList<DeploymentRecyclerView.DeploymentParcelable> items = b .getParcelableArrayList(INTERACTIVE_TOAST_BUNDLE_KEY); if (!items.isEmpty()) { for (DeploymentRecyclerView.DeploymentParcelable deploymentModel : items) { mRecyclerViewAdapter.addItem(deploymentModel.getDeploymentModel(), deploymentModel.getPosition()); } items.clear(); } } }); mInteractiveToast.setOnHideListener(new InteractiveToast.OnHideListener() { @Override public void onHide(Parcelable token) { Bundle b = (Bundle) token; final ArrayList<DeploymentParcelable> items = b .getParcelableArrayList(INTERACTIVE_TOAST_BUNDLE_KEY); if (!items.isEmpty()) { for (DeploymentParcelable deploymentModel : items) { if (deploymentModel.getDeploymentModel() .getStatus() == DeploymentModel.Status.ACTIVATED) { mPrefs.getActiveDeploymentUrl().delete(); } mDeleteDeploymentPresenter .deleteDeployment(deploymentModel.getDeploymentModel()); } items.clear(); } } }); ArrayList<DeploymentParcelable> items = new ArrayList<>(); if (reverseSortedPositions.length > 0) { for (int i : reverseSortedPositions) { DeploymentParcelable parcelable = new DeploymentParcelable( mRecyclerViewAdapter.getItem(i), i); items.add(parcelable); mRecyclerViewAdapter.removeItem(mRecyclerViewAdapter.getItem(i)); } } // Stores the selected models into a bundle for later reuse. Bundle b = new Bundle(); b.putParcelableArrayList(INTERACTIVE_TOAST_BUNDLE_KEY, items); mInteractiveToast.show(getString(R.string.items_deleted, reverseSortedPositions.length), getString(R.string.undo), R.drawable.ic_undo, b); } }); }
From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { // TODO Auto-generated method stub super.onSaveInstanceState(outState); if (pageWaitingForData != null) { outState.putString(PAGE_WAITING_FOR_DATA, pageWaitingForData); }//from ww w . j av a 2s.c o m if (pathWaitingForData != null) { outState.putString(PATH_WAITING_FOR_DATA, pathWaitingForData); } if (actionWaitingForData != null) { outState.putString(ACTION_WAITING_FOR_DATA, actionWaitingForData); } outState.putString(CURRENT_FRAGMENT, currentFragment.name()); if (getCurrentForm() != null) { outState.putString(FORM_URI, getCurrentForm().formUri.toString()); } if (getInstanceId() != null) { outState.putString(INSTANCE_ID, getInstanceId()); } if (getUploadTableId() != null) { outState.putString(UPLOAD_TABLE_ID, getUploadTableId()); } if (getScreenPath() != null) { outState.putString(SCREEN_PATH, getScreenPath()); } if (getControllerState() != null) { outState.putString(CONTROLLER_STATE, getControllerState()); } if (getAuxillaryHash() != null) { outState.putString(AUXILLARY_HASH, getAuxillaryHash()); } if (getAppName() != null) { outState.putString(APP_NAME, getAppName()); } outState.putBundle(SESSION_VARIABLES, sessionVariables); outState.putParcelableArrayList(SECTION_STATE_SCREEN_HISTORY, sectionStateScreenHistory); if (mConflictTables != null && !mConflictTables.isEmpty()) { outState.putBundle(CONFLICT_TABLES, mConflictTables); } }
From source file:com.amaze.filemanager.asynchronous.services.CopyService.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { Bundle b = new Bundle(); isRootExplorer = intent.getBooleanExtra(TAG_IS_ROOT_EXPLORER, false); ArrayList<HybridFileParcelable> files = intent.getParcelableArrayListExtra(TAG_COPY_SOURCES); String targetPath = intent.getStringExtra(TAG_COPY_TARGET); int mode = intent.getIntExtra(TAG_COPY_OPEN_MODE, OpenMode.UNKNOWN.ordinal()); final boolean move = intent.getBooleanExtra(TAG_COPY_MOVE, false); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(c); accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference() .getCurrentUserColorPreferences(this, sharedPreferences).accent; mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); b.putInt(TAG_COPY_START_ID, startId); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small); customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big); Intent stopIntent = new Intent(TAG_BROADCAST_COPY_CANCEL); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(c, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_content_copy_white_36dp, getString(R.string.stop_ftp), stopPendingIntent); mBuilder = new NotificationCompat.Builder(c, NotificationConstants.CHANNEL_NORMAL_ID) .setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_content_copy_white_36dp) .setCustomContentView(customSmallContentViews).setCustomBigContentView(customBigContentViews) .setCustomHeadsUpContentView(customSmallContentViews) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setOngoing(true) .setColor(accentColor);// www . j av a2 s . c o m // set default notification views text NotificationConstants.setMetadata(c, mBuilder, NotificationConstants.TYPE_NORMAL); startForeground(NotificationConstants.COPY_ID, mBuilder.build()); initNotificationViews(); b.putBoolean(TAG_COPY_MOVE, move); b.putString(TAG_COPY_TARGET, targetPath); b.putInt(TAG_COPY_OPEN_MODE, mode); b.putParcelableArrayList(TAG_COPY_SOURCES, files); super.onStartCommand(intent, flags, startId); super.progressHalted(); //going async new DoInBackground(isRootExplorer).execute(b); // If we get killed, after returning from here, restart return START_STICKY; }