List of usage examples for android.os Bundle putLong
public void putLong(@Nullable String key, long value)
From source file:com.owncloud.android.ui.activity.FileActivity.java
/** * {@inheritDoc}/*from w ww . ja v a 2s . c o m*/ */ @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(FileActivity.EXTRA_FILE, mFile); outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification); outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor()); outState.putBoolean(KEY_TRY_SHARE_AGAIN, mTryShareAgain); if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) { // Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST // since it doesn't have a title then outState.putString(KEY_ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString()); } }
From source file:com.android.browser.BookmarksPageCallbacks.java
private void editBookmark(BrowserBookmarksAdapter adapter, int position) { Intent intent = new Intent(getActivity(), AddBookmarkPage.class); Cursor cursor = adapter.getItem(position); Bundle item = new Bundle(); item.putString(BrowserContract.Bookmarks.TITLE, cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE)); item.putString(BrowserContract.Bookmarks.URL, cursor.getString(BookmarksLoader.COLUMN_INDEX_URL)); byte[] data = cursor.getBlob(BookmarksLoader.COLUMN_INDEX_FAVICON); if (data != null) { item.putParcelable(BrowserContract.Bookmarks.FAVICON, BitmapFactory.decodeByteArray(data, 0, data.length)); }//from w w w . j a v a2 s . c o m item.putLong(BrowserContract.Bookmarks._ID, cursor.getLong(BookmarksLoader.COLUMN_INDEX_ID)); item.putLong(BrowserContract.Bookmarks.PARENT, cursor.getLong(BookmarksLoader.COLUMN_INDEX_PARENT)); intent.putExtra(AddBookmarkPage.EXTRA_EDIT_BOOKMARK, item); intent.putExtra(AddBookmarkPage.EXTRA_IS_FOLDER, cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) == 1); startActivity(intent); }
From source file:com.dwdesign.tweetings.activity.LinkHandlerActivity.java
private boolean setFragment(final Uri uri) { final Bundle extras = getIntent().getExtras(); Fragment fragment = null;//from ww w. j a va2s. c om if (uri != null) { final Bundle bundle = new Bundle(); if (extras != null) { bundle.putAll(extras); } switch (matchLinkId(uri)) { case LINK_ID_STATUS: { setTitle(R.string.view_status); fragment = new StatusFragment(); final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); bundle.putLong(INTENT_KEY_STATUS_ID, parseLong(param_status_id)); break; } case LINK_ID_USER: { setTitle(R.string.view_user_profile); fragment = new UserProfileFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!isNullOrEmpty(param_screen_name)) { bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); } if (!isNullOrEmpty(param_user_id)) { bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); } break; } case LINK_ID_USER_TIMELINE: { setTitle(R.string.tweets); fragment = new UserTimelineFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!isNullOrEmpty(param_screen_name)) { bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); } if (!isNullOrEmpty(param_user_id)) { bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); } break; } case LINK_ID_USER_FAVORITES: { setTitle(R.string.favorites); fragment = new UserFavoritesFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!isNullOrEmpty(param_screen_name)) { bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); } if (!isNullOrEmpty(param_user_id)) { bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); } break; } case LINK_ID_USER_FOLLOWERS: { setTitle(R.string.followers); fragment = new UserFollowersFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!isNullOrEmpty(param_screen_name)) { bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); } if (!isNullOrEmpty(param_user_id)) { bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); } break; } case LINK_ID_USER_FRIENDS: { setTitle(R.string.following); fragment = new UserFriendsFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!isNullOrEmpty(param_screen_name)) { bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); } if (!isNullOrEmpty(param_user_id)) { bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); } break; } case LINK_ID_USER_BLOCKS: { setTitle(R.string.blocked_users); fragment = new UserBlocksListFragment(); break; } case LINK_ID_CONVERSATION: { setTitle(R.string.view_conversation); fragment = new ConversationFragment(); final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); bundle.putLong(INTENT_KEY_STATUS_ID, parseLong(param_status_id)); break; } case LINK_ID_DIRECT_MESSAGES_CONVERSATION: { setTitle(R.string.direct_messages); fragment = new DMConversationFragment(); final String param_conversation_id = uri.getQueryParameter(QUERY_PARAM_CONVERSATION_ID); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final long conversation_id = parseLong(param_conversation_id); if (conversation_id > 0) { bundle.putLong(INTENT_KEY_CONVERSATION_ID, conversation_id); } else if (param_screen_name != null) { bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); } break; } case LINK_ID_LIST_DETAILS: { setTitle(R.string.user_list); fragment = new UserListDetailsFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String param_list_name = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isNullOrEmpty(param_list_id) && (isNullOrEmpty(param_list_name) || isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id))) { finish(); return false; } bundle.putInt(INTENT_KEY_LIST_ID, parseInt(param_list_id)); bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); bundle.putString(INTENT_KEY_LIST_NAME, param_list_name); break; } case LINK_ID_LIST_TYPES: { setTitle(R.string.user_list); fragment = new UserListTypesFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id)) { finish(); return false; } bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); break; } case LINK_ID_LIST_TIMELINE: { setTitle(R.string.list_timeline); fragment = new UserListTimelineFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String param_list_name = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isNullOrEmpty(param_list_id) && (isNullOrEmpty(param_list_name) || isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id))) { finish(); return false; } bundle.putInt(INTENT_KEY_LIST_ID, parseInt(param_list_id)); bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); bundle.putString(INTENT_KEY_LIST_NAME, param_list_name); break; } case LINK_ID_LIST_MEMBERS: { setTitle(R.string.list_members); fragment = new UserListMembersFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String param_list_name = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isNullOrEmpty(param_list_id) && (isNullOrEmpty(param_list_name) || isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id))) { finish(); return false; } bundle.putInt(INTENT_KEY_LIST_ID, parseInt(param_list_id)); bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); bundle.putString(INTENT_KEY_LIST_NAME, param_list_name); break; } case LINK_ID_LIST_SUBSCRIBERS: { setTitle(R.string.list_subscribers); fragment = new UserListSubscribersFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String param_list_name = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isNullOrEmpty(param_list_id) && (isNullOrEmpty(param_list_name) || isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id))) { finish(); return false; } bundle.putInt(INTENT_KEY_LIST_ID, parseInt(param_list_id)); bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); bundle.putString(INTENT_KEY_LIST_NAME, param_list_name); break; } case LINK_ID_LIST_CREATED: { setTitle(R.string.list_created_by_user); fragment = new UserListCreatedFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id)) { finish(); return false; } bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); break; } case LINK_ID_LIST_SUBSCRIPTIONS: { setTitle(R.string.list_user_followed); fragment = new UserListSubscriptionsFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id)) { finish(); return false; } bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); break; } case LINK_ID_LIST_MEMBERSHIPS: { setTitle(R.string.list_following_user); fragment = new UserListMembershipsFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (isNullOrEmpty(param_screen_name) && isNullOrEmpty(param_user_id)) { finish(); return false; } bundle.putLong(INTENT_KEY_USER_ID, parseLong(param_user_id)); bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); break; } case LINK_ID_USERS_RETWEETED_STATUS: { setTitle(R.string.users_retweeted_this); fragment = new UserRetweetedStatusFragment(); final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); bundle.putLong(INTENT_KEY_STATUS_ID, parseLong(param_status_id)); break; } case LINK_ID_SAVED_SEARCHES: { setTitle(R.string.saved_searches); fragment = new SavedSearchesListFragment(); break; } case LINK_ID_RETWEETED_TO_ME: { setTitle(R.string.retweets_of_me); fragment = new RetweetedToMeFragment(); break; } case LINK_ID_NEARBY: { setTitle(R.string.nearby_tweets); fragment = new NativeNearbyMapFragment(); break; } case LINK_ID_TRENDS: { setTitle(R.string.trends); fragment = new TrendsFragment(); break; } case LINK_ID_USER_MENTIONS: { setTitle(R.string.user_mentions); fragment = new UserMentionsFragment(); final String param_screen_name = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); if (!isNullOrEmpty(param_screen_name)) { bundle.putString(INTENT_KEY_SCREEN_NAME, param_screen_name); } else { finish(); return false; } break; } case LINK_ID_MENTIONS: { setTitle(R.string.mentions); fragment = new MentionsFragment(); break; } case LINK_ID_INCOMING_FRIENDSHIPS: { setTitle(R.string.incoming_friendships); fragment = new IncomingFriendshipsFragment(); break; } case LINK_ID_BUFFERAPP: { final String param_code = uri.getQueryParameter(QUERY_PARAM_CODE); setTitle(R.string.accounts); fragment = new AccountsFragment(); bundle.putString(INTENT_KEY_BUFFERAPP_CODE, param_code); break; } default: { break; } } final String param_account_id = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID); if (param_account_id != null) { bundle.putLong(INTENT_KEY_ACCOUNT_ID, parseLong(param_account_id)); } else { final String param_account_name = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_NAME); if (param_account_name != null) { bundle.putLong(INTENT_KEY_ACCOUNT_ID, getAccountId(this, param_account_name)); } else { final long account_id = getDefaultAccountId(this); if (isMyAccount(this, account_id)) { bundle.putLong(INTENT_KEY_ACCOUNT_ID, account_id); } else { finish(); return false; } } } if (fragment != null) { fragment.setArguments(bundle); } } mFragment = fragment; return true; }
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@SuppressWarnings("deprecation") public void displayStatus(final ParcelableStatus status) { mStatus = null;/* w w w . ja va 2s. com*/ mImagesPreviewFragment.clear(); if (status == null || getActivity() == null) return; mStatus = status; final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null); mMenuBar.inflate(R.menu.menu_status); final MenuItem bufferView = mMenuBar.getMenu().findItem(MENU_ADD_TO_BUFFER); if (bufferView != null) { if (buffer_authorised != null && !buffer_authorised.equals("")) { bufferView.setVisible(true); } else { bufferView.setVisible(false); } } setMenuForStatus(getActivity(), mMenuBar.getMenu(), status); mMenuBar.show(); final boolean is_multiple_account_enabled = getActivatedAccountIds(getActivity()).length > 1; updateUserColor(); mContentScroller .setBackgroundResource(is_multiple_account_enabled ? R.drawable.ic_label_account_nopadding : 0); if (is_multiple_account_enabled) { final Drawable d = mContentScroller.getBackground(); if (d != null) { d.mutate().setColorFilter(getAccountColor(getActivity(), status.account_id), PorterDuff.Mode.MULTIPLY); mContentScroller.invalidate(); } } mNameView.setText(status.name); mScreenNameView.setText("@" + status.screen_name); mScreenNameView.setCompoundDrawablesWithIntrinsicBounds( getUserTypeIconRes(status.is_verified, status.is_protected), 0, 0, 0); mTextView.setText(status.text); final TwidereLinkify linkify = new TwidereLinkify(mTextView); linkify.setOnLinkClickListener(new OnLinkClickHandler(getActivity(), mAccountId)); linkify.addAllLinks(); final boolean is_reply = status.in_reply_to_status_id > 0; final String time = formatToLongTimeString(getActivity(), status.status_timestamp); final String strTime = "<a href=\"https://twitter.com/" + status.screen_name + "/status/" + String.valueOf(status.status_id) + "\">" + time + "</a>"; final String source_html = status.source; if (!isNullOrEmpty(time) && !isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.time_source, strTime, source_html))); } else if (isNullOrEmpty(time) && !isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.source, source_html))); } else if (!isNullOrEmpty(time) && isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(time); } mTimeAndSourceView.setMovementMethod(LinkMovementMethod.getInstance()); mInReplyToView.setVisibility(is_reply ? View.VISIBLE : View.GONE); mConversationView.setVisibility(is_reply ? View.VISIBLE : View.GONE); if (is_reply) { mInReplyToView.setText(getString(R.string.in_reply_to, status.in_reply_to_screen_name)); Display display = getActivity().getWindowManager().getDefaultDisplay(); int width = display.getWidth(); // deprecated int height = display.getHeight(); // deprecated int heightOfConversation = (height / 2) - 48 - 44; ViewGroup.LayoutParams params = mConversationView.getLayoutParams(); params.height = heightOfConversation; mConversationView.setLayoutParams(params); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = null; ft = fragmentManager.beginTransaction(); final Fragment fragment = new ConversationFragment(); final Bundle args = new Bundle(); args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); args.putLong(INTENT_KEY_STATUS_ID, status.in_reply_to_status_id); fragment.setArguments(args); ft.replace(R.id.conversation, fragment, getString(R.string.view_conversation)); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } if (status.play_package != null) { mMarketView.setVisibility(View.VISIBLE); mPlayInfoTask = new PlayStoreInfoTask(); mPlayInfoTask.execute(); } else { mMarketView.setVisibility(View.GONE); } final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image); final String preview_image = hires_profile_image ? getBiggerTwitterProfileImage(status.profile_image_url_string) : status.profile_image_url_string; mLazyImageLoader.displayProfileImage(mProfileImageView, preview_image); final List<ImageSpec> images = getImagesInStatus(status.text_html); mImagesPreviewContainer.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE); mImagesPreviewFragment.addAll(images); mImagesPreviewFragment.update(); if (mLoadMoreAutomatically == true) { mImagesPreviewFragment.show(); } mRetweetedStatusView.setVisibility(status.is_protected ? View.GONE : View.VISIBLE); if (status.retweet_id > 0) { final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String retweeted_by = display_name ? status.retweeted_by_name : status.retweeted_by_screen_name; mRetweetedStatusView.setText(status.retweet_count > 1 ? getString(R.string.retweeted_by_with_count, retweeted_by, status.retweet_count - 1) : getString(R.string.retweeted_by, retweeted_by)); mRetweetedStatusView.setVisibility(View.VISIBLE); } else { mRetweetedStatusView.setVisibility(View.GONE); mRetweetedStatusView.setText(R.string.users_retweeted_this); } mLocationView.setVisibility(ParcelableLocation.isValidLocation(status.location) ? View.VISIBLE : View.GONE); if (mLoadMoreAutomatically) { showFollowInfo(true); showLocationInfo(true); } else { mFollowIndicator.setVisibility(View.GONE); } }
From source file:com.bonsai.wallet32.SendBitcoinActivity.java
private DialogFragment showFeeAdjustDialog(String msg, int acctId, String acctStr, String addrStr, long amount, long fee, double rate) { DialogFragment df = new FeeAdjustDialogFragment(); Bundle args = new Bundle(); args.putString("msg", msg); args.putInt("acctId", acctId); args.putString("acctStr", acctStr); args.putString("addr", addrStr); args.putLong("amount", amount); args.putLong("fee", fee); args.putDouble("rate", rate); df.setArguments(args);// www. j ava 2 s .c o m df.show(getSupportFragmentManager(), "sendconfirm"); return df; }
From source file:com.facebook.AuthorizationClient.java
private void logWebLoginCompleted(String applicationId, String e2e) { AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context, applicationId); Bundle parameters = new Bundle(); parameters.putString(AnalyticsEvents.PARAMETER_WEB_LOGIN_E2E, e2e); parameters.putLong(AnalyticsEvents.PARAMETER_WEB_LOGIN_SWITCHBACK_TIME, System.currentTimeMillis()); parameters.putString(AnalyticsEvents.PARAMETER_APP_ID, applicationId); appEventsLogger.logSdkEvent(AnalyticsEvents.EVENT_WEB_LOGIN_COMPLETE, null, parameters); }
From source file:com.morlunk.mumbleclient.app.PlumbleActivity.java
/** * Loads a fragment from the drawer./*from w w w . j av a2 s.c o m*/ */ private void loadDrawerFragment(int fragmentId) { Class<? extends Fragment> fragmentClass = null; Bundle args = new Bundle(); switch (fragmentId) { case DrawerAdapter.ITEM_SERVER: fragmentClass = ChannelFragment.class; break; case DrawerAdapter.ITEM_INFO: fragmentClass = ServerInfoFragment.class; break; case DrawerAdapter.ITEM_ACCESS_TOKENS: fragmentClass = AccessTokenFragment.class; args.putLong("server", mService.getConnectedServer().getId()); args.putStringArrayList("access_tokens", (ArrayList<String>) mDatabase.getAccessTokens(mService.getConnectedServer().getId())); break; case DrawerAdapter.ITEM_PINNED_CHANNELS: fragmentClass = ChannelFragment.class; args.putBoolean("pinned", true); break; case DrawerAdapter.ITEM_FAVOURITES: fragmentClass = FavouriteServerListFragment.class; break; case DrawerAdapter.ITEM_PUBLIC: fragmentClass = PublicServerListFragment.class; break; case DrawerAdapter.ITEM_SETTINGS: Intent prefIntent = new Intent(this, Preferences.class); startActivity(prefIntent); return; default: return; } Fragment fragment = Fragment.instantiate(this, fragmentClass.getName(), args); getSupportFragmentManager().beginTransaction() .replace(R.id.content_frame, fragment, fragmentClass.getName()) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit(); setTitle(mDrawerAdapter.getItemWithId(fragmentId).title); }
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@SuppressLint({ "NewApi", "NewApi", "NewApi" }) @Override/* www. j ava 2 s . co m*/ public boolean onMenuItemClick(final MenuItem item) { if (mStatus == null) return false; final String text_plain = mStatus.text_plain; final String screen_name = mStatus.screen_name; final String name = mStatus.name; switch (item.getItemId()) { case MENU_SHARE: { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, "@" + mStatus.screen_name + ": " + text_plain); startActivity(Intent.createChooser(intent, getString(R.string.share))); break; } case MENU_RETWEET: { if (isMyRetweet(mStatus)) { mService.destroyStatus(mAccountId, mStatus.retweet_id); } else { final long id_to_retweet = mStatus.is_retweet && mStatus.retweet_id > 0 ? mStatus.retweet_id : mStatus.status_id; mService.retweetStatus(mAccountId, id_to_retweet); } break; } case MENU_TRANSLATE: { translate(mStatus); break; } case MENU_QUOTE_REPLY: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, mStatusId); bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name); bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name); bundle.putBoolean(INTENT_KEY_IS_QUOTE, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_QUOTE: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putBoolean(INTENT_KEY_IS_QUOTE, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_ADD_TO_BUFFER: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putBoolean(INTENT_KEY_IS_BUFFER, true); bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), screen_name, text_plain)); intent.putExtras(bundle); startActivity(intent); break; } case MENU_REPLY: { final Intent intent = new Intent(INTENT_ACTION_COMPOSE); final Bundle bundle = new Bundle(); final List<String> mentions = new Extractor().extractMentionedScreennames(text_plain); mentions.remove(screen_name); mentions.add(0, screen_name); bundle.putStringArray(INTENT_KEY_MENTIONS, mentions.toArray(new String[mentions.size()])); bundle.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, mStatusId); bundle.putString(INTENT_KEY_IN_REPLY_TO_TWEET, text_plain); bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, screen_name); bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, name); intent.putExtras(bundle); startActivity(intent); break; } case MENU_FAV: { if (mStatus.is_favorite) { mService.destroyFavorite(mAccountId, mStatusId); } else { mService.createFavorite(mAccountId, mStatusId); } break; } case MENU_COPY_CLIPBOARD: { final String textToCopy = "@" + mStatus.screen_name + ": " + mStatus.text_plain; int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); clipboard.setText(textToCopy); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService( Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("Status", textToCopy); clipboard.setPrimaryClip(clip); } Toast.makeText(getActivity(), R.string.text_copied, Toast.LENGTH_SHORT).show(); break; } case MENU_DELETE: { mService.destroyStatus(mAccountId, mStatusId); break; } case MENU_EXTENSIONS: { final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_STATUS); final Bundle extras = new Bundle(); extras.putParcelable(INTENT_KEY_STATUS, mStatus); intent.putExtras(extras); startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions))); break; } case MENU_MUTE_SOURCE: { final String source = HtmlEscapeHelper.unescape(mStatus.source); if (source == null) return false; final Uri uri = Filters.Sources.CONTENT_URI; final ContentValues values = new ContentValues(); final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).edit(); final ContentResolver resolver = getContentResolver(); values.put(Filters.TEXT, source); resolver.delete(uri, Filters.TEXT + " = '" + source + "'", null); resolver.insert(uri, values); editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit(); Toast.makeText(getActivity(), getString(R.string.source_muted, source), Toast.LENGTH_SHORT).show(); break; } case MENU_SET_COLOR: { final Intent intent = new Intent(INTENT_ACTION_SET_COLOR); startActivityForResult(intent, REQUEST_SET_COLOR); break; } case MENU_CLEAR_COLOR: { clearUserColor(getActivity(), mStatus.user_id); updateUserColor(); break; } case MENU_RECENT_TWEETS: { openUserTimeline(getActivity(), mAccountId, mStatus.user_id, mStatus.screen_name); break; } case MENU_FIND_RETWEETS: { openUserRetweetedStatus(getActivity(), mStatus.account_id, mStatus.retweet_id > 0 ? mStatus.retweet_id : mStatus.status_id); break; } default: return false; } return super.onOptionsItemSelected(item); }
From source file:com.handpoint.headstart.client.ui.MainActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(CURRENT_PAGE, this.mPager.getCurrentItem()); if (null != mOriginalId) { outState.putLong(VOIDED_ID, mOriginalId); }// w ww . j a va 2s .c o m if (null != mDeferredTransaction) { outState.putParcelable(DEFERRED_TRANSACTION, new ParcelDeferredTransaction(mDeferredTransaction)); } if (isActivationDialogShowed) { outState.putBoolean(ACTIVATION_DIALOG_SHOWED, true); } }
From source file:com.cerema.cloud2.ui.activity.FileActivity.java
/** * {@inheritDoc}/* w w w . jav a2 s .c om*/ */ @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(FileActivity.EXTRA_FILE, mFile); outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification); outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor()); if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) { // Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST // since it doesn't have a title then outState.putString(KEY_ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString()); } }