Example usage for android.content Intent setExtrasClassLoader

List of usage examples for android.content Intent setExtrasClassLoader

Introduction

In this page you can find the example usage for android.content Intent setExtrasClassLoader.

Prototype

public void setExtrasClassLoader(@Nullable ClassLoader loader) 

Source Link

Document

Sets the ClassLoader that will be used when unmarshalling any Parcelable values from the extras of this Intent.

Usage

From source file:de.vanita5.twittnuker.activity.support.MediaViewerActivity.java

public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SAVE: {
        if (mImageFile != null) {
            new SaveImageTask(this, mImageFile).execute();
        }/*from  w w w  . j  a  v  a  2  s  . c  o m*/
        break;
    }
    case MENU_OPEN_IN_BROWSER: {
        final Intent intent = getIntent();
        intent.setExtrasClassLoader(getClassLoader());
        final Uri uri = intent.getData();
        final Uri orig = intent.getParcelableExtra(EXTRA_URI_ORIG);
        final Uri uriPreferred = orig != null ? orig : uri;
        if (uriPreferred == null)
            return false;
        final String scheme = uriPreferred.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            final Intent open_intent = new Intent(Intent.ACTION_VIEW, uriPreferred);
            open_intent.addCategory(Intent.CATEGORY_BROWSABLE);
            try {
                startActivity(open_intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
        }
        break;
    }
    default: {
        final Intent intent = item.getIntent();
        if (intent != null) {
            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
            return true;
        }
        return false;
    }
    }
    return true;
}

From source file:de.vanita5.twittnuker.activity.support.UserListSelectorActivity.java

@Override
public void onItemClick(final AdapterView<?> view, final View child, final int position, final long id) {
    final int view_id = view.getId();
    final ListView list = (ListView) view;
    if (view_id == R.id.users_list) {
        final ParcelableUser user = mUsersAdapter.getItem(position - list.getHeaderViewsCount());
        if (user == null)
            return;
        if (isSelectingUser()) {
            final Intent data = new Intent();
            data.setExtrasClassLoader(getClassLoader());
            data.putExtra(EXTRA_USER, user);
            setResult(RESULT_OK, data);//  w ww .  j  a  v a 2 s .com
            finish();
        } else {
            getUserLists(user.screen_name);
        }
    } else if (view_id == R.id.user_lists_list) {
        final Intent data = new Intent();
        data.putExtra(EXTRA_USER_LIST, mUserListsAdapter.getItem(position - list.getHeaderViewsCount()));
        setResult(RESULT_OK, data);
        finish();
    }
}

From source file:de.vanita5.twittnuker.activity.support.LinkHandlerActivity.java

private boolean showFragment(final Uri uri) {
    final Intent intent = getIntent();
    intent.setExtrasClassLoader(getClassLoader());
    final Fragment fragment = createFragmentForIntent(this, intent);
    if (uri == null || fragment == null)
        return false;
    switch (matchLinkId(uri)) {
    case LINK_ID_STATUS: {
        setTitle(R.string.status);/* w ww  .  j  a  v  a2s  .com*/
        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.action_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_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;
    }
    default: {
        return false;
    }
    }
    mFinishOnly = Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY));
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(android.R.id.content, fragment);
    ft.commit();
    return true;
}

From source file:org.mariotaku.twidere.util.OnLinkClickHandler.java

protected void openTwitterLink(final String link, final UserKey accountKey) {
    if (manager != null && manager.isActive())
        return;//from  w  ww.  ja v  a 2s. c  o  m
    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClass(context, WebLinkHandlerActivity.class);
    intent.putExtra(EXTRA_ACCOUNT_KEY, accountKey);
    intent.setExtrasClassLoader(TwidereApplication.class.getClassLoader());
    try {
        context.startActivity(intent);
    } catch (final ActivityNotFoundException e) {
        // TODO
    }
}

From source file:com.umeng.comm.ui.imagepicker.adapters.viewholders.ReceivedCommentViewHolder.java

private void startReplyCommentActivity(FeedItem feedItem) {
    if (feedItem.status >= FeedItem.STATUS_SPAM && feedItem.status != FeedItem.STATUS_LOCK) {
        ToastMsg.showShortMsgByResName("umeng_comm_invalid_feed");
        return;/*from w  w w. ja v  a 2  s .  co  m*/
    }
    if (mFeedDetailClassName != null) {
        Intent intent = new Intent(mContext, mFeedDetailClassName);
        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);
        //            Intent intent = new Intent(getActivity(), FeedDetailActivity.class);
        //            intent.putExtra(Constants.TAG_FEED, feedItem);
        intent.putExtra(Constants.TAG_IS_COMMENT, true);
        intent.putExtra(Constants.TAG_IS_SCROLL, true);
        mContext.startActivity(intent);
    }
}

From source file:org.getlantern.firetweet.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;
    switch (linkId) {
    case LINK_ID_STATUS: {
        setTitle(R.string.status);/*from   ww  w  .j  a  v a 2 s. c  o m*/
        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;
    }
    }
    mFinishOnly = Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY));
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.main_content, fragment);
    ft.commit();
    return true;
}

From source file:syncthing.android.ui.LauncherActivity.java

void setupNavigation(Bundle savedInstanceState) {
    mNavigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override//from w  ww . jav a2s .co m
        public boolean onNavigationItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.manage_devices:
                closeDrawers();
                startDeviceManageActivity();
                return true;
            case R.id.app_settings:
                closeDrawers();
                startSettingsActivity();
                return true;
            default:
                break;
            }
            Intent intent = item.getIntent();
            if (intent != null && intent.hasExtra(ManageActivity.EXTRA_CREDENTIALS)) {
                clearCheckedMenuItems();
                item.setChecked(true);
                closeDrawers();

                intent.setExtrasClassLoader(LauncherActivity.class.getClassLoader());
                Credentials credentials = intent.getParcelableExtra(ManageActivity.EXTRA_CREDENTIALS);
                openSession(credentials);
                return true;
            }
            return false;
        }
    });
    Credentials current = mSettings.getDefaultCredentials();
    populateNavigationMenu(current, savedInstanceState == null);
}

From source file:org.mariotaku.twidere.fragment.UserListFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    final ParcelableUserList userList = mUserList;
    MenuUtils.setMenuItemAvailability(menu, R.id.info, userList != null);
    menu.removeGroup(MENU_GROUP_USER_LIST_EXTENSION);
    if (userList != null) {
        final boolean isMyList = userList.user_key.equals(userList.account_key);
        final boolean isFollowing = userList.is_following;
        MenuUtils.setMenuItemAvailability(menu, R.id.edit, isMyList);
        MenuUtils.setMenuItemAvailability(menu, R.id.follow, !isMyList);
        MenuUtils.setMenuItemAvailability(menu, R.id.add, isMyList);
        MenuUtils.setMenuItemAvailability(menu, R.id.delete, isMyList);
        final MenuItem followItem = menu.findItem(R.id.follow);
        if (isFollowing) {
            followItem.setIcon(R.drawable.ic_action_cancel);
            followItem.setTitle(R.string.unsubscribe);
        } else {// w  w w  .  ja v  a 2 s  .c o m
            followItem.setIcon(R.drawable.ic_action_add);
            followItem.setTitle(R.string.subscribe);
        }
        final Intent extensionsIntent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST);
        extensionsIntent.setExtrasClassLoader(getActivity().getClassLoader());
        extensionsIntent.putExtra(EXTRA_USER_LIST, userList);
        MenuUtils.addIntentToMenu(getActivity(), menu, extensionsIntent, MENU_GROUP_USER_LIST_EXTENSION);
    } else {
        MenuUtils.setMenuItemAvailability(menu, R.id.edit, false);
        MenuUtils.setMenuItemAvailability(menu, R.id.follow, false);
        MenuUtils.setMenuItemAvailability(menu, R.id.add, false);
        MenuUtils.setMenuItemAvailability(menu, R.id.delete, false);
    }
}

From source file:org.mariotaku.gallery3d.ImageViewerGLActivity.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SAVE: {
        if (mImageFile != null) {
            new SaveImageTask(this, mImageFile).execute();
        }//from  w w  w.  jav  a 2 s  .  c om
        break;
    }
    case MENU_OPEN_IN_BROWSER: {
        final Intent intent = getIntent();
        intent.setExtrasClassLoader(getClassLoader());
        final Uri uri = intent.getData();
        final Uri orig = intent.getParcelableExtra(EXTRA_URI_ORIG);
        final Uri uriPreferred = orig != null ? orig : uri;
        if (uriPreferred == null)
            return false;
        final String scheme = uriPreferred.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            final Intent open_intent = new Intent(Intent.ACTION_VIEW, uriPreferred);
            open_intent.addCategory(Intent.CATEGORY_BROWSABLE);
            try {
                startActivity(open_intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
        }
        break;
    }
    default: {
        final Intent intent = item.getIntent();
        if (intent != null) {
            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
            return true;
        }
        return false;
    }
    }
    return true;
}

From source file:org.mariotaku.twidere.fragment.support.UserListFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    final ParcelableUserList userList = mUserList;
    setMenuItemAvailability(menu, MENU_INFO, userList != null);
    menu.removeGroup(MENU_GROUP_USER_LIST_EXTENSION);
    if (userList != null) {
        final boolean isMyList = userList.user_id == userList.account_id;
        final boolean isFollowing = userList.is_following;
        setMenuItemAvailability(menu, MENU_EDIT, isMyList);
        setMenuItemAvailability(menu, MENU_FOLLOW, !isMyList);
        setMenuItemAvailability(menu, MENU_ADD, isMyList);
        setMenuItemAvailability(menu, MENU_DELETE, isMyList);
        final MenuItem followItem = menu.findItem(MENU_FOLLOW);
        if (isFollowing) {
            followItem.setIcon(R.drawable.ic_action_cancel);
            followItem.setTitle(R.string.unsubscribe);
        } else {/*  w  ww .jav  a 2  s .c  o  m*/
            followItem.setIcon(R.drawable.ic_action_add);
            followItem.setTitle(R.string.subscribe);
        }
        final Intent extensionsIntent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER_LIST);
        extensionsIntent.setExtrasClassLoader(getActivity().getClassLoader());
        extensionsIntent.putExtra(EXTRA_USER_LIST, userList);
        addIntentToMenu(getActivity(), menu, extensionsIntent, MENU_GROUP_USER_LIST_EXTENSION);
    } else {
        setMenuItemAvailability(menu, MENU_EDIT, false);
        setMenuItemAvailability(menu, MENU_FOLLOW, false);
        setMenuItemAvailability(menu, MENU_ADD, false);
        setMenuItemAvailability(menu, MENU_DELETE, false);
    }
}