Example usage for android.app ActivityOptions makeScaleUpAnimation

List of usage examples for android.app ActivityOptions makeScaleUpAnimation

Introduction

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

Prototype

public static ActivityOptions makeScaleUpAnimation(View source, int startX, int startY, int width, int height) 

Source Link

Document

Create an ActivityOptions specifying an animation where the new activity is scaled from a small originating area of the screen to its final full representation.

Usage

From source file:net.wespot.pim.controller.ImageGridFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    final Intent intent = new Intent(getActivity(), ImageDetailActivity.class);

    intent.putExtra(ImageDetailActivity.GENERAL_ITEM_ID, giLocalObject.getId());
    intent.putExtra(ImageDetailActivity.RESPONSE_POSITION, (int) position);

    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(intent, options.toBundle());
    } else {/*from  w ww.  j a va2  s. c  om*/
        startActivity(intent);
    }
}

From source file:net.wespot.pim.controller.ImageGridFragment.java

@Override
public void onListItemClick(View v, int position, ResponseLocalObject item) {
    final Intent intent = new Intent(getActivity(), ImageDetailActivity.class);

    intent.putExtra(ImageDetailActivity.GENERAL_ITEM_ID, item.getGeneralItemLocalObject().getId());
    intent.putExtra(ImageDetailActivity.RESPONSE_POSITION, position);

    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(intent, options.toBundle());
    } else {//from   w w  w .  j av a 2 s  . co m
        startActivity(intent);
    }
}

From source file:com.fbbackup.ImageGridFragment.java

@TargetApi(16)
@Override//ww w .j  a v 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);

    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);
    }
}

From source file:uk.org.downiesoft.slideshow.GridViewFragment.java

/**
 * {@inheritDoc}// w w w  .  j  av  a 2s . com
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_slideshow:
        View thumbView = mGridView.getChildAt(0);
        ActivityOptions options = ActivityOptions.makeScaleUpAnimation(mGridView, (int) thumbView.getX(),
                (int) thumbView.getY(), thumbView.getWidth(), thumbView.getHeight());
        startSlideshow(mCurrentFile, 0, true, options);
        return true;
    case R.id.action_show_favourites:
        showFavourites();
        return true;
    case R.id.action_save_favourites:
        FavouritesManager.saveFavouritesDialog(getActivity(), mFavourites, this);
        return true;
    case R.id.action_open_favourites:
        FavouritesManager.loadFavouritesDialog(getActivity(), this);
        return true;
    case R.id.action_refresh_gridthumbs:
        mThumbnailAdapter.refreshThumbs();
        return true;
    case R.id.action_browse:
        Intent intent = new Intent(getActivity(), BrowserActivity.class);
        intent.putExtra(BrowserDialog.ARG_ZFILE, mCurrentFile.toArgs());
        startActivityForResult(intent, SlideShowActivity.REQUEST_BROWSER);
        return true;
    default:
        return false;
    }
}

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

/**
 * Callback method to be invoked when an item in this AdapterView has
 * been clicked.//w ww  .ja va  2 s . 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:uk.org.downiesoft.slideshow.GridViewFragment.java

/**
 * {@inheritDoc}//  www.ja  va2s.com
  * In this case we select the given slide in the grid view.
 * @see PreviewFragment.PreviewFragmentListener
 */
@Override
public void onPreviewStartSlideshow() {
    View previewView = mPreview.getView();
    if (previewView != null) {
        ActivityOptions options = ActivityOptions.makeScaleUpAnimation(mGridView, (int) previewView.getX(),
                (int) previewView.getY(), previewView.getWidth(), previewView.getHeight());
        startSlideshow(mCurrentFile, mCurrentImage, false, options);
    }
}

From source file:com.cm.android.beercellar.ui.ImageGridFragment.java

@TargetApi(VERSION_CODES.JELLY_BEAN)
@Override//w w  w .j a  va  2s  .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);
    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.android.leanlauncher.LauncherTransitionable.java

boolean startActivity(View v, Intent intent, Object tag) {
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try {/*from   w w  w . j  a  v a  2 s .  co m*/
        // Only launch using the new animation if the shortcut has not opted out (this is a
        // private contract between launcher and may be ignored in the future).
        boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
        LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this);
        UserManagerCompat userManager = UserManagerCompat.getInstance(this);

        UserHandleCompat user = null;
        if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) {
            long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1);
            user = userManager.getUserForSerialNumber(serialNumber);
        }

        Bundle optsBundle = null;
        if (useLaunchAnimation) {
            ActivityOptions opts = Utilities.isLmpOrAbove()
                    ? ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim)
                    : ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(),
                            v.getMeasuredHeight());
            optsBundle = opts.toBundle();
        }

        if (user == null || user.equals(UserHandleCompat.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            // TODO Component can be null when shortcuts are supported for secondary user
            launcherApps.startActivityForProfile(intent.getComponent(), user, intent.getSourceBounds(),
                    optsBundle);
        }
        return true;
    } catch (SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Launcher does not have the permission to launch " + intent
                + ". Make sure to create a MAIN intent-filter for the corresponding activity "
                + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e);
    }
    return false;
}

From source file:com.android.soma.Launcher.java

boolean startActivity(View v, Intent intent, Object tag) {
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    try {/*  w  w w.  ja v a 2  s.c o  m*/
        // Only launch using the new animation if the shortcut has not opted out (this is a
        // private contract between launcher and may be ignored in the future).
        boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
        if (useLaunchAnimation) {
            ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(),
                    v.getMeasuredHeight());

            startActivity(intent, opts.toBundle());
        } else {
            startActivity(intent);
        }
        return true;
    } catch (SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Launcher does not have the permission to launch " + intent
                + ". Make sure to create a MAIN intent-filter for the corresponding activity "
                + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e);
    }
    return false;
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

private boolean startActivity(View v, Intent intent, Object tag) {
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try {/*from   ww  w.  ja v a 2s .c o m*/
        // Only launch using the new animation if the shortcut has not opted out (this is a
        // private contract between launcher and may be ignored in the future).
        boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
        LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this);
        UserManagerCompat userManager = UserManagerCompat.getInstance(this);

        UserHandleCompat user = null;
        if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) {
            long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1);
            user = userManager.getUserForSerialNumber(serialNumber);
        }

        Bundle optsBundle = null;
        if (useLaunchAnimation) {
            ActivityOptions opts = null;
            if (sClipRevealMethod != null) {
                // TODO: call method directly when Launcher3 can depend on M APIs
                int left = 0, top = 0;
                int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
                if (v instanceof TextView) {
                    // Launch from center of icon, not entire view
                    Drawable icon = Workspace.getTextViewIcon((TextView) v);
                    if (icon != null) {
                        Rect bounds = icon.getBounds();
                        left = (width - bounds.width()) / 2;
                        top = v.getPaddingTop();
                        width = bounds.width();
                        height = bounds.height();
                    }
                }
                try {
                    opts = (ActivityOptions) sClipRevealMethod.invoke(null, v, left, top, width, height);
                } catch (IllegalAccessException e) {
                    Log.d(TAG, "Could not call makeClipRevealAnimation: " + e);
                    sClipRevealMethod = null;
                } catch (InvocationTargetException e) {
                    Log.d(TAG, "Could not call makeClipRevealAnimation: " + e);
                    sClipRevealMethod = null;
                }
            }
            if (opts == null && !Utilities.isLmpOrAbove()) {
                // Below L, we use a scale up animation
                opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(),
                        v.getMeasuredHeight());
            } else if (opts == null && Utilities.isLmpMR1()) {
                // On L devices, we use the device default slide-up transition.
                // On L MR1 devices, we a custom version of the slide-up transition which
                // doesn't have the delay present in the device default.
                opts = ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim);
            }
            optsBundle = opts != null ? opts.toBundle() : null;
        }

        if (user == null || user.equals(UserHandleCompat.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            // TODO Component can be null when shortcuts are supported for secondary user
            launcherApps.startActivityForProfile(intent.getComponent(), user, intent.getSourceBounds(),
                    optsBundle);
        }
        return true;
    } catch (SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Launcher does not have the permission to launch " + intent
                + ". Make sure to create a MAIN intent-filter for the corresponding activity "
                + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e);
    }
    return false;
}