Example usage for android.app ActivityOptions toBundle

List of usage examples for android.app ActivityOptions toBundle

Introduction

In this page you can find the example usage for android.app ActivityOptions toBundle.

Prototype

public Bundle toBundle() 

Source Link

Document

Returns the created options as a Bundle, which can be passed to android.content.Context#startActivity(android.content.Intent,android.os.Bundle) Context.startActivity(Intent, Bundle) and related methods.

Usage

From source file:com.mklodoss.SexyGirl.displayingbitmaps.ui.ImageGridFragment.java

@TargetApi(VERSION_CODES.JELLY_BEAN)
@Override//from  w w w.  j av  a  2 s  .c o  m
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    final Intent i = new Intent(getActivity(), ImageDetailActivity.class);
    i.putExtra(ImageDetailActivity.EXTRA_IMAGE, (int) id);
    i.putExtra(ImageDetailActivity.EXTRA_CATEGORY, category);
    if (Utils.hasJellyBean()) {
        // makeThumbnailScaleUpAnimation() looks kind of ugly here as the loading spinner may
        // show plus the thumbnail image in GridView is cropped. so using
        // makeScaleUpAnimation() instead.
        ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight());
        getActivity().startActivity(i, options.toBundle());
    } else {
        startActivity(i);
    }
}

From source file:com.fastbootmobile.encore.app.fragments.SearchFragment.java

private void onArtistClick(int i, View v) {
    if (mAdapter.getChildrenCount(SearchAdapter.ARTIST) > 1) {
        SearchAdapter.SearchEntry entry = mAdapter.getChild(SearchAdapter.ARTIST, i);

        if (entry.ref.equals(KEY_SPECIAL_MORE)) {
            mAdapter.setGroupMaxCount(SearchAdapter.ARTIST,
                    mAdapter.getGroupMaxCount(SearchAdapter.ARTIST) + 5);
        } else {//from   w  w w  .j  a v  a  2s . c om
            SearchAdapter.ViewHolder holder = (SearchAdapter.ViewHolder) v.getTag();
            ImageView ivCover = holder.albumArtImageView;
            Bitmap hero = ((MaterialTransitionDrawable) ivCover.getDrawable()).getFinalDrawable().getBitmap();
            int color = 0xffffff;
            if (hero != null) {
                Palette palette = Palette.generate(hero);
                Palette.Swatch darkVibrantColor = palette.getDarkVibrantSwatch();
                Palette.Swatch darkMutedColor = palette.getDarkMutedSwatch();

                if (darkVibrantColor != null) {
                    color = darkVibrantColor.getRgb();
                } else if (darkMutedColor != null) {
                    color = darkMutedColor.getRgb();
                } else {
                    color = getResources().getColor(R.color.default_album_art_background);
                }
            }
            Intent intent = new Intent(getActivity(), ArtistActivity.class);
            intent.putExtra(ArtistActivity.EXTRA_ARTIST, entry.ref);
            intent.putExtra(ArtistActivity.EXTRA_BACKGROUND_COLOR, color);
            Utils.queueBitmap(ArtistActivity.BITMAP_ARTIST_HERO, hero);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation(getActivity(), ivCover,
                        "itemImage");
                getActivity().startActivity(intent, opt.toBundle());
            } else {
                startActivity(intent);
            }
        }
    }
}

From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvShareFragment.java

private void showQrCodeDialog() {
    Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class);

    // create the transition animation - the images in the layouts
    // of both activities are defined with android:transitionName="qr_code"
    Bundle opts = null;/*from  w w  w  .  j a va2  s. c o  m*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getActivity(), mQrCodeLayout,
                "qr_code");
        opts = options.toBundle();
    }

    qrCodeIntent.setData(mDataUri);
    ActivityCompat.startActivity(getActivity(), qrCodeIntent, opts);
}

From source file:us.phyxsi.gameshelf.ui.HomeActivity.java

@OnClick(R.id.fab)
protected void fabClick() {
    Intent intent = new Intent(this, AddNewBoardgame.class);
    intent.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR,
            ContextCompat.getColor(this, R.color.accent));
    intent.putExtra(NewBoardgameService.EXTRA_BOARDGAME_RESULT, true);
    //        registerPostStoryResultListener();
    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, fab,
            getString(R.string.transition_add_new_boardgame));
    startActivityForResult(intent, RC_ADD_NEW_BOARDGAME, options.toBundle());
}

From source file:com.fastbootmobile.encore.app.fragments.SearchFragment.java

private void onAlbumClick(int i, View v) {
    if (mAdapter.getChildrenCount(SearchAdapter.ALBUM) > 1) {
        SearchAdapter.SearchEntry entry = mAdapter.getChild(SearchAdapter.ALBUM, i);

        if (entry.ref.equals(KEY_SPECIAL_MORE)) {
            mAdapter.setGroupMaxCount(SearchAdapter.ALBUM, mAdapter.getGroupMaxCount(SearchAdapter.ALBUM) + 5);
        } else {//from www  .  j a  v  a2  s  . co  m
            SearchAdapter.ViewHolder holder = (SearchAdapter.ViewHolder) v.getTag();
            Bitmap hero = ((MaterialTransitionDrawable) holder.albumArtImageView.getDrawable())
                    .getFinalDrawable().getBitmap();
            int color = 0xffffff;
            if (hero != null) {
                Palette palette = Palette.generate(hero);
                Palette.Swatch darkVibrantColor = palette.getDarkVibrantSwatch();
                Palette.Swatch darkMutedColor = palette.getDarkMutedSwatch();

                if (darkVibrantColor != null) {
                    color = darkVibrantColor.getRgb();
                } else if (darkMutedColor != null) {
                    color = darkMutedColor.getRgb();
                } else {
                    color = getResources().getColor(R.color.default_album_art_background);
                }
            }

            Intent intent = AlbumActivity.craftIntent(getActivity(), hero, entry.ref, entry.identifier, color);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ImageView ivCover = holder.albumArtImageView;
                ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation(getActivity(),
                        new Pair<View, String>(ivCover, "itemImage"));
                getActivity().startActivity(intent, opt.toBundle());
            } else {
                startActivity(intent);
            }
        }
    }
}

From source file:io.plaidapp.ui.PlayerActivity.java

@OnClick(R.id.follow)
void follow() {/*from  w ww  .j a v a 2 s  .  c o m*/
    if (DribbblePrefs.get(this).isLoggedIn()) {
        if (following != null && following) {
            final Call<Void> unfollowCall = dataManager.getDribbbleApi().unfollow(player.id);
            unfollowCall.enqueue(new Callback<Void>() {
                @Override
                public void onResponse(Call<Void> call, Response<Void> response) {
                }

                @Override
                public void onFailure(Call<Void> call, Throwable t) {
                }
            });
            following = false;
            TransitionManager.beginDelayedTransition(container);
            follow.setText(R.string.follow);
            follow.setActivated(false);
            setFollowerCount(followerCount - 1);
        } else {
            final Call<Void> followCall = dataManager.getDribbbleApi().follow(player.id);
            followCall.enqueue(new Callback<Void>() {
                @Override
                public void onResponse(Call<Void> call, Response<Void> response) {
                }

                @Override
                public void onFailure(Call<Void> call, Throwable t) {
                }
            });
            following = true;
            TransitionManager.beginDelayedTransition(container);
            follow.setText(R.string.following);
            follow.setActivated(true);
            setFollowerCount(followerCount + 1);
        }
    } else {
        Intent login = new Intent(this, DribbbleLogin.class);
        MorphTransform.addExtras(login, ContextCompat.getColor(this, R.color.dribbble),
                getResources().getDimensionPixelSize(R.dimen.dialog_corners));
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, follow,
                getString(R.string.transition_dribbble_login));
        startActivity(login, options.toBundle());
    }
}

From source file:com.antew.redditinpictures.library.ui.RedditImageAdapterViewFragment.java

/**
 * Callback method to be invoked when an item in this AdapterView has
 * been clicked./*from ww  w  .  j  a v a  2s .c om*/
 * <p/>
 * Implementers can call getItemAtPosition(position) if they need
 * to access the data associated with the selected item.
 *
 * @param parent
 *     The AdapterView where the click happened.
 * @param view
 *     The view within the AdapterView that was clicked (this
 *     will be a view provided by the adapter)
 * @param position
 *     The position of the view in the adapter.
 * @param id
 *     The row id of the item that was clicked.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    EasyTracker.getInstance(getActivity()).send(MapBuilder.createEvent(Constants.Analytics.Category.UI_ACTION,
            Constants.Analytics.Action.OPEN_POST, mCurrentSubreddit, null).build());
    final Intent i = new Intent(getActivity(), getImageDetailActivityClass());
    Bundle b = new Bundle();
    b.putString(Constants.Extra.EXTRA_SUBREDDIT, mCurrentSubreddit);
    b.putString(Constants.Extra.EXTRA_CATEGORY, mCategory.name());
    b.putString(Constants.Extra.EXTRA_AGE, mAge.name());
    i.putExtra(Constants.Extra.EXTRA_IMAGE, position);
    i.putExtras(b);

    if (AndroidUtil.hasJellyBean()) {
        ActivityOptions options = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(),
                view.getHeight());
        getActivity().startActivity(i, options.toBundle());
    } else {
        startActivity(i);
    }
}

From source file:com.fbbackup.TagMeImageGridFragment.java

@TargetApi(16)
@Override//  w w  w  . ja  v  a 2  s  . com
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    final Intent i = new Intent(getActivity(), TagImageDetailActivity.class);

    Bundle bundle = new Bundle();

    bundle.putStringArray("photo", tagMePicture);

    bundle.putString("userName", name);

    i.putExtras(bundle);

    i.putExtra(ImageDetailActivity.EXTRA_IMAGE, (int) id);
    if (Utils.hasJellyBean()) {
        // makeThumbnailScaleUpAnimation() looks kind of ugly here as the
        // loading spinner may
        // show plus the thumbnail image in GridView is cropped. so using
        // makeScaleUpAnimation() instead.
        ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight());
        getActivity().startActivity(i, options.toBundle());
    } else {
        startActivity(i);
    }
}

From source file:com.fastbootmobile.encore.app.adapters.PlaylistListAdapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final int itemViewType = getItemViewType(position);

    if (itemViewType == VIEW_TYPE_HEADER) {
        SpecialViewHolder specialHolder = (SpecialViewHolder) holder;
        specialHolder.cardFavorites.setOnClickListener(new View.OnClickListener() {
            @Override// w  w w. j ava  2s. c  o m
            public void onClick(View v) {
                Context ctx = v.getContext();
                Intent intent = PlaylistActivity.craftIntent(ctx, AutoPlaylistHelper.REF_SPECIAL_FAVORITES,
                        null);
                ctx.startActivity(intent);
            }
        });

        specialHolder.cardMostPlayed.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Context ctx = v.getContext();
                Intent intent = PlaylistActivity.craftIntent(ctx, AutoPlaylistHelper.REF_SPECIAL_MOST_PLAYED,
                        null);
                ctx.startActivity(intent);
            }
        });
    } else if (itemViewType == VIEW_TYPE_REGULAR) {
        final Playlist item = mPlaylists.get(position - 1);
        holder.tvPlaylistName.setText(item.getName());
        holder.ivCover.loadArtForPlaylist(item);

        if (item.isLoaded() || item.getSongsCount() > 0) {
            ProviderConnection provider = PluginsLookup.getDefault().getProvider(item.getProvider());
            if (provider != null) {
                holder.tvPlaylistDesc
                        .setText(String.format("%s / %s",
                                holder.tvPlaylistDesc.getContext().getResources().getQuantityString(
                                        R.plurals.xx_songs, item.getSongsCount(), item.getSongsCount()),
                                provider.getProviderName()));
            }

            holder.ivOfflineStatus.setVisibility(View.VISIBLE);

            switch (item.getOfflineStatus()) {
            case BoundEntity.OFFLINE_STATUS_NO:
                holder.ivOfflineStatus.setVisibility(View.GONE);
                break;

            case BoundEntity.OFFLINE_STATUS_DOWNLOADING:
                holder.ivOfflineStatus.setImageResource(R.drawable.ic_sync_in_progress);
                break;

            case BoundEntity.OFFLINE_STATUS_ERROR:
                holder.ivOfflineStatus.setImageResource(R.drawable.ic_sync_problem);
                break;

            case BoundEntity.OFFLINE_STATUS_PENDING:
                holder.ivOfflineStatus.setImageResource(R.drawable.ic_track_download_pending);
                break;

            case BoundEntity.OFFLINE_STATUS_READY:
                holder.ivOfflineStatus.setImageResource(R.drawable.ic_track_downloaded);
                break;
            }
        } else {
            holder.tvPlaylistDesc.setText(null);
            holder.ivOfflineStatus.setVisibility(View.GONE);
        }

        final int dragState = holder.getDragStateFlags();

        if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0)) {
            int bgColor = 0;

            if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) {
                bgColor = 0xFFDDDDDD;
            } else if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) {
                bgColor = 0xFFAAAAAA;
            }

            if (bgColor != 0) {
                holder.container.setBackgroundColor(bgColor);
            } else {
                int[] attrs = new int[] { android.R.attr.selectableItemBackground /* index 0 */ };
                TypedArray ta = holder.container.getContext().obtainStyledAttributes(attrs);
                Drawable drawableFromTheme = ta.getDrawable(0 /* index */);
                ta.recycle();
                holder.container.setBackground(drawableFromTheme);
            }
        }

        holder.container.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Context ctx = v.getContext();
                Intent intent = PlaylistActivity.craftIntent(ctx, item,
                        ((MaterialTransitionDrawable) holder.ivCover.getDrawable()).getFinalDrawable()
                                .getBitmap());

                if (Utils.hasLollipop()) {
                    ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation((Activity) ctx,
                            holder.ivCover, "itemImage");
                    ctx.startActivity(intent, opt.toBundle());
                } else {
                    ctx.startActivity(intent);
                }
            }
        });
    }
}

From source file:com.fbbackup.ImageGridFragment.java

@TargetApi(16)
@Override//  w  ww  .j ava2 s. c o m
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    final Intent i = new Intent(getActivity(), ImageDetailActivity.class);

    Bundle bundle = new Bundle();

    bundle.putStringArray("photo", photoArray);

    bundle.putInt("albumPosition", position);

    bundle.putString("albumName", albumName);

    bundle.putString("userName", name);

    i.putExtras(bundle);

    i.putExtra(ImageDetailActivity.EXTRA_IMAGE, (int) id);
    if (Utils.hasJellyBean()) {
        // makeThumbnailScaleUpAnimation() looks kind of ugly here as the
        // loading spinner may
        // show plus the thumbnail image in GridView is cropped. so using
        // makeScaleUpAnimation() instead.
        ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight());
        getActivity().startActivity(i, options.toBundle());
    } else {
        startActivity(i);
    }
}