List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mRoots = DocumentsApplication.getRootsCache(this); virtualIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); virtualIntent.addCategory(Intent.CATEGORY_OPENABLE); virtualIntent.setType("*/*"); virtualIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); setResult(Activity.RESULT_CANCELED); setContentView(R.layout.activity);/*from w ww.j a v a2 s . c om*/ final Resources res = getResources(); mShowAsDialog = res.getBoolean(R.bool.show_as_dialog); if (mShowAsDialog) { // backgroundDimAmount from theme isn't applied; do it manually final WindowManager.LayoutParams a = getWindow().getAttributes(); a.dimAmount = 0.6f; getWindow().setAttributes(a); getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); getWindow().setFlags(~0, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Inset ourselves to look like a dialog final Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); final int width = (int) res.getFraction(R.dimen.dialog_width, size.x, size.x); final int height = (int) res.getFraction(R.dimen.dialog_height, size.y, size.y); final int insetX = (size.x - width) / 2; final int insetY = (size.y - height) / 2; final Drawable before = getWindow().getDecorView().getBackground(); final Drawable after = new InsetDrawable(before, insetX, insetY, insetX, insetY); getWindow().getDecorView().setBackground(after); // Dismiss when touch down in the dimmed inset area getWindow().getDecorView().setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { final float x = event.getX(); final float y = event.getY(); if (x < insetX || x > v.getWidth() - insetX || y < insetY || y > v.getHeight() - insetY) { finish(); return true; } } return false; } }); } else { // Non-dialog means we have a drawer mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_glyph, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerListener); mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_shadow, GravityCompat.START); mRootsContainer = findViewById(R.id.container_roots); } mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory); if (icicle != null) { mState = icicle.getParcelable(EXTRA_STATE); } else { if (DEBUG) { Log.i(TAG, "mState"); } buildDefaultState(); } // Hide roots when we're managing a specific root if (mState.action == ACTION_MANAGE) { if (mShowAsDialog) { findViewById(R.id.dialog_roots).setVisibility(View.GONE); } else { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } } if (mState.action == ACTION_CREATE) { final String mimeType = virtualIntent.getType(); final String title = virtualIntent.getStringExtra(Intent.EXTRA_TITLE); SaveFragment.show(getFragmentManager(), mimeType, title); } if (mState.action == ACTION_GET_CONTENT) { final Intent moreApps = new Intent(virtualIntent); moreApps.setComponent(null); moreApps.setPackage(null); RootsFragment.show(getFragmentManager(), moreApps); } else if (mState.action == ACTION_OPEN || mState.action == ACTION_CREATE) { RootsFragment.show(getFragmentManager(), null); } if (!mState.restored) { if (mState.action == ACTION_MANAGE) { final Uri rootUri = virtualIntent.getData(); new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor()); } else { new RestoreStackTask().execute(); } } else { onCurrentDirectoryChanged(ANIM_NONE); } }
From source file:com.android.mail.ui.AbstractActivityController.java
/** * Restore the state from the previous bundle. Subclasses should call this * method from the parent class, since it performs important UI * initialization./*from w w w . j a v a2 s . co m*/ * * @param savedState previous state */ @Override public void onRestoreInstanceState(Bundle savedState) { mDetachedConvUri = savedState.getParcelable(SAVED_DETACHED_CONV_URI); if (savedState.containsKey(SAVED_CONVERSATION)) { // Open the conversation. final Conversation conversation = savedState.getParcelable(SAVED_CONVERSATION); restoreConversation(conversation); } if (savedState.containsKey(SAVED_TOAST_BAR_OP)) { ToastBarOperation op = savedState.getParcelable(SAVED_TOAST_BAR_OP); if (op != null) { if (op.getType() == ToastBarOperation.UNDO) { onUndoAvailable(op); } else if (op.getType() == ToastBarOperation.ERROR) { onError(mFolder, true); } } } mFolderListFolder = savedState.getParcelable(SAVED_HIERARCHICAL_FOLDER); final ConversationListFragment convListFragment = getConversationListFragment(); if (convListFragment != null) { convListFragment.getAnimatedAdapter().onRestoreInstanceState(savedState); } /* * Restore the state of selected conversations. This needs to be done after the correct mode * is set and the action bar is fully initialized. If not, several key pieces of state * information will be missing, and the split views may not be initialized correctly. */ restoreSelectedConversations(savedState); // Order is important!!! // The dialog listener needs to happen *after* the selected set is restored. // If there has been an orientation change, and we need to recreate the listener for the // confirm dialog fragment (delete/archive/...), then do it here. if (mDialogAction != -1) { makeDialogListener(mDialogAction, mDialogFromSelectedSet, getUndoCallbackForDestructiveActionsWithAutoAdvance(mDialogAction, mCurrentConversation)); } mInbox = savedState.getParcelable(SAVED_INBOX_KEY); mConversationListScrollPositions.clear(); mConversationListScrollPositions.putAll(savedState.getBundle(SAVED_CONVERSATION_LIST_SCROLL_POSITIONS)); }
From source file:net.reichholf.dreamdroid.fragment.TimerEditFragment.java
@SuppressWarnings("unchecked") @Override//from ww w. j a va 2 s.c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.timer_edit, container, false); mName = (EditText) view.findViewById(R.id.EditTextTitle); mDescription = (EditText) view.findViewById(R.id.EditTextDescription); mEnabled = (CheckBox) view.findViewById(R.id.CheckBoxEnabled); mZap = (CheckBox) view.findViewById(R.id.CheckBoxZap); mAfterevent = (Spinner) view.findViewById(R.id.SpinnerAfterEvent); mLocation = (Spinner) view.findViewById(R.id.SpinnerLocation); mStartDate = (TextView) view.findViewById(R.id.TextViewBeginDate); mStartTime = (TextView) view.findViewById(R.id.TextViewBeginTime); mEndDate = (TextView) view.findViewById(R.id.TextViewEndDate); mEndTime = (TextView) view.findViewById(R.id.TextViewEndTime); mRepeatings = (TextView) view.findViewById(R.id.TextViewRepeated); mService = (TextView) view.findViewById(R.id.TextViewService); mTags = (TextView) view.findViewById(R.id.TextViewTags); // onClickListeners registerOnClickListener(mService, Statics.ITEM_PICK_SERVICE); registerOnClickListener(mStartDate, Statics.ITEM_PICK_BEGIN_DATE); registerOnClickListener(mStartTime, Statics.ITEM_PICK_BEGIN_TIME); registerOnClickListener(mEndDate, Statics.ITEM_PICK_END_DATE); registerOnClickListener(mEndTime, Statics.ITEM_PICK_END_TIME); registerOnClickListener(mRepeatings, Statics.ITEM_PICK_REPEATED); registerOnClickListener(mTags, Statics.ITEM_PICK_TAGS); mAfterevent.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { mTimer.put(Timer.KEY_AFTER_EVENT, Integer.valueOf(position).toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { // Auto is the default mAfterevent.setSelection(Timer.Afterevents.AUTO.intValue()); } }); mLocation.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { mTimer.put(Timer.KEY_LOCATION, DreamDroid.getLocations().get(position)); } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO implement some nothing-selected-handler for locations } }); // Initialize if savedInstanceState won't and instance was not retained if (savedInstanceState == null && mTimer == null && mTimerOld == null) { HashMap<String, Object> map = (HashMap<String, Object>) getArguments().get(sData); ExtendedHashMap data = new ExtendedHashMap(); data.putAll(map); mTimer = new ExtendedHashMap(); mTimer.putAll((HashMap<String, Object>) data.get("timer")); if (Intent.ACTION_EDIT.equals(getArguments().get("action"))) { mTimerOld = mTimer.clone(); } else { mTimerOld = null; } mSelectedTags = new ArrayList<>(); if (DreamDroid.getLocations().size() == 0 || DreamDroid.getTags().size() == 0) { mGetLocationsAndTagsTask = new GetLocationsAndTagsTask(); mGetLocationsAndTagsTask.execute(); } else { reload(); } } else if (savedInstanceState != null) { mTimer = savedInstanceState.getParcelable("timer"); mTimerOld = savedInstanceState.getParcelable("timerOld"); mSelectedTags = new ArrayList<>(Arrays.asList(savedInstanceState.getStringArray("selectedTags"))); if (mTimer != null) { reload(); } } else { reload(); } registerFab(R.id.fab_save, view, new View.OnClickListener() { @Override public void onClick(View v) { onItemSelected(Statics.ITEM_SAVE); } }); return view; }
From source file:com.android.mail.ui.AbstractActivityController.java
/** * Copy any selected conversations stored in the saved bundle into our selection set, * triggering {@link ConversationSetObserver} callbacks as our selection set changes. * *//*w w w. j av a2s . c om*/ private void restoreSelectedConversations(Bundle savedState) { if (savedState == null) { mCheckedSet.clear(); return; } final ConversationCheckedSet selectedSet = savedState.getParcelable(SAVED_SELECTED_SET); if (selectedSet == null || selectedSet.isEmpty()) { mCheckedSet.clear(); return; } // putAll will take care of calling our registered onSetPopulated method mCheckedSet.putAll(selectedSet); }
From source file:com.android.mail.compose.ComposeActivity.java
private void finishCreate() { final Bundle savedState = mInnerSavedState; findViews();//from w w w . ja va2s. co m final Intent intent = getIntent(); final Message message; final ArrayList<AttachmentPreview> previews; mShowQuotedText = false; final CharSequence quotedText; int action; // Check for any of the possibly supplied accounts.; final Account account; if (hadSavedInstanceStateMessage(savedState)) { action = savedState.getInt(EXTRA_ACTION, COMPOSE); account = savedState.getParcelable(Utils.EXTRA_ACCOUNT); message = savedState.getParcelable(EXTRA_MESSAGE); previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE); quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT); mExtraValues = savedState.getParcelable(EXTRA_VALUES); // Get the draft id from the request id if there is one. if (savedState.containsKey(EXTRA_REQUEST_ID)) { final int requestId = savedState.getInt(EXTRA_REQUEST_ID); if (sRequestMessageIdMap.containsKey(requestId)) { synchronized (mDraftLock) { mDraftId = sRequestMessageIdMap.get(requestId); } } } } else { account = obtainAccount(intent); action = intent.getIntExtra(EXTRA_ACTION, COMPOSE); // Initialize the message from the message in the intent message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE); previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE); mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI); quotedText = null; if (Analytics.isLoggable()) { if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0); } } } mAttachmentsView.setAttachmentPreviews(previews); setAccount(account); if (mAccount == null) { return; } initRecipients(); // Clear the notification and mark the conversation as seen, if necessary final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER); if (notificationFolder != null) { final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION); Intent actionIntent; if (conversationUri != null) { actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR); actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri); } else { actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS); actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri)); } actionIntent.setPackage(getPackageName()); actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account); actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder); startService(actionIntent); } if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) { mLaunchedFromEmail = true; } else if (Intent.ACTION_SEND.equals(intent.getAction())) { final Uri dataUri = intent.getData(); if (dataUri != null) { final String dataScheme = intent.getData().getScheme(); final String accountScheme = mAccount.composeIntentUri.getScheme(); mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme); } } if (mRefMessageUri != null) { mShowQuotedText = true; mComposeMode = action; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); String wearReply = null; if (remoteInput != null) { LogUtils.d(LOG_TAG, "Got remote input from new api"); CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT); if (input != null) { wearReply = input.toString(); } } else { // TODO: remove after legacy code has been removed. LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode"); ClipData clipData = intent.getClipData(); if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) { Bundle extras = clipData.getItemAt(0).getIntent().getExtras(); if (extras != null) { wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT); } } } if (!TextUtils.isEmpty(wearReply)) { createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode, wearReply).execute(); finish(); return; } else { LogUtils.w(LOG_TAG, "remote input string is null"); } } getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this); return; } else if (message != null && action != EDIT_DRAFT) { initFromDraftMessage(message); initQuotedTextFromRefMessage(mRefMessage, action); mShowQuotedText = message.appendRefMessageContent; // if we should be showing quoted text but mRefMessage is null // and we have some quotedText, display that if (mShowQuotedText && mRefMessage == null) { if (quotedText != null) { initQuotedText(quotedText, false /* shouldQuoteText */); } else if (mExtraValues != null) { initExtraValues(mExtraValues); return; } } } else if (action == EDIT_DRAFT) { if (message == null) { throw new IllegalStateException("Message must not be null to edit draft"); } initFromDraftMessage(message); // Update the action to the draft type of the previous draft switch (message.draftType) { case UIProvider.DraftType.REPLY: action = REPLY; break; case UIProvider.DraftType.REPLY_ALL: action = REPLY_ALL; break; case UIProvider.DraftType.FORWARD: action = FORWARD; break; case UIProvider.DraftType.COMPOSE: default: action = COMPOSE; break; } LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action); mShowQuotedText = message.appendRefMessageContent; if (message.refMessageUri != null) { // If we're editing an existing draft that was in reference to an existing message, // still need to load that original message since we might need to refer to the // original sender and recipients if user switches "reply <-> reply-all". mRefMessageUri = message.refMessageUri; mComposeMode = action; getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this); return; } } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) { if (mRefMessage != null) { initFromRefMessage(action); mShowQuotedText = true; } } else { if (initFromExtras(intent)) { return; } } mComposeMode = action; finishSetup(action, intent, savedState); }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log_OC.d(TAG, "onCreate() start"); // Log.d(TAG,"called first"); super.onCreate(savedInstanceState); // this calls onAccountChanged() // when ownCloud Account is valid // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); if (AccountUtils.getCurrentOwnCloudAccount(getBaseContext()) != null) { Intent intent = new Intent(this, InitialPageActivity.class); startActivity(intent);//from w w w . ja v a 2 s.c om } mHandler = new Handler(); // / bindings to transference services mUploadConnection = new ListServiceConnection(); mDownloadConnection = new ListServiceConnection(); bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE); bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE); shareNotifier = new NotificationCompat.Builder(this).setContentTitle("File Shared") .setSmallIcon(R.drawable.icon); Button shareButton = (Button) findViewById(R.id.shareItem); Intent fileShareIntent = new Intent(this, FileDisplayActivity.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, fileShareIntent, 0); shareNotifier.setContentIntent(pIntent); shareNotifier.setAutoCancel(true); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); dataSource = new DbFriends(this); // ContentResolver.setIsSyncable(getAccount(), // AccountAuthenticator.AUTHORITY, 1); // ContentResolver.setSyncAutomatically(getAccount(), // AccountAuthenticator.AUTHORITY,true); // broadcast receiver that is called by the service which downloads the // files to the phone instantdownloadreceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String message = intent.getStringExtra("message"); instantDownloadFile(); // make the http request and update the ui to include the sharer // information // unregisterReceiver(instantdownloadreceiver); } }; // PIN CODE request ; best location is to decide, let's try this first if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) { requestPinCode(); } // / file observer Intent observer_intent = new Intent(this, FileObserverService.class); observer_intent.putExtra(FileObserverService.KEY_FILE_CMD, FileObserverService.CMD_INIT_OBSERVED_LIST); startService(observer_intent); // / Load of saved instance state if (savedInstanceState != null) { mWaitingToPreview = (OCFile) savedInstanceState .getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW); } else { mWaitingToPreview = null; } // / USER INTERFACE // Inflate and set the layout view setContentView(R.layout.files); mDualPane = getResources().getBoolean(R.bool.large_land_layout); mLeftFragmentContainer = findViewById(R.id.left_fragment_container); mRightFragmentContainer = findViewById(R.id.right_fragment_container); if (savedInstanceState == null) { createMinFragments(); } // Action bar setup mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setHomeButtonEnabled(true); // mandatory since // Android ICS, // according to the // official // documentation setSupportProgressBarIndeterminateVisibility(false); // always AFTER // setContentView(...) // ; to work around // bug in its // implementation Log_OC.d(TAG, "onCreate() end"); }
From source file:com.android.mail.compose.ComposeActivity.java
private void initAttachmentsFromIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null) { extras = Bundle.EMPTY;/* w w w . j a v a 2 s.c om*/ } final String action = intent.getAction(); if (!mAttachmentsChanged) { long totalSize = 0; if (extras.containsKey(EXTRA_ATTACHMENTS)) { final String[] uris = (String[]) extras.getSerializable(EXTRA_ATTACHMENTS); final ArrayList<Uri> parsedUris = Lists.newArrayListWithCapacity(uris.length); for (String uri : uris) { parsedUris.add(Uri.parse(uri)); } totalSize += handleAttachmentUrisFromIntent(parsedUris); } if (extras.containsKey(Intent.EXTRA_STREAM)) { if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { final ArrayList<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); totalSize += handleAttachmentUrisFromIntent(uris); } else { final Uri uri = extras.getParcelable(Intent.EXTRA_STREAM); final ArrayList<Uri> uris = Lists.newArrayList(uri); totalSize += handleAttachmentUrisFromIntent(uris); } } if (totalSize > 0) { mAttachmentsChanged = true; updateSaveUi(); Analytics.getInstance().sendEvent("send_intent_with_attachments", Integer.toString(getAttachments().size()), null, totalSize); } } }
From source file:net.exclaimindustries.geohashdroid.wiki.WikiPictureEditor.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get some display metrics. We need to scale the gallery thumbnails // accordingly, else they look too small on big screens and too big on // small screens. We do this here to save calculations later, else // we'd be doing floating-point multiplication on EVERY SINGLE // THUMBNAIL, and we can't guarantee that won't be painful on every // Android phone. DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); THUMB_DIMEN = (int) (getResources().getDimensionPixelSize(R.dimen.nominal_icon_size) * metrics.density); Log.d(DEBUG_TAG, "Thumbnail dimensions: " + THUMB_DIMEN); mInfo = (Info) getIntent().getParcelableExtra(GeohashDroid.INFO); setContentView(R.layout.pictureselect); Button submitButton = (Button) findViewById(R.id.wikieditbutton); ImageButton galleryButton = (ImageButton) findViewById(R.id.GalleryButton); galleryButton.setOnClickListener(new View.OnClickListener() { @Override/*from www . j av a2 s . c o m*/ public void onClick(View v) { // Fire off the Gallery! startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), REQUEST_PICTURE); } }); submitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // We don't want to let the Activity handle the dialog. That WILL // cause it to show up properly and all, but after a configuration // change (i.e. orientation shift), it won't show or update any text // (as far as I know), as we can't reassign the handler properly. // So, we'll handle it ourselves. mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true, WikiPictureEditor.this); mConnectionHandler = new PictureConnectionRunner(mProgressHandler, WikiPictureEditor.this); mWikiConnectionThread = new Thread(mConnectionHandler, "WikiConnectionThread"); mWikiConnectionThread.start(); } }); // We can set the background on the thumbnail view right away, even if // it's not actually visible. ImageView thumbView = (ImageView) findViewById(R.id.ThumbnailImage); thumbView.setBackgroundResource(R.drawable.gallery_selected_default); thumbView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); // Now, let's see if we have anything retained... try { RetainedThings retain = (RetainedThings) getLastNonConfigurationInstance(); if (retain != null) { // We have something retained! Thus, we need to construct the // popup and update it with the right status, assuming the // thread's still going. if (retain.thread != null && retain.thread.isAlive()) { mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true, WikiPictureEditor.this); mConnectionHandler = retain.handler; mConnectionHandler.resetHandler(mProgressHandler); mWikiConnectionThread = retain.thread; } // And in any event, put the image info back up. mCurrentFile = retain.currentFile; mCurrentThumbnail = retain.thumbnail; mPictureLocation = retain.picLocation; setThumbnail(); } else { // If there was nothing to retain, maybe we've got a bundle. if (icicle != null) { if (icicle.containsKey(STORED_FILE)) mCurrentFile = icicle.getString(STORED_FILE); if (icicle.containsKey(STORED_LOCATION)) mPictureLocation = icicle.getParcelable(STORED_LOCATION); } // Rebuild it all in any event. buildThumbnail(); setThumbnail(); } } catch (Exception ex) { // If we got an exception, reset the thumbnail info with whatever // we have handy. buildThumbnail(); setThumbnail(); } // Rebuild the thumbnail and display it as need be. }
From source file:com.android.launcher2.Launcher.java
/** * Restores the previous state, if it exists. * * @param savedState The previous state. *///from w ww .ja va2 s .co m private void restoreState(Bundle savedState) { if (savedState == null) { return; } State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal())); if (state == State.APPS_CUSTOMIZE) { mOnResumeState = State.APPS_CUSTOMIZE; } int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, -1); if (currentScreen > -1) { mWorkspace.setCurrentPage(currentScreen); } final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1); final int pendingAddScreen = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SCREEN, -1); if (pendingAddContainer != ItemInfo.NO_ID && pendingAddScreen > -1) { mPendingAddInfo.container = pendingAddContainer; mPendingAddInfo.screen = pendingAddScreen; mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X); mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y); mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X); mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y); mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO); mWaitingForResult = true; mRestoring = true; } boolean renameFolder = savedState.getBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, false); if (renameFolder) { long id = savedState.getLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID); mFolderInfo = mModel.getFolderById(this, sFolders, id); mRestoring = true; } // Restore the AppsCustomize tab if (mAppsCustomizeTabHost != null) { String curTab = savedState.getString("apps_customize_currentTab"); if (curTab != null) { mAppsCustomizeTabHost .setContentTypeImmediate(mAppsCustomizeTabHost.getContentTypeForTabTag(curTab)); mAppsCustomizeContent.loadAssociatedPages(mAppsCustomizeContent.getCurrentPage()); } int currentIndex = savedState.getInt("apps_customize_currentIndex"); mAppsCustomizeContent.restorePageForIndex(currentIndex); } }