List of usage examples for android.os Bundle putParcelableArrayList
public void putParcelableArrayList(@Nullable String key, @Nullable ArrayList<? extends Parcelable> value)
From source file:org.getlantern.firetweet.util.Utils.java
public static void openStatuses(final Activity activity, final List<ParcelableStatus> statuses) { if (activity == null || statuses == null) return;// w w w .j a v a 2s .co m final Bundle extras = new Bundle(); extras.putParcelableArrayList(EXTRA_STATUSES, new ArrayList<>(statuses)); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_FIRETWEET); builder.authority(AUTHORITY_STATUSES); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.putExtras(extras); activity.startActivity(intent); }
From source file:org.getlantern.firetweet.util.Utils.java
public static void openUsers(final Activity activity, final List<ParcelableUser> users) { if (activity == null || users == null) return;/*from www .j av a 2s . c om*/ final Bundle extras = new Bundle(); extras.putParcelableArrayList(EXTRA_USERS, new ArrayList<>(users)); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_FIRETWEET); builder.authority(AUTHORITY_USERS); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.putExtras(extras); activity.startActivity(intent); }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (selectedStorage != NO_VALUE) outState.putInt("selectitem", selectedStorage); 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 v a2 s. c om /*if (mainFragment!=null) { outState.putParcelable("main_fragment", mainFragment); }*/ }
From source file:de.sourcestream.movieDB.controller.CastDetails.java
/** * Called to ask the fragment to save its current dynamic state, * so it can later be reconstructed in a new instance of its process is restarted. * * @param outState Bundle in which to place your saved state. */// w ww . jav a 2 s . com @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Used to avoid bug where we add item in the back stack // and if we change orientation twice the item from the back stack has null values if (save != null && save.getInt("timeOut") == 1) save = null; if (save != null) { outState.putBundle("save", save); if (addToBackStack) { activity.addCastDetailsBundle(save); addToBackStack = false; } } else { Bundle send = new Bundle(); send.putInt("currentId", currentId); if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) { timeOut = 1; request.cancel(true); } send.putInt("timeOut", timeOut); send.putString("title", title); if (timeOut == 0) { // HomePage send.putInt("homeIconCheck", homeIconCheck); if (homeIconCheck == 0) send.putString("homepage", homeIconUrl); // Gallery icon send.putInt("galleryIconCheck", galleryIconCheck); if (galleryIconCheck == 0) send.putStringArrayList("galleryList", galleryList); // More icon send.putInt("moreIconCheck", moreIconCheck); // Cast details info begins here if (castDetailsInfo != null) { // Name send.putString("name", castDetailsInfo.getName().getText().toString()); // Poster path url if (castDetailsInfo.getProfilePath().getTag() != null) send.putString("profilePathURL", castDetailsInfo.getProfilePath().getTag().toString()); // Birth info send.putString("birthInfo", castDetailsInfo.getBirthInfo().getText().toString()); // Also known as send.putString("alsoKnownAs", castDetailsInfo.getAlsoKnownAs().getText().toString()); // Known list if (castDetailsInfo.getKnownList() != null && castDetailsInfo.getKnownList().size() > 0) send.putParcelableArrayList("knownList", castDetailsInfo.getKnownList()); } // Cast details info ends here // Credits starts here if (castDetailsCredits != null) send.putParcelableArrayList("moviesList", moviesList); // Credits ends here // Overview if (castDetailsBiography != null) send.putString("biography", castDetailsBiography.getBiography().getText().toString()); } outState.putBundle("save", send); save = send; if (addToBackStack) { activity.addCastDetailsBundle(send); addToBackStack = false; } } }
From source file:com.nbplus.iotlib.IoTInterface.java
public void getDevicesList(DeviceTypes type, final IoTServiceStatusNotification callback, boolean forceRescan) { if (!mInitialized) { InitializeRequiredException initException = new InitializeRequiredException( "Init required Exception!!"); try {//from ww w . j av a 2 s.c om throw initException; } catch (Exception e) { e.printStackTrace(); } return; } if (mServiceStatus.equals(IoTServiceStatus.NONE) && !mErrorCodes.equals(IoTResultCodes.SUCCESS)) { mHandler.postDelayed(new Runnable() { @Override public void run() { callback.onResult(IoTServiceCommand.GET_DEVICE_LIST, mServiceStatus, mErrorCodes, null); } }, 100); } else if (mServiceStatus.equals(IoTServiceStatus.RUNNING)) { // ?? if (forceRescan) { // ? .. Message msg = new Message(); msg.what = IoTServiceCommand.GET_DEVICE_LIST; Bundle b = new Bundle(); String msgId = IoTServiceCommand.generateMessageId(mCtx); b.putString(IoTServiceCommand.KEY_MSGID, msgId); b.putSerializable(IoTServiceCommand.KEY_DEVICE_TYPE, type); mForceRescanCallback = new WeakReference<>(callback); //mRequestedCallbaks.put(msgId, new WeakReference<>(callback)); msg.setData(b); try { mServiceMessenger.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } else { mHandler.postDelayed(new Runnable() { @Override public void run() { Bundle b = new Bundle(); ArrayList<IoTDevice> devicesList = null; if (mBondedWithServerList != null && mBondedWithServerList.size() > 0) { devicesList = new ArrayList<>(mBondedWithServerList.values()); } else { devicesList = new ArrayList<>(); } b.putParcelableArrayList(IoTServiceCommand.KEY_DATA, devicesList); callback.onResult(IoTServiceCommand.GET_DEVICE_LIST, mServiceStatus, mErrorCodes, b); } }, 100); } } else if (mServiceStatus.equals(IoTServiceStatus.INITIALIZE)) { // bound ? String msgId = IoTServiceCommand.generateMessageId(mCtx); mForceRescanCallback = new WeakReference<>(callback); } else { // stop ?.. ?? ? ? ?. mHandler.postDelayed(new Runnable() { @Override public void run() { callback.onResult(IoTServiceCommand.GET_DEVICE_LIST, mServiceStatus, mErrorCodes, null); } }, 100); } }
From source file:de.sourcestream.movieDB.controller.MovieDetails.java
/** * Called to ask the fragment to save its current dynamic state, * so it can later be reconstructed in a new instance of its process is restarted. * * @param outState Bundle in which to place your saved state. *//*from ww w. j ava 2 s .c o m*/ @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Used to avoid bug where we add item in the back stack // and if we change orientation twice the item from the back stack has null values if (save != null && save.getInt("timeOut") == 1) save = null; if (save != null) { if (movieDetailsCast != null) save.putInt("lastVisitedPerson", movieDetailsCast.getLastVisitedPerson()); outState.putBundle("save", save); if (addToBackStack) { activity.addMovieDetailsBundle(save); addToBackStack = false; } } else { Bundle send = new Bundle(); send.putInt("currentId", currentId); if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) { timeOut = 1; request.cancel(true); } send.putInt("timeOut", timeOut); send.putString("title", title); if (timeOut == 0) { // HomePage send.putInt("homeIconCheck", homeIconCheck); if (homeIconCheck == 0) send.putString("homepage", homeIconUrl); // Gallery icon send.putInt("galleryIconCheck", galleryIconCheck); if (galleryIconCheck == 0) send.putStringArrayList("galleryList", galleryList); // Trailer icon send.putInt("trailerIconCheck", trailerIconCheck); if (trailerIconCheck == 0) send.putStringArrayList("trailerList", trailerList); // More icon send.putInt("moreIconCheck", moreIconCheck); // Movie details info begins here if (movieDetailsInfo != null) { // Backdrop path send.putInt("backDropCheck", movieDetailsInfo.getBackDropCheck()); if (movieDetailsInfo.getBackDropCheck() == 0 && movieDetailsInfo.getBackDropPath().getTag() != null) send.putString("backDropUrl", movieDetailsInfo.getBackDropPath().getTag().toString()); // Poster path url if (movieDetailsInfo.getPosterPath().getTag() != null) send.putString("posterPathURL", movieDetailsInfo.getPosterPath().getTag().toString()); // Rating send.putFloat("rating", movieDetailsInfo.getRatingBar().getRating()); send.putString("voteCount", movieDetailsInfo.getVoteCount().getText().toString()); // Title send.putString("titleText", movieDetailsInfo.getTitleText().getText().toString()); // Release date send.putString("releaseDate", movieDetailsInfo.getReleaseDate().getText().toString()); // Status send.putString("status", movieDetailsInfo.getStatusText().getText().toString()); // Tag line send.putString("tagline", movieDetailsInfo.getTagline().getText().toString()); // RunTime send.putString("runTime", movieDetailsInfo.getRuntime().getText().toString()); // Genres send.putString("genres", movieDetailsInfo.getGenres().getText().toString()); // Production countries send.putString("productionCountries", movieDetailsInfo.getCountries().getText().toString()); // Production companies send.putString("productionCompanies", movieDetailsInfo.getCompanies().getText().toString()); // Similar list if (movieDetailsInfo.getSimilarList() != null && movieDetailsInfo.getSimilarList().size() > 0) send.putParcelableArrayList("similarList", movieDetailsInfo.getSimilarList()); } // Movie details info ends here // Movie details cast starts here if (movieDetailsCast != null) { send.putParcelableArrayList("castList", castList); send.putInt("lastVisitedPerson", movieDetailsCast.getLastVisitedPerson()); } // Movie details cast ends here // Overview if (movieDetailsOverview != null) send.putString("overview", movieDetailsOverview.getOverview().getText().toString()); } outState.putBundle("save", send); save = send; if (addToBackStack) { activity.addMovieDetailsBundle(send); addToBackStack = false; } } }
From source file:com.nbplus.iotlib.IoTInterface.java
private void handleDeviceListNotification(Bundle b) { mEmergencyDeviceList.clear();/* w w w .ja va 2 s .c o m*/ HashMap<String, IoTDevice> scannedDevices = new HashMap<>(); if (b == null) { Log.w(TAG, "bundle data is null"); //return; // ? ? . } else { b.setClassLoader(IoTDevice.class.getClassLoader()); scannedDevices = (HashMap<String, IoTDevice>) b.getSerializable(IoTServiceCommand.KEY_DATA); if (scannedDevices == null) { scannedDevices = new HashMap<>(); } } if (scannedDevices == null || scannedDevices.size() == 0) { Log.w(TAG, "empty device list"); //return; // ? ? . } boolean changed = false; Iterator<String> iter = scannedDevices.keySet().iterator(); Log.d(TAG, "IoTServiceCommand.GET_DEVICE_LIST added size = " + scannedDevices.size()); while (iter.hasNext()) { String key = iter.next(); IoTDevice bondedDevice = mBondedWithServerList.get(key); IoTDevice scannedDevice = scannedDevices.get(key); Log.d(TAG, "check " + key + " is exist or new..."); // ? ?? ? ?? ? ? ? ?. if (bondedDevice == null) { continue; } // if (bondedDevice != null) { // already exist if (scannedDevice.getUuids() == null || scannedDevice.getUuids().size() == 0) { Log.e(TAG, ">>> xx device name " + bondedDevice.getDeviceName() + " has no uuid advertisement"); continue; } ArrayList<String> deviceUuids = bondedDevice.getUuids(); if (deviceUuids == null || deviceUuids.size() == 0) { if (bondedDevice.getDeviceTypeId() == IoTDevice.DEVICE_TYPE_ID_BT) { bondedDevice.setAdRecordHashMap(scannedDevice.getAdRecordHashMap()); bondedDevice.setUuids(scannedDevice.getUuids()); bondedDevice.setUuidLen(scannedDevice.getUuidLen()); } bondedDevice.setIsKnownDevice(isKnownScenarioDevice(bondedDevice.getDeviceTypeId(), bondedDevice.getUuids(), bondedDevice.getUuidLen())); mBondedWithServerList.put(key, bondedDevice); changed = true; } else { if (!scannedDevice.getUuids().equals(deviceUuids)) { if (bondedDevice.getDeviceTypeId() == IoTDevice.DEVICE_TYPE_ID_BT) { bondedDevice.setAdRecordHashMap(scannedDevice.getAdRecordHashMap()); bondedDevice.setUuids(scannedDevice.getUuids()); bondedDevice.setUuidLen(scannedDevice.getUuidLen()); } bondedDevice.setIsKnownDevice(isKnownScenarioDevice(bondedDevice.getDeviceTypeId(), bondedDevice.getUuids(), bondedDevice.getUuidLen())); mBondedWithServerList.put(key, bondedDevice); changed = true; } } // do nothing... // ? ?? ? ?? ? ? ? ?. // } else { // ArrayList<String> uuids = DataParser.getUuids(scannedDevice.getAdRecordHashMap()); // if (uuids == null || uuids.size() == 0) { // Log.e(TAG, ">>> device name " + scannedDevice.getDeviceName() + " has no uuid advertisement"); // continue; // } // scannedDevice.setUuids(uuids); // scannedDevice.setUuidLen(DataParser.getUuidLength(scannedDevice.getAdRecordHashMap())); // scannedDevice.setIsKnownDevice(isKnownScenarioDevice(scannedDevice.getDeviceTypeId(), scannedDevice.getUuids(), scannedDevice.getUuidLen())); // // bondedDevice = scannedDevice; // mBondedWithServerList.put(bondedDevice.getDeviceId(), bondedDevice); // changed = true; // } // ?? ?? . if (bondedDevice.isBondedWithServer() && isEmergencyCallDevice(bondedDevice.getDeviceTypeId(), bondedDevice.getUuids(), bondedDevice.getUuidLen())) { Log.d(TAG, "Emergency call device broadcast received : " + bondedDevice.getDeviceId()); mEmergencyDeviceList.add(bondedDevice); } // ? ? ?? Notification ?. if (bondedDevice.isBondedWithServer() && isKeepAliveDevice(bondedDevice)) { Log.d(TAG, "Smart sensor device found device ID = " + bondedDevice.getDeviceId()); if (!mKeepAliveDeviceList.containsKey(bondedDevice.getDeviceId())) { // ? ? ? 3 . if (mKeepAliveDeviceList.size() >= MAX_KEEP_ALIVE_CONNECTED_DEVICE_SIZE) { Log.d(TAG, "MAX_KEEP_ALIVE_CONNECTED_DEVICE_SIZE reached...."); // do nothing. } else { mKeepAliveDeviceList.put(bondedDevice.getDeviceId(), bondedDevice); Bundle extras = new Bundle(); IoTHandleData data = new IoTHandleData(); data.setDeviceId(bondedDevice.getDeviceId()); data.setDeviceTypeId(bondedDevice.getDeviceTypeId()); data.setIsKeepAliveDevice(true); extras.putParcelable(IoTServiceCommand.KEY_DATA, data); sendMessageToService(IoTServiceCommand.DEVICE_CONNECT, extras); } } else { Log.d(TAG, "This device already connected. and collecting data... "); } } } if (changed) { // save to preference. String json = mGson.toJson(mBondedWithServerList); if (json != null) { IoTServicePreference.setIoTDevicesList(mCtx, json); } } Log.d(TAG, "Current device size = " + mBondedWithServerList.size()); if (mEmergencyDeviceList.size() > 0) { // ?? ? long currTimeMs = System.currentTimeMillis(); //if (currTimeMs - mLastEmergencyDeviceFoundTimeMs > 1 * 60 * 1000) { mIsEmergencyDataCollecting = true; // ? ?? ? . Bundle extras = new Bundle(); extras.putBoolean(IoTServiceCommand.KEY_DATA, false); sendMessageToService(IoTServiceCommand.SCANNING_STOP, extras); mHandler.removeMessages(HANDLER_RETRIEVE_IOT_DEVICES); sendMessageToService(IoTServiceCommand.DEVICE_DISCONNECT_ALL, null); // } else { // Log.d(TAG, ">>> Already emergency device retrive.. before = " + (currTimeMs - mLastEmergencyDeviceFoundTimeMs)); // mIsEmergencyDataCollecting = false; // mEmergencyDeviceList.clear(); // } } if (mForceRescanCallback == null) { return; } final IoTServiceStatusNotification responseCallback = mForceRescanCallback.get(); if (responseCallback != null) { Bundle extras = new Bundle(); ArrayList<IoTDevice> devicesList = null; // 2015.12.09 // ?? ? BT . // ? ?? ? ??? ? . //if (mBondedWithServerList != null && mBondedWithServerList.size() > 0) { // devicesList = new ArrayList<>(mBondedWithServerList.values()); //} else { // devicesList = new ArrayList<>(); //} if (mKeepAliveDeviceList != null && mKeepAliveDeviceList.size() > 0) { devicesList = new ArrayList<>(mKeepAliveDeviceList.values()); } else { devicesList = new ArrayList<>(); } // ArrayList<String> deviceIdList = new ArrayList<>(); for (int i = 0; i < devicesList.size(); i++) { deviceIdList.add(devicesList.get(i).getDeviceId()); } ArrayList<IoTDevice> scannedDevicesList = new ArrayList<>(scannedDevices.values()); for (int i = 0; i < scannedDevicesList.size(); i++) { if (deviceIdList.contains(scannedDevicesList.get(i).getDeviceId())) { Log.d(TAG, "mForceRescanCallback device id " + scannedDevicesList.get(i).getDeviceId() + " is already added."); continue; } devicesList.add(scannedDevicesList.get(i)); } extras.putParcelableArrayList(IoTServiceCommand.KEY_DATA, devicesList); responseCallback.onResult(IoTServiceCommand.GET_DEVICE_LIST, mServiceStatus, mErrorCodes, extras); } mForceRescanCallback = null; // TODO : log if (BuildConfig.DEBUG) { iter = mBondedWithServerList.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); IoTDevice device = mBondedWithServerList.get(key); printScanDeviceInformation(device); } } }
From source file:com.android.mail.compose.ComposeActivity.java
private void saveState(Bundle state) { // We have no accounts so there is nothing to compose, and therefore, nothing to save. if (mAccounts == null || mAccounts.length == 0) { return;// www.j a va 2 s . com } // The framework is happy to save and restore the selection but only if it also saves and // restores the contents of the edit text. That's a lot of text to put in a bundle so we do // this manually. View focus = getCurrentFocus(); if (focus != null && focus instanceof EditText) { EditText focusEditText = (EditText) focus; state.putInt(EXTRA_FOCUS_SELECTION_START, focusEditText.getSelectionStart()); state.putInt(EXTRA_FOCUS_SELECTION_END, focusEditText.getSelectionEnd()); } final List<ReplyFromAccount> replyFromAccounts = mFromSpinner.getReplyFromAccounts(); final int selectedPos = mFromSpinner.getSelectedItemPosition(); final ReplyFromAccount selectedReplyFromAccount = (replyFromAccounts != null && replyFromAccounts.size() > 0 && replyFromAccounts.size() > selectedPos) ? replyFromAccounts.get(selectedPos) : null; if (selectedReplyFromAccount != null) { state.putString(EXTRA_SELECTED_REPLY_FROM_ACCOUNT, selectedReplyFromAccount.serialize().toString()); state.putParcelable(Utils.EXTRA_ACCOUNT, selectedReplyFromAccount.account); } else { state.putParcelable(Utils.EXTRA_ACCOUNT, mAccount); } if (mDraftId == UIProvider.INVALID_MESSAGE_ID && mRequestId != 0) { // We don't have a draft id, and we have a request id, // save the request id. state.putInt(EXTRA_REQUEST_ID, mRequestId); } // We want to restore the current mode after a pause // or rotation. int mode = getMode(); state.putInt(EXTRA_ACTION, mode); final Message message = createMessage(selectedReplyFromAccount, mRefMessage, mode, removeComposingSpans(mBodyView.getText())); if (mDraft != null) { message.id = mDraft.id; message.serverId = mDraft.serverId; message.uri = mDraft.uri; } state.putParcelable(EXTRA_MESSAGE, message); if (mRefMessage != null) { state.putParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE, mRefMessage); } else if (message.appendRefMessageContent) { // If we have no ref message but should be appending // ref message content, we have orphaned quoted text. Save it. state.putCharSequence(EXTRA_QUOTED_TEXT, mQuotedTextView.getQuotedTextIfIncluded()); } state.putBoolean(EXTRA_SHOW_CC, mCcBccView.isCcVisible()); state.putBoolean(EXTRA_SHOW_BCC, mCcBccView.isBccVisible()); state.putBoolean(EXTRA_RESPONDED_INLINE, mRespondedInline); state.putBoolean(EXTRA_SAVE_ENABLED, mSave != null && mSave.isEnabled()); state.putParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS, mAttachmentsView.getAttachmentPreviews()); state.putParcelable(EXTRA_VALUES, mExtraValues); state.putBoolean(EXTRA_TEXT_CHANGED, mTextChanged); // On configuration changes, we don't actually need to parse the body html ourselves because // the framework can correctly restore the body EditText to its exact original state. state.putBoolean(EXTRA_SKIP_PARSING_BODY, isChangingConfigurations()); }