List of usage examples for android.content Intent setExtrasClassLoader
public void setExtrasClassLoader(@Nullable ClassLoader loader)
From source file:org.mariotaku.twidere.fragment.support.UserListDetailsFragment.java
@Override public void onClick(final View view) { switch (view.getId()) { case R.id.more_options: { if (mUserList == null) return; mPopupMenu = PopupMenu.getInstance(getActivity(), view); mPopupMenu.inflate(R.menu.action_user_list); final Menu menu = mPopupMenu.getMenu(); final Intent extensionsIntent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST); extensionsIntent.setExtrasClassLoader(getActivity().getClassLoader()); extensionsIntent.putExtra(EXTRA_USER_LIST, mUserList); addIntentToMenu(getActivity(), menu, extensionsIntent); mPopupMenu.setOnMenuItemClickListener(this); mPopupMenu.show();/*from ww w . j a v a 2 s. c o m*/ break; } case R.id.retry: { getUserListInfo(true); break; } case R.id.profile_image: { if (mUserList == null) return; openUserProfile(getActivity(), mUserList.account_id, mUserList.user_id, mUserList.user_screen_name); break; } } }
From source file:org.mariotaku.twidere.activity.support.LinkHandlerActivity.java
private boolean showFragment(final int linkId, final Uri uri) { final Intent intent = getIntent(); intent.setExtrasClassLoader(getClassLoader()); final Fragment fragment = createFragmentForIntent(this, linkId, intent); if (uri == null || fragment == null) return false; setSubtitle(null);/*from www.ja v a2s. com*/ switch (linkId) { case LINK_ID_STATUS: { setTitle(R.string.status); break; } case LINK_ID_USER: { setTitle(R.string.user); break; } case LINK_ID_USER_TIMELINE: { setTitle(R.string.statuses); break; } case LINK_ID_USER_FAVORITES: { setTitle(R.string.favorites); break; } case LINK_ID_USER_FOLLOWERS: { setTitle(R.string.followers); break; } case LINK_ID_USER_FRIENDS: { setTitle(R.string.following); break; } case LINK_ID_USER_BLOCKS: { setTitle(R.string.blocked_users); break; } case LINK_ID_MUTES_USERS: { setTitle(R.string.twitter_muted_users); break; } case LINK_ID_DIRECT_MESSAGES_CONVERSATION: { setTitle(R.string.direct_messages); break; } case LINK_ID_USER_LIST: { setTitle(R.string.user_list); break; } case LINK_ID_USER_LISTS: { setTitle(R.string.user_lists); break; } case LINK_ID_USER_LIST_TIMELINE: { setTitle(R.string.list_timeline); break; } case LINK_ID_USER_LIST_MEMBERS: { setTitle(R.string.list_members); break; } case LINK_ID_USER_LIST_SUBSCRIBERS: { setTitle(R.string.list_subscribers); break; } case LINK_ID_USER_LIST_MEMBERSHIPS: { setTitle(R.string.lists_following_user); break; } case LINK_ID_SAVED_SEARCHES: { setTitle(R.string.saved_searches); break; } case LINK_ID_USER_MENTIONS: { setTitle(R.string.user_mentions); break; } case LINK_ID_INCOMING_FRIENDSHIPS: { setTitle(R.string.incoming_friendships); break; } case LINK_ID_USERS: { setTitle(R.string.users); break; } case LINK_ID_STATUSES: { setTitle(R.string.statuses); break; } case LINK_ID_USER_MEDIA_TIMELINE: { setTitle(R.string.media); break; } case LINK_ID_STATUS_RETWEETERS: { setTitle(R.string.users_retweeted_this); break; } case LINK_ID_STATUS_FAVORITERS: { setTitle(R.string.users_retweeted_this); break; } case LINK_ID_STATUS_REPLIES: { setTitle(R.string.view_replies); break; } case LINK_ID_SEARCH: { setTitle(android.R.string.search_go); setSubtitle(uri.getQueryParameter(QUERY_PARAM_QUERY)); break; } case LINK_ID_ACCOUNTS: { setTitle(R.string.accounts); break; } case LINK_ID_DRAFTS: { setTitle(R.string.drafts); break; } case LINK_ID_FILTERS: { setTitle(R.string.filters); break; } case LINK_ID_MAP: { setTitle(R.string.view_map); break; } case LINK_ID_PROFILE_EDITOR: { setTitle(R.string.edit_profile); break; } default: { setTitle(getString(R.string.app_name)); break; } } mFinishOnly = Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY)); final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.content_fragment, fragment); ft.commit(); return true; }
From source file:org.getlantern.firetweet.fragment.support.UserListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { final AsyncTwitterWrapper twitter = getTwitterWrapper(); final ParcelableUserList userList = mUserList; final MenuItem followItem = menu.findItem(MENU_FOLLOW); if (followItem != null) { followItem.setEnabled(userList != null); if (userList == null) { followItem.setIcon(android.R.color.transparent); }/*from w ww . j a va2 s . c o m*/ } if (twitter == null || userList == null) return; final boolean isMyList = userList.user_id == userList.account_id; setMenuItemAvailability(menu, MENU_EDIT, isMyList); setMenuItemAvailability(menu, MENU_ADD, isMyList); setMenuItemAvailability(menu, MENU_DELETE, isMyList); final boolean isFollowing = userList.is_following; if (followItem != null) { followItem.setVisible(!isMyList); if (isFollowing) { followItem.setIcon(R.drawable.ic_action_cancel); followItem.setTitle(R.string.unsubscribe); } else { followItem.setIcon(R.drawable.ic_action_add); followItem.setTitle(R.string.subscribe); } } menu.removeGroup(MENU_GROUP_USER_LIST_EXTENSION); final Intent extensionsIntent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST); extensionsIntent.setExtrasClassLoader(getActivity().getClassLoader()); extensionsIntent.putExtra(EXTRA_USER_LIST, mUserList); addIntentToMenu(getActivity(), menu, extensionsIntent, MENU_GROUP_USER_LIST_EXTENSION); }
From source file:syncthing.android.ui.LauncherActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Timber.d("onActivityResult(%d, %d, %s)", requestCode, resultCode, data); final Handler handler = new Handler(); switch (requestCode) { case ActivityRequestCodes.LOGIN_ACTIVITY: case ActivityRequestCodes.MANAGE_ACTIVITY: case ActivityRequestCodes.WELCOME_ACTIVITY: { // OK with credentials opens the device if (resultCode == Activity.RESULT_OK && data != null && data.hasExtra(ManageActivity.EXTRA_CREDENTIALS)) { Timber.d("Got Positive response"); data.setExtrasClassLoader(LauncherActivity.class.getClassLoader()); final Credentials currentDevice = data.getParcelableExtra(ManageActivity.EXTRA_CREDENTIALS); if (currentDevice != null) { Timber.d("Found credentials in the intent"); handler.postDelayed(() -> populateNavigationMenu(currentDevice, true), 10); return; }/*from w w w. ja va 2 s . c o m*/ } Timber.d("Result either canceled or missing credentials"); //IDK just open the drawer handler.postDelayed(() -> { populateNavigationMenu(null, false); openDrawer(GravityCompat.START); }, 10); break; } default: Timber.d("Unknown request code"); super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:org.getlantern.firetweet.activity.support.HomeActivity.java
private int handleIntent(final Intent intent, final boolean firstCreate) { // use packge's class loader to prevent BadParcelException intent.setExtrasClassLoader(getClassLoader()); // reset intent setIntent(new Intent(this, HomeActivity.class)); final String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action)) { final String query = intent.getStringExtra(SearchManager.QUERY); final Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA); final long accountId; if (appSearchData != null && appSearchData.containsKey(EXTRA_ACCOUNT_ID)) { accountId = appSearchData.getLong(EXTRA_ACCOUNT_ID, -1); } else {/*from ww w. j av a 2 s . co m*/ accountId = getDefaultAccountId(this); } openSearch(this, accountId, query); return -1; } final boolean refreshOnStart = mPreferences.getBoolean(KEY_REFRESH_ON_START, false); final long[] refreshedIds = intent.getLongArrayExtra(EXTRA_REFRESH_IDS); if (refreshedIds != null) { mTwitterWrapper.refreshAll(refreshedIds); } else if (firstCreate && refreshOnStart) { mTwitterWrapper.refreshAll(); } final Uri uri = intent.getData(); final String tabType = uri != null ? Utils.matchTabType(uri) : null; int initialTab = -1; if (tabType != null) { final long accountId = ParseUtils.parseLong(uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID)); for (int i = mPagerAdapter.getCount() - 1; i > -1; i--) { final SupportTabSpec tab = mPagerAdapter.getTab(i); if (tabType.equals(tab.type)) { initialTab = i; if (hasAccountId(tab.args, accountId)) { break; } } } } if (initialTab != -1 && mViewPager != null) { // clearNotification(initial_tab); } final Intent extraIntent = intent.getParcelableExtra(EXTRA_EXTRA_INTENT); if (extraIntent != null && firstCreate) { extraIntent.setExtrasClassLoader(getClassLoader()); startActivity(extraIntent); } return initialTab; }
From source file:com.nbplus.iotapp.bluetooth.BluetoothLeService.java
/** * modified 2015.11.03//from w ww . j a v a2 s . c o m * @param action * @param data */ private void broadcastUpdate(final String action, IoTHandleData data) { final Intent intent = new Intent(action); intent.setExtrasClassLoader(IoTHandleData.class.getClassLoader()); intent.putExtra(IoTServiceCommand.KEY_DATA, data); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
From source file:de.vanita5.twittnuker.activity.support.HomeActivity.java
private int handleIntent(final Intent intent, final boolean firstCreate) { // use packge's class loader to prevent BadParcelException intent.setExtrasClassLoader(getClassLoader()); // reset intent setIntent(new Intent(this, HomeActivity.class)); final String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action)) { final String query = intent.getStringExtra(SearchManager.QUERY); final Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA); final long accountId; if (appSearchData != null && appSearchData.containsKey(EXTRA_ACCOUNT_ID)) { accountId = appSearchData.getLong(EXTRA_ACCOUNT_ID, -1); } else {/*w w w . j av a 2 s. c o m*/ accountId = getDefaultAccountId(this); } openSearch(this, accountId, query); return -1; } final boolean refreshOnStart = mPreferences.getBoolean(KEY_REFRESH_ON_START, false); final long[] refreshedIds = intent.getLongArrayExtra(EXTRA_IDS); if (refreshedIds != null) { mTwitterWrapper.refreshAll(refreshedIds); } else if (firstCreate && refreshOnStart) { mTwitterWrapper.refreshAll(); } final int tab = intent.getIntExtra(EXTRA_INITIAL_TAB, -1); final int initialTab = tab != -1 ? tab : getAddedTabPosition(this, intent.getStringExtra(EXTRA_TAB_TYPE)); if (initialTab != -1 && mViewPager != null) { // clearNotification(initial_tab); } final Intent extraIntent = intent.getParcelableExtra(EXTRA_EXTRA_INTENT); if (extraIntent != null && firstCreate) { extraIntent.setExtrasClassLoader(getClassLoader()); SwipebackActivityUtils.startSwipebackActivity(this, extraIntent); } return initialTab; }
From source file:com.umeng.comm.ui.adapters.viewholders.ReceivedCommentViewHolder.java
/** * ??//from w w w . ja v a 2s.co m * * @param item ?feed item */ private void setForwardItemData(final FeedItem item, boolean canReplyComment) { // @feed // atOriginFeedCreator(item.sourceFeed); // 2feed? if ((item.sourceFeed.status >= FeedItem.STATUS_SPAM && item.status != FeedItem.STATUS_LOCK) || isDeleted(item.sourceFeed)) { // mForwardTextTv.setGravity(Gravity.CENTER); // mForwardTextTv.setText(ResFinder.getString("umeng_comm_feed_deleted")); // if (mImageGv != null) { // mImageGv.setVisibility(View.GONE); // } // TODO ?? // feed??feed?feed?feed? // if (item.status >= FeedItem.STATUS_SPAM && item.sourceFeed.status >= FeedItem.STATUS_SPAM && item.status != FeedItem.STATUS_LOCK) { // // mForwardLayout.setVisibility(View.GONE); // } else { // // ?feed // deleteInvalidateFeed(item.sourceFeed); // } mFeedInfoHolder.setVisibility(View.GONE); mFeedSimpleInfoHolder.setVisibility(View.VISIBLE); mFeedSimpleUserName.setVisibility(View.GONE); mFeedSimpleContent.setText(ResFinder.getString("umeng_comm_feed_deleted")); } else { // mForwardTextTv.setGravity(Gravity.LEFT | Gravity.CENTER); boolean hasImg = (mFeedItem.sourceFeed.imageUrls != null && !mFeedItem.sourceFeed.imageUrls.isEmpty()); // show sourceFeed creator name CommUser sourceFeedCreatorClone; if (mSourceFeedCreators.containsKey(mFeedItem.sourceFeed.creator.id)) { sourceFeedCreatorClone = mSourceFeedCreators.get(mFeedItem.sourceFeed.creator.id); } else { sourceFeedCreatorClone = new CommUser(); // @? final String atPrefix = "@"; sourceFeedCreatorClone.name = atPrefix + mFeedItem.sourceFeed.creator.name; mSourceFeedCreators.put(mFeedItem.sourceFeed.creator.id, sourceFeedCreatorClone); } if (hasImg) { mFeedInfoHolder.setVisibility(View.VISIBLE); mFeedSimpleInfoHolder.setVisibility(View.GONE); mFeedUserName.setText(sourceFeedCreatorClone.name); ImgDisplayOption option = ImgDisplayOption.getCommonDisplayOption(); ImageLoaderManager.getInstance().getCurrentSDK() .displayImage(mFeedItem.sourceFeed.getImages().get(0).thumbnail, mFeedImage, option); } else { mFeedInfoHolder.setVisibility(View.GONE); mFeedSimpleInfoHolder.setVisibility(View.VISIBLE); mFeedSimpleUserName.setVisibility(View.VISIBLE); mFeedSimpleUserName.setText(sourceFeedCreatorClone.name); } List<CommUser> list = new LinkedList<CommUser>(); list.add(sourceFeedCreatorClone); FeedViewRender.renderFriendText(mContext, hasImg ? mFeedUserName : mFeedSimpleUserName, list, new FrinendClickSpanListener() { @Override public void onClick(CommUser user) { Intent intent = new Intent(mContext, MyInformationActivity.class); intent.putExtra(Constants.TAG_USER, user); mContext.startActivity(intent); } }); // show sourceFeed ??@? FeedViewRender.parseTopicsAndFriends(hasImg ? mFeedContent : mFeedSimpleContent, item.sourceFeed, new TopicClickSpanListener() { @Override public void onClick(Topic topic) { Intent intent = new Intent(mContext, TopicDetailActivity.class); intent.putExtra(Constants.TAG_TOPIC, topic); mContext.startActivity(intent); } }, new FrinendClickSpanListener() { @Override public void onClick(CommUser user) { Intent intent = new Intent(mContext, MyInformationActivity.class); intent.putExtra(Constants.TAG_USER, user); mContext.startActivity(intent); } }); // if (mImageGv != null) { // mImageGv.setVisibility(View.VISIBLE); // } } if (canReplyComment) { mReplyCommentBtn.setVisibility(View.VISIBLE); mReplyCommentBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { FeedItem feedItem = item.sourceFeed; if (feedItem.status >= FeedItem.STATUS_SPAM && feedItem.status != FeedItem.STATUS_LOCK) { ToastMsg.showShortMsgByResName("umeng_comm_invalid_feed"); return; } Intent intent = new Intent(mContext, FeedDetailActivity.class); intent.setExtrasClassLoader(ImageItem.class.getClassLoader()); intent.putExtra(Constants.FEED, feedItem); String commentId = feedItem.extraData.getString(HttpProtocol.COMMENT_ID_KEY); // id intent.putExtra(HttpProtocol.COMMENT_ID_KEY, commentId); mContext.startActivity(intent); } }); } else { mReplyCommentBtn.setVisibility(View.GONE); } }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void openStatus(final Activity activity, final ParcelableStatus status) { if (activity == null || status == null) return;/*from w ww . ja v a 2 s .co m*/ final long account_id = status.account_id, status_id = status.id; final Bundle extras = new Bundle(); extras.putParcelable(EXTRA_STATUS, status); final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWITTNUKER); builder.authority(AUTHORITY_STATUS); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id)); builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id)); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.setExtrasClassLoader(activity.getClassLoader()); intent.putExtras(extras); SwipebackActivityUtils.startSwipebackActivity(activity, intent); }