List of usage examples for android.os Bundle putBoolean
public void putBoolean(@Nullable String key, boolean value)
From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); int index;/* ww w .j av a 2 s . c o m*/ View vi; if (listView != null) { if (IS_LIST) { index = (mLayoutManager).findFirstVisibleItemPosition(); vi = listView.getChildAt(0); } else { index = (mLayoutManagerGrid).findFirstVisibleItemPosition(); vi = listView.getChildAt(0); } int top = (vi == null) ? 0 : vi.getTop(); outState.putInt("index", index); outState.putInt("top", top); //outState.putBoolean("IS_LIST", IS_LIST); outState.putParcelableArrayList("list", getLayoutElements()); outState.putString("CURRENT_PATH", CURRENT_PATH); outState.putBoolean("selection", selection); outState.putInt("openMode", openMode.ordinal()); outState.putInt("folder_count", folder_count); outState.putInt("file_count", file_count); if (selection) { outState.putIntegerArrayList("position", adapter.getCheckedItemPositions()); } outState.putBoolean("results", results); if (openMode == OpenMode.SMB) { outState.putString("SmbPath", smbPath); } } }
From source file:com.dycody.android.idealnote.DetailFragment.java
@Override public void onSaveInstanceState(Bundle outState) { if (noteTmp != null) { noteTmp.setTitle(getNoteTitle()); noteTmp.setContent(getNoteContent()); outState.putParcelable("noteTmp", noteTmp); outState.putParcelable("note", note); outState.putParcelable("noteOriginal", noteOriginal); outState.putParcelable("attachmentUri", attachmentUri); outState.putBoolean("orientationChanged", orientationChanged); }// ww w .jav a2 s. c om super.onSaveInstanceState(outState); }
From source file:com.android.calendar.EventInfoFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(BUNDLE_KEY_EVENT_ID, mEventId); outState.putLong(BUNDLE_KEY_START_MILLIS, mStartMillis); outState.putLong(BUNDLE_KEY_END_MILLIS, mEndMillis); outState.putBoolean(BUNDLE_KEY_IS_DIALOG, mIsDialog); outState.putInt(BUNDLE_KEY_WINDOW_STYLE, mWindowStyle); outState.putBoolean(BUNDLE_KEY_DELETE_DIALOG_VISIBLE, mDeleteDialogVisible); outState.putInt(BUNDLE_KEY_CALENDAR_COLOR, mCalendarColor); outState.putBoolean(BUNDLE_KEY_CALENDAR_COLOR_INIT, mCalendarColorInitialized); outState.putInt(BUNDLE_KEY_ORIGINAL_COLOR, mOriginalColor); outState.putBoolean(BUNDLE_KEY_ORIGINAL_COLOR_INIT, mOriginalColorInitialized); outState.putInt(BUNDLE_KEY_CURRENT_COLOR, mCurrentColor); outState.putBoolean(BUNDLE_KEY_CURRENT_COLOR_INIT, mCurrentColorInitialized); outState.putInt(BUNDLE_KEY_CURRENT_COLOR_KEY, mCurrentColorKey); outState.putInt(BUNDLE_KEY_DELETE_DIALOG_CHOICE, mDeleteDialogChoice); // We'll need the temporary response for configuration changes. outState.putInt(BUNDLE_KEY_TENTATIVE_USER_RESPONSE, mTentativeUserSetResponse); if (mTentativeUserSetResponse != Attendees.ATTENDEE_STATUS_NONE && mEditResponseHelper != null) { outState.putInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, mEditResponseHelper.getWhichEvents()); }/*from w w w.j av a2 s . c o m*/ // Save the current response. int response; if (mAttendeeResponseFromIntent != Attendees.ATTENDEE_STATUS_NONE) { response = mAttendeeResponseFromIntent; } else { response = mOriginalAttendeeResponse; } outState.putInt(BUNDLE_KEY_ATTENDEE_RESPONSE, response); if (mUserSetResponse != Attendees.ATTENDEE_STATUS_NONE) { response = mUserSetResponse; outState.putInt(BUNDLE_KEY_USER_SET_ATTENDEE_RESPONSE, response); outState.putInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, mWhichEvents); } // Save the reminders. mReminders = EventViewUtils.reminderItemsToReminders(mReminderViews, mReminderMinuteValues, mReminderMethodValues); int numReminders = mReminders.size(); ArrayList<Integer> reminderMinutes = new ArrayList<Integer>(numReminders); ArrayList<Integer> reminderMethods = new ArrayList<Integer>(numReminders); for (ReminderEntry reminder : mReminders) { reminderMinutes.add(reminder.getMinutes()); reminderMethods.add(reminder.getMethod()); } outState.putIntegerArrayList(BUNDLE_KEY_REMINDER_MINUTES, reminderMinutes); outState.putIntegerArrayList(BUNDLE_KEY_REMINDER_METHODS, reminderMethods); }
From source file:com.hybris.mobile.lib.commerce.provider.CatalogProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteDatabase sqLiteDatabase = mDatabaseHelper.getWritableDatabase(); String tableName;// www. j av a2 s.c om String where; String order = ""; Bundle bundleSyncAdapter = new Bundle(); String lastPathSegment = uri.getLastPathSegment(); if (StringUtils.isNotBlank(sortOrder)) { order = " ORDER BY " + sortOrder; } switch (URI_MATCHER.match(uri)) { // Getting the content for a group (list of simple data) case CatalogContract.Provider.CODE_GROUP_ID: tableName = CatalogContract.DataBaseDataSimple.TABLE_NAME; where = CatalogContract.DataBaseDataLinkGroup.TABLE_NAME + "." + CatalogContract.DataBaseDataLinkGroup.ATT_GROUP_ID + "='" + lastPathSegment + "'"; // Limit for the query on the sync adapter String currentPage = uri.getQueryParameter(CatalogContract.Provider.QUERY_PARAM_CURRENT_PAGE); String pageSize = uri.getQueryParameter(CatalogContract.Provider.QUERY_PARAM_PAGE_SIZE); // Bundle information for the syncing part bundleSyncAdapter.putString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID, lastPathSegment); if (StringUtils.isNotBlank(currentPage) && StringUtils.isNotBlank(pageSize)) { bundleSyncAdapter.putInt(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE, Integer.valueOf(currentPage)); bundleSyncAdapter.putInt(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE, Integer.valueOf(pageSize)); } break; // Getting a specific data detail case CatalogContract.Provider.CODE_DATA_ID: case CatalogContract.Provider.CODE_DATA_DETAILS_ID: tableName = CatalogContract.DataBaseDataDetails.TABLE_NAME; where = CatalogContract.DataBaseDataDetails.TABLE_NAME + "." + CatalogContract.DataBaseDataDetails.ATT_DATA_ID + "='" + lastPathSegment + "'"; // Bundle information for the syncing part bundleSyncAdapter.putString(CatalogSyncConstants.SYNC_PARAM_DATA_ID, lastPathSegment); // We don't load the variants for a specific data bundleSyncAdapter.putBoolean(CatalogSyncConstants.SYNC_PARAM_LOAD_VARIANTS, false); break; default: Log.e(TAG, "URI not recognized" + uri.toString()); throw new IllegalArgumentException("URI not recognized" + uri.toString()); } // We do the query by joining the data to the group Cursor cursor = sqLiteDatabase.rawQuery("SELECT * FROM " + tableName + " INNER JOIN " + CatalogContract.DataBaseDataLinkGroup.TABLE_NAME + " ON " + tableName + "." + CatalogContract.DataBaseData.ATT_DATA_ID + "=" + CatalogContract.DataBaseDataLinkGroup.TABLE_NAME + "." + CatalogContract.DataBaseDataLinkGroup.ATT_DATA_ID + " WHERE " + where + order, null); // Register the cursor to watch the uri for changes cursor.setNotificationUri(getContext().getContentResolver(), uri); // Existing data if (cursor.getCount() > 0) { // TODO - For now we check if one the items is out-of-sync and we sync all of them if this is the case // Future - Check every out-of-date items and sync them cursor.moveToLast(); int status = cursor.getInt(cursor.getColumnIndex(CatalogContract.DataBaseData.ATT_STATUS)); cursor.moveToFirst(); // Data expired, we request a sync if (status == CatalogContract.SyncStatus.OUTOFDATE.getValue()) { Log.i(TAG, "Data for " + uri.toString() + " is out-of-date, requesting a sync"); requestSync(bundleSyncAdapter); // TODO - the uptodate/outofdate should be done in the sync adapter // We up-to-date all the data in case the sync does not return any results (we base our out of sync on the last item of the cursor) if (URI_MATCHER.match(uri) == CatalogContract.Provider.CODE_GROUP_ID) { updateInternalDataSyncStatus(cursor, tableName, SyncStatus.UPTODATE); } } // Data updated, we invalidate the data else { Log.i(TAG, "Data for " + uri.toString() + " is up-of-date, invalidating it"); updateInternalDataSyncStatus(cursor, tableName, SyncStatus.OUTOFDATE); } } // No data found, we request a sync if it's not already up-to-date else { boolean triggerSyncAdapter; switch (URI_MATCHER.match(uri)) { // Saving the sync info for the group case CatalogContract.Provider.CODE_GROUP_ID: triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriSyncGroup(authority), CatalogContract.DataBaseSyncStatusGroup.ATT_GROUP_ID, CatalogContract.DataBaseSyncStatusGroup.TABLE_NAME, lastPathSegment); break; // Saving the sync info for the data case CatalogContract.Provider.CODE_DATA_ID: triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriData(authority), CatalogContract.DataBaseData.ATT_DATA_ID, CatalogContract.DataBaseDataSimple.TABLE_NAME, lastPathSegment); break; // Saving the sync info for the data details case CatalogContract.Provider.CODE_DATA_DETAILS_ID: triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriDataDetails(authority), CatalogContract.DataBaseData.ATT_DATA_ID, CatalogContract.DataBaseDataDetails.TABLE_NAME, lastPathSegment); break; default: Log.e(TAG, "URI not recognized" + uri.toString()); throw new IllegalArgumentException("URI not recognized" + uri.toString()); } // Trigger the sync adapter if (triggerSyncAdapter) { Log.i(TAG, "No data found for " + uri.toString() + " and data out-of-date, requesting a sync"); requestSync(bundleSyncAdapter); } else { Log.i(TAG, "No data found for " + uri.toString() + " and data up-to-date"); } } return cursor; }
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); if (mColorFilter != null) { savedInstanceState.putInt(KEY_THEME_COLOR, mColorFilterColor); }/*from w w w .j a v a 2 s.c o m*/ savedInstanceState.putBoolean(KEY_IS_SUGGESTION_LIST_COLLAPSED, mIsSuggestionListCollapsed); savedInstanceState.putLong(KEY_PREVIOUS_CONTACT_ID, mPreviousContactId); savedInstanceState.putBoolean(KEY_SUGGESTIONS_AUTO_SELECTED, mSuggestionsShouldAutoSelected); savedInstanceState.putSerializable(KEY_SELECTED_SUGGESTION_CONTACTS, mSelectedAggregationIds); }
From source file:com.dwdesign.tweetings.util.Utils.java
public static Bundle parseArguments(final String string) { final Bundle bundle = new Bundle(); if (string != null) { try {// w w w . j a v a 2 s . c o m final JSONObject json = new JSONObject(string); final Iterator<?> it = json.keys(); while (it.hasNext()) { final Object key_obj = it.next(); if (key_obj == null) { continue; } final String key = key_obj.toString(); final Object value = json.get(key); if (value instanceof Boolean) { bundle.putBoolean(key, json.getBoolean(key)); } else if (value instanceof Integer) { // Simple workaround for account_id if (INTENT_KEY_ACCOUNT_ID.equals(key)) { bundle.putLong(key, json.getLong(key)); } else { bundle.putInt(key, json.getInt(key)); } } else if (value instanceof Long) { bundle.putLong(key, json.getLong(key)); } else if (value instanceof String) { bundle.putString(key, json.getString(key)); } else { Log.w(LOGTAG, "Unknown type " + value.getClass().getSimpleName() + " in arguments key " + key); } } } catch (final JSONException e) { e.printStackTrace(); } catch (final ClassCastException e) { e.printStackTrace(); } } return bundle; }
From source file:com.amaze.filemanager.activities.MainActivity.java
public void showSMBDialog(String name, String path, boolean edit) { if (path.length() > 0 && name.length() == 0) { int i = -1; if ((i = DataUtils.containsServer(new String[] { name, path })) != -1) { name = DataUtils.servers.get(i)[0]; }/*w w w . j a v a2 s . c om*/ } SmbConnectDialog smbConnectDialog = new SmbConnectDialog(); Bundle bundle = new Bundle(); bundle.putString("name", name); bundle.putString("path", path); bundle.putBoolean("edit", edit); smbConnectDialog.setArguments(bundle); smbConnectDialog.show(getFragmentManager(), "smbdailog"); }
From source file:android.app.FragmentManager.java
Bundle saveFragmentBasicState(Fragment f) { Bundle result = null; if (mStateBundle == null) { mStateBundle = new Bundle(); }/*from www. ja v a 2s.c o m*/ f.performSaveInstanceState(mStateBundle); if (!mStateBundle.isEmpty()) { result = mStateBundle; mStateBundle = null; } if (f.mView != null) { saveFragmentViewState(f); } if (f.mSavedViewState != null) { if (result == null) { result = new Bundle(); } result.putSparseParcelableArray(FragmentManagerImpl.VIEW_STATE_TAG, f.mSavedViewState); } if (!f.mUserVisibleHint) { if (result == null) { result = new Bundle(); } // Only add this if it's not the default value result.putBoolean(FragmentManagerImpl.USER_VISIBLE_HINT_TAG, f.mUserVisibleHint); } return result; }
From source file:br.org.funcate.dynamicforms.FragmentDetailActivity.java
private void saveAction() throws Exception { FragmentDetail detailFragment = (FragmentDetail) getSupportFragmentManager() .findFragmentById(R.id.detailFragment); if (detailFragment != null) { detailFragment.storeFormItems(false); }//from ww w .j av a 2s.c o m if (sectionObject == null) { throw new Exception(this.getString(R.string.session_object_exception)); } // extract and check constraints List<String> availableFormNames = TagsManager.getFormNames4Section(sectionObject); Bundle formData = null; if (availableFormNames.isEmpty()) { throw new Exception(this.getString(R.string.session_object_exception)); } for (String formNameIt : availableFormNames) { JSONObject formObject = TagsManager.getForm4Name(formNameIt, sectionObject); JSONArray formItemsArray = TagsManager.getFormItems(formObject); int length = formItemsArray != null ? formItemsArray.length() : 0; formData = new Bundle(length); ArrayList<String> keys = new ArrayList<String>(length); ArrayList<String> types = new ArrayList<String>(length); String key = ""; String value = ""; String type = ""; boolean insertKey;// This control flag is used to ignore some types because are simply ignored or are manipulated in other time. for (int i = 0; i < length; i++) { JSONObject jsonObject = formItemsArray.getJSONObject(i); if (jsonObject.has(TAG_KEY)) key = jsonObject.getString(TAG_KEY).trim(); if (jsonObject.has(TAG_VALUE)) { value = jsonObject.getString(TAG_VALUE).trim(); } if (jsonObject.has(TAG_TYPE)) { type = jsonObject.getString(TAG_TYPE).trim(); } if (!key.equals("") && !value.equals("") && !type.equals("")) { insertKey = true; if (type.equals(TYPE_STRING)) { formData.putString(key, value); } else if (type.equals(TYPE_STRINGAREA)) { formData.putString(key, value); } else if (type.equals(TYPE_DOUBLE)) { formData.putDouble(key, Double.valueOf(value)); } else if (type.equals(TYPE_INTEGER)) { formData.putInt(key, Integer.valueOf(value)); } else if (type.equals(TYPE_DATE)) { formData.putString(key, value); } else if (type.equals(TYPE_TIME)) { formData.putString(key, value); } else if (type.equals(TYPE_LABEL)) { insertKey = false; //formData.putString(key, value); } else if (type.equals(TYPE_LABELWITHLINE)) { insertKey = false; //formData.putString(key, value); } else if (type.equals(TYPE_BOOLEAN)) { formData.putBoolean(key, Boolean.valueOf(value)); } else if (type.equals(TYPE_STRINGCOMBO)) { formData.putString(key, value); } else if (type.equals(TYPE_CONNECTEDSTRINGCOMBO)) { formData.putString(key, value); } else if (type.equals(TYPE_STRINGMULTIPLECHOICE)) { insertKey = false; //formData.putString(key,value); } else if (type.equals(TYPE_PICTURES)) { insertKey = false; // Using the new key to represent a list of image paths. It is manipulated on posterior time. //formData.putString(key,value); decodeFromJson(value, formData); } if (insertKey) { keys.add(key); types.add(type); } } } formData.putStringArrayList(LibraryConstants.FORM_TYPES, types); formData.putStringArrayList(LibraryConstants.FORM_KEYS, keys); if (sectionObject.has(FormUtilities.ATTR_GEOJSON_TAGS)) { JSONObject geojsonGeometry = sectionObject.getJSONObject(FormUtilities.ATTR_GEOJSON_TAGS); formData.putString(FormUtilities.ATTR_GEOJSON_TAGS, geojsonGeometry.toString()); } if (pointId >= 0) { formData.putLong(FormUtilities.GEOM_ID, pointId); } if (existingFeatureData != null) { formData.putBundle(FormUtilities.ATTR_DATA_VALUES, existingFeatureData); } } if (formData == null) { throw new Exception(this.getString(R.string.session_object_exception)); } Intent intent = getIntent(); intent.putExtra(LibraryConstants.PREFS_KEY_FORM, formData); setResult(Activity.RESULT_OK, intent); finish(); }
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);//from w w w . j a va 2 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; }