List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key)
From source file:com.amaze.filemanager.fragments.MainFragment.java
void onSavedInstanceState(final Bundle savedInstanceState) { Bundle b = new Bundle(); String cur = savedInstanceState.getString("CURRENT_PATH"); if (cur != null) { b.putInt("index", savedInstanceState.getInt("index")); b.putInt("top", savedInstanceState.getInt("top")); scrolls.put(cur, b);/* w w w .j ava2 s . c om*/ openMode = OpenMode.getOpenMode(savedInstanceState.getInt("openMode", 0)); if (openMode == OpenMode.SMB) smbPath = savedInstanceState.getString("SmbPath"); LIST_ELEMENTS = savedInstanceState.getParcelableArrayList("list"); CURRENT_PATH = cur; folder_count = savedInstanceState.getInt("folder_count", 0); file_count = savedInstanceState.getInt("file_count", 0); results = savedInstanceState.getBoolean("results"); getMainActivity().getAppbar().getBottomBar().updatePath(CURRENT_PATH, results, MainActivityHelper.SEARCH_TEXT, openMode, folder_count, file_count, this); reloadListElements(true, results, !IS_LIST); if (savedInstanceState.getBoolean("selection")) { for (Integer index : savedInstanceState.getIntegerArrayList("position")) { adapter.toggleChecked(index, null); } } } }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mService = getTweetingsApplication().getServiceInterface(); mResolver = getContentResolver();/*from ww w. ja va2s. c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.compose); mActionBar = getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mUploadProvider = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null); final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras(); final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1; mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null; mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1; mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null; mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null; mInReplyToText = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_TWEET) : null; mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false; mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false; mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null; final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null; final String account_username = getAccountUsername(this, account_id); int text_selection_start = -1; mIsBuffer = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_BUFFER, false) : false; if (mInReplyToStatusId > 0) { if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null && (mentions == null || mentions.length < 1)) { mText = bundle.getString(INTENT_KEY_TEXT); } else if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); text_selection_start = mText.indexOf(' ') + 1; } mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false; final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String name = display_name ? mInReplyToName : mInReplyToScreenName; if (name != null) { setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, name)); } if (mAccountIds == null || mAccountIds.length == 0) { mAccountIds = new long[] { account_id }; } TextView replyText = (TextView) findViewById(R.id.reply_text); if (!isNullOrEmpty(mInReplyToText)) { replyText.setVisibility(View.VISIBLE); replyText.setText(mInReplyToText); } else { replyText.setVisibility(View.GONE); } } else { if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); } if (mAccountIds == null || mAccountIds.length == 0) { final long[] ids_in_prefs = ArrayUtils .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ','); final long[] activated_ids = getActivatedAccountIds(this); final long[] intersection = ArrayUtils.intersection(ids_in_prefs, activated_ids); mAccountIds = intersection.length > 0 ? intersection : activated_ids; } final String action = getIntent().getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { setTitle(R.string.share); final Bundle extras = getIntent().getExtras(); if (extras != null) { if (mText == null) { final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT); final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT); mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text)); } else { mText = bundle.getString(INTENT_KEY_TEXT); } if (mImageUri == null) { final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM); final String content_type = getIntent().getType(); if (extra_stream != null && content_type != null && content_type.startsWith("image/")) { final String real_path = getImagePathFromUri(this, extra_stream); final File file = real_path != null ? new File(real_path) : null; if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); mIsImageAttached = true; mIsPhotoAttached = false; } else { mImageUri = null; mIsImageAttached = false; } } } } } else if (bundle != null) { if (bundle.getString(INTENT_KEY_TEXT) != null) { mText = bundle.getString(INTENT_KEY_TEXT); } } } final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme()) ? new File(mImageUri.getPath()) : null; final boolean image_file_valid = image_file != null && image_file.exists(); mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE); if (image_file_valid) { reloadAttachedImageThumbnail(image_file); } mImageThumbnailPreview.setOnClickListener(this); mImageThumbnailPreview.setOnLongClickListener(this); mMenuBar.setOnMenuItemClickListener(this); mMenuBar.inflate(R.menu.menu_compose); mMenuBar.show(); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); mEditText.setMovementMethod(ArrowKeyMovementMethod.getInstance()); mEditText.setImeOptions(EditorInfo.IME_ACTION_GO); mEditText.setOnEditorActionListener(this); } mEditText.addTextChangedListener(this); if (mText != null) { mEditText.setText(mText); if (mIsQuote) { mEditText.setSelection(0); } else if (text_selection_start != -1 && text_selection_start < mEditText.length() && mEditText.length() > 0) { mEditText.setSelection(text_selection_start, mEditText.length() - 1); } else if (mEditText.length() > 0) { mEditText.setSelection(mEditText.length()); } } invalidateSupportOptionsMenu(); setMenu(); if (mColorIndicator != null) { mColorIndicator.setOrientation(ColorView.VERTICAL); mColorIndicator.setColor(getAccountColors(this, mAccountIds)); } mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED) : false; mIsPossiblySensitive = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE) : false; }
From source file:com.androzic.MapActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); Log.e(TAG, "onRestoreInstanceState()"); lastKnownLocation = savedInstanceState.getParcelable("lastKnownLocation"); lastRenderTime = savedInstanceState.getLong("lastRenderTime"); lastMagnetic = savedInstanceState.getLong("lastMagnetic"); lastDim = savedInstanceState.getLong("lastDim"); lastGeoid = savedInstanceState.getBoolean("lastGeoid"); waypointSelected = savedInstanceState.getInt("waypointSelected"); routeSelected = savedInstanceState.getInt("routeSelected"); mapObjectSelected = savedInstanceState.getLong("mapObjectSelected"); /*//from w w w . ja v a 2 s .co m * double[] distAncor = savedInstanceState.getDoubleArray("distAncor"); * if (distAncor != null) * { * application.distanceOverlay = new DistanceOverlay(this); * application.distanceOverlay.setAncor(distAncor); * } */ }
From source file:es.uniovi.imovil.fcrtrainer.HexadecimalExerciseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView;//w w w . jav a 2s.c o m rootView = inflater.inflate(R.layout.fragment_hexadecimal, container, false); etAnswer = (EditText) rootView.findViewById(R.id.answer); bChange = (Button) rootView.findViewById(R.id.change); bSolution = (Button) rootView.findViewById(R.id.seesolution); bCheck = (Button) rootView.findViewById(R.id.checkbutton); tvNumberToConvert = (TextView) rootView.findViewById(R.id.numbertoconvert); tvTitle = (TextView) rootView.findViewById(R.id.exercisetitle); tvPoints = (TextView) rootView.findViewById(R.id.tvpoints); randomGenerator = new Random(); etAnswer.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (EditorInfo.IME_ACTION_DONE == actionId) { if (tohex) isCorrect(etAnswer.getEditableText().toString().trim().toLowerCase(Locale.US)); else isCorrect(etAnswer.getEditableText().toString().trim()); } return false; } }); bCheck.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (tohex) isCorrect(etAnswer.getEditableText().toString().trim().toLowerCase(Locale.US)); else isCorrect(etAnswer.getEditableText().toString().trim()); } }); bChange.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { tohex ^= true; if (tohex) { setKeyboardLayout(); setTitle(); } else { setKeyboardLayout(); setTitle(); } generateRandomNumber(); } }); bSolution.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showSolution(); } }); if (savedInstanceState != null) { tohex = savedInstanceState.getBoolean("tohex"); numberToConvert = savedInstanceState.getInt("numbertoconvert"); updateUI(); setKeyboardLayout(); setTitle(); } else generateRandomNumber(); return rootView; }
From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java
void retrieveFromSavedInstance(final Bundle savedInstanceState) { Bundle b = new Bundle(); String cur = savedInstanceState.getString("CURRENT_PATH"); if (cur != null) { b.putInt("index", savedInstanceState.getInt("index")); b.putInt("top", savedInstanceState.getInt("top")); scrolls.put(cur, b);//from ww w .ja v a2s . c o m openMode = OpenMode.getOpenMode(savedInstanceState.getInt("openMode", 0)); if (openMode == OpenMode.SMB) smbPath = savedInstanceState.getString("SmbPath"); putLayoutElements(savedInstanceState.<LayoutElement>getParcelableArrayList("list")); CURRENT_PATH = cur; folder_count = savedInstanceState.getInt("folder_count", 0); file_count = savedInstanceState.getInt("file_count", 0); results = savedInstanceState.getBoolean("results"); MAIN_ACTIVITY.updatePath(CURRENT_PATH, results, openMode, folder_count, file_count); createViews(getLayoutElements(), true, (CURRENT_PATH), openMode, results, !IS_LIST); if (savedInstanceState.getBoolean("selection")) { for (int i : savedInstanceState.getIntegerArrayList("position")) { adapter.toggleChecked(i, null); } } } }
From source file:com.dwdesign.tweetings.util.Utils.java
public static String buildArguments(final Bundle args) { final Set<String> keys = args.keySet(); final JSONObject json = new JSONObject(); for (final String key : keys) { final Object value = args.get(key); if (value == null) { continue; }// w w w. j a v a 2 s . c o m try { if (value instanceof Boolean) { json.put(key, args.getBoolean(key)); } else if (value instanceof Integer) { json.put(key, args.getInt(key)); } else if (value instanceof Long) { json.put(key, args.getLong(key)); } else if (value instanceof String) { json.put(key, args.getString(key)); } else { Log.w(LOGTAG, "Unknown type " + (value != null ? value.getClass().getSimpleName() : null) + " in arguments key " + key); } } catch (final JSONException e) { e.printStackTrace(); } } return json.toString(); }
From source file:android.support.v17.leanback.app.BrowseFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TypedArray ta = getActivity().obtainStyledAttributes(R.styleable.LeanbackTheme); mContainerListMarginStart = (int) ta.getDimension(R.styleable.LeanbackTheme_browseRowsMarginStart, getActivity().getResources().getDimensionPixelSize(R.dimen.lb_browse_rows_margin_start)); mContainerListAlignTop = (int) ta.getDimension(R.styleable.LeanbackTheme_browseRowsMarginTop, getActivity().getResources().getDimensionPixelSize(R.dimen.lb_browse_rows_margin_top)); ta.recycle();//w ww .j ava2 s . c o m readArguments(getArguments()); if (mCanShowHeaders) { if (mHeadersBackStackEnabled) { mWithHeadersBackStackName = LB_HEADERS_BACKSTACK + this; mBackStackChangedListener = new BackStackListener(); getFragmentManager().addOnBackStackChangedListener(mBackStackChangedListener); mBackStackChangedListener.load(savedInstanceState); } else { if (savedInstanceState != null) { mShowingHeaders = savedInstanceState.getBoolean(HEADER_SHOW); } } } mScaleFactor = getResources().getFraction(R.fraction.lb_browse_rows_scale, 1, 1); }
From source file:de.da_sense.moses.client.FormFragment.java
/** * Creates a Layout for a Single_Questionnaire * // ww w .ja v a2 s . c o m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Intent intent = getActivity().getIntent(); mBelongsTo = intent.getIntExtra(WelcomeActivity.KEY_BELONGS_TO, WelcomeActivityPagerAdapter.TAB_RUNNING); mLayoutInflater = inflater; container.setBackgroundColor(getResources().getColor(android.R.color.background_light)); if (savedInstanceState != null) { if (mPosition == -1) mPosition = savedInstanceState.getInt(KEY_POSITION, -1); if (mAPKID == null) mAPKID = savedInstanceState.getString(InstalledExternalApplication.KEY_APK_ID, null); } if (mAPKID == null) Log.e(LOG_TAG, "onCreateView the APKID was not set and not in the bundle"); // check the presence of the formID if (mFormID == -1) { // the id is not set, it must be in the bundle mFormID = savedInstanceState.getInt(Form.KEY_FORM_ID, -1); if (mFormID == -1) // the id of the form was not in the bundle, this should never have happened Log.e(LOG_TAG, "onCreateView the formID was not set and not in the bundle"); } ExternalApplication app; // get the corresponding installedApp if (mBelongsTo == WelcomeActivityPagerAdapter.TAB_HISTORY) { app = HistoryExternalApplicationsManager.getInstance().getAppForId(mAPKID); } else { app = InstalledExternalApplicationsManager.getInstance().getAppForId(mAPKID); } if (app != null) { mForm = app.getSurvey().getForm(mFormID); } mRoot = (LinearLayout) inflater.inflate(R.layout.form, container, false); mScrollView = (ScrollView) mRoot.findViewById(R.id.scrollView1); // set focus to the dummy layout in order to prevent virtual keyboard from popping up View dummyLayout = mRoot.findViewById(R.id.dummy_layout_form); dummyLayout.requestFocus(); addFormToLayout(mForm, mRoot); if (savedInstanceState != null) { if (mIsFirst == null) mIsFirst = savedInstanceState.getBoolean(KEY_IS_FIRST); if (mIsLast == null) mIsLast = savedInstanceState.getBoolean(KEY_IS_LAST); } return (View) mRoot; }
From source file:android.support.mediacompat.service.ServiceBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); if (ACTION_CALL_MEDIA_BROWSER_SERVICE_METHOD.equals(intent.getAction()) && extras != null) { StubMediaBrowserServiceCompat service = StubMediaBrowserServiceCompat.sInstance; int method = extras.getInt(KEY_METHOD_ID, 0); switch (method) { case NOTIFY_CHILDREN_CHANGED: service.notifyChildrenChanged(extras.getString(KEY_ARGUMENT)); break; case SEND_DELAYED_NOTIFY_CHILDREN_CHANGED: service.sendDelayedNotifyChildrenChanged(); break; case SEND_DELAYED_ITEM_LOADED: service.sendDelayedItemLoaded(); break; case CUSTOM_ACTION_SEND_PROGRESS_UPDATE: service.mCustomActionResult.sendProgressUpdate(extras.getBundle(KEY_ARGUMENT)); break; case CUSTOM_ACTION_SEND_ERROR: service.mCustomActionResult.sendError(extras.getBundle(KEY_ARGUMENT)); break; case CUSTOM_ACTION_SEND_RESULT: service.mCustomActionResult.sendResult(extras.getBundle(KEY_ARGUMENT)); break; case SET_SESSION_TOKEN: StubMediaBrowserServiceCompatWithDelayedMediaSession.sInstance.callSetSessionToken(); break; }//w ww . j av a2s.co m } else if (ACTION_CALL_MEDIA_SESSION_METHOD.equals(intent.getAction()) && extras != null) { MediaSessionCompat session = StubMediaBrowserServiceCompat.sSession; int method = extras.getInt(KEY_METHOD_ID, 0); switch (method) { case SET_EXTRAS: session.setExtras(extras.getBundle(KEY_ARGUMENT)); break; case SET_FLAGS: session.setFlags(extras.getInt(KEY_ARGUMENT)); break; case SET_METADATA: session.setMetadata((MediaMetadataCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_PLAYBACK_STATE: session.setPlaybackState((PlaybackStateCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_QUEUE: List<QueueItem> items = extras.getParcelableArrayList(KEY_ARGUMENT); session.setQueue(items); break; case SET_QUEUE_TITLE: session.setQueueTitle(extras.getCharSequence(KEY_ARGUMENT)); break; case SET_SESSION_ACTIVITY: session.setSessionActivity((PendingIntent) extras.getParcelable(KEY_ARGUMENT)); break; case SET_CAPTIONING_ENABLED: session.setCaptioningEnabled(extras.getBoolean(KEY_ARGUMENT)); break; case SET_REPEAT_MODE: session.setRepeatMode(extras.getInt(KEY_ARGUMENT)); break; case SET_SHUFFLE_MODE: session.setShuffleMode(extras.getInt(KEY_ARGUMENT)); break; case SEND_SESSION_EVENT: Bundle arguments = extras.getBundle(KEY_ARGUMENT); session.sendSessionEvent(arguments.getString("event"), arguments.getBundle("extras")); break; case SET_ACTIVE: session.setActive(extras.getBoolean(KEY_ARGUMENT)); break; case RELEASE: session.release(); break; case SET_PLAYBACK_TO_LOCAL: session.setPlaybackToLocal(extras.getInt(KEY_ARGUMENT)); break; case SET_PLAYBACK_TO_REMOTE: ParcelableVolumeInfo volumeInfo = extras.getParcelable(KEY_ARGUMENT); session.setPlaybackToRemote(new VolumeProviderCompat(volumeInfo.controlType, volumeInfo.maxVolume, volumeInfo.currentVolume) { }); break; case SET_RATING_TYPE: session.setRatingType(RatingCompat.RATING_5_STARS); break; } } }