android.app.ActivityOptions Java Examples

The following examples show how to use android.app.ActivityOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppConfigActivity.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public static void show(Context ctx, String packagename, View source) {
    Intent i = new Intent();

    ActivityOptions opts = null;

    if (source != null) {
        opts = ActivityOptions.makeScaleUpAnimation(source, 0, 0, 0, 0);
    }

    i.setClass(ctx, AppConfigActivity.class);
    i.putExtra(EXTRA_PACKAGENAME, packagename);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    if (opts != null) {
        ctx.startActivity(i, opts.toBundle());
    } else {
        ctx.startActivity(i);
    }
}
 
Example #2
Source File: SettingsFragment.java    From NavigationView-Demo with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_settings, container, false);

    FloatingActionButton floatingActionButton = (FloatingActionButton) rootView.findViewById(R.id.fab);
    floatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), FabActivity.class);

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

    return rootView;
}
 
Example #3
Source File: SwipeUtils.java    From hipda with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calling the convertToTranslucent method on platforms after Android 5.0
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
private static void convertActivityToTranslucentAfterL(Activity activity) {
    try {
        Method getActivityOptions = Activity.class.getDeclaredMethod("getActivityOptions");
        getActivityOptions.setAccessible(true);
        Object options = getActivityOptions.invoke(activity);

        Class<?>[] classes = Activity.class.getDeclaredClasses();
        Class<?> translucentConversionListenerClazz = null;
        for (Class clazz : classes) {
            if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
                translucentConversionListenerClazz = clazz;
            }
        }
        Method convertToTranslucent = Activity.class.getDeclaredMethod("convertToTranslucent",
                translucentConversionListenerClazz, ActivityOptions.class);
        convertToTranslucent.setAccessible(true);
        convertToTranslucent.invoke(activity, null, options);
    } catch (Throwable t) {
    }
}
 
Example #4
Source File: Launcher.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
boolean startActivity(View v, Intent intent, Object tag) {
	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

	try {
		// 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();
		
	}
	return false;
}
 
Example #5
Source File: SafeActivityOptions.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Performs permission check and retrieves the options.
 *
 * @param intent The intent that is being launched.
 * @param aInfo The info of the activity being launched.
 * @param callerApp The record of the caller.
 */
ActivityOptions getOptions(@Nullable Intent intent, @Nullable ActivityInfo aInfo,
        @Nullable ProcessRecord callerApp,
        ActivityStackSupervisor supervisor) throws SecurityException {
    if (mOriginalOptions != null) {
        checkPermissions(intent, aInfo, callerApp, supervisor, mOriginalOptions,
                mOriginalCallingPid, mOriginalCallingUid);
        setCallingPidForRemoteAnimationAdapter(mOriginalOptions, mOriginalCallingPid);
    }
    if (mCallerOptions != null) {
        checkPermissions(intent, aInfo, callerApp, supervisor, mCallerOptions,
                mRealCallingPid, mRealCallingUid);
        setCallingPidForRemoteAnimationAdapter(mCallerOptions, mRealCallingPid);
    }
    return mergeActivityOptions(mOriginalOptions, mCallerOptions);
}
 
Example #6
Source File: MainActivity.java    From gallery-app-android with MIT License 6 votes vote down vote up
private void onClickImage(ItemViewHolder holder, Gallery gallery, Image image) {
  Intent intent = new Intent(this, GalleryActivity.class)
      .putExtra(Intents.EXTRA_GALLERY, Parcels.wrap(gallery))
      .putExtra(Intents.EXTRA_IMAGE, Parcels.wrap(image));

  Bundle options = null;
  if (Const.HAS_L) {
    Drawable drawable = holder.photo.getDrawable();
    if (drawable != null) {
      Holder.set(drawable);

      options = ActivityOptions.makeSceneTransitionAnimation(this, holder.photo,
          getString(R.string.gallery_photo_hero)).toBundle();
    }
  }

  ActivityCompat.startActivity(this, intent, options);
}
 
Example #7
Source File: Utils.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Calling the convertToTranslucent method on platforms after Android 5.0
 */
private static void convertActivityToTranslucentAfterL(Activity activity) {
    try {
        Method getActivityOptions = Activity.class.getDeclaredMethod("getActivityOptions");
        getActivityOptions.setAccessible(true);
        Object options = getActivityOptions.invoke(activity);

        Class<?>[] classes = Activity.class.getDeclaredClasses();
        Class<?> translucentConversionListenerClazz = null;
        for (Class clazz : classes) {
            if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
                translucentConversionListenerClazz = clazz;
            }
        }
        Method convertToTranslucent = Activity.class.getDeclaredMethod("convertToTranslucent",
                translucentConversionListenerClazz, ActivityOptions.class);
        convertToTranslucent.setAccessible(true);
        convertToTranslucent.invoke(activity, null, options);
    } catch (Throwable t) {
    }
}
 
Example #8
Source File: MoviesActivity.java    From udacity-p1-p2-popular-movies with MIT License 6 votes vote down vote up
@Override
public void onMovieClick(@Nullable View movieView, Movie movie) {
    if (! mTwoPane) {
        Intent intent = new Intent(this, MovieDetailsActivity.class);
        intent.putExtra(BundleKeys.MOVIE, Movie.toParcelable(movie));
        if (movieView != null) {
            ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(movieView, 0, 0,
                    movieView.getWidth(), movieView.getHeight());
            startActivity(intent, opts.toBundle());
        } else {
            startActivity(intent);
        }
    } else {
        showMovieDetails(movie);
    }
}
 
Example #9
Source File: CalendarFragment.java    From narrate-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onSingleTapUp(MotionEvent e) {
    View view = mRecyclerView.findChildViewUnder(e.getX(), e.getY());

    if (view != null) {
        view.playSoundEffect(SoundEffectConstants.CLICK);

        int pos = mRecyclerView.getChildPosition(view);

        Intent i = new Intent(getActivity(), ViewEntryActivity.class);
        Bundle b = new Bundle();
        b.putParcelable(ViewEntryActivity.ENTRY_KEY, mDisplayedEntries.get(pos));
        i.putExtras(b);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.buildDrawingCache(true);
            Bitmap drawingCache = view.getDrawingCache(true);
            Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0).toBundle();
            getActivity().startActivity(i, bundle);
        } else {
            startActivity(i);
        }
    }

    return super.onSingleTapUp(e);
}
 
Example #10
Source File: WakefulBroadcastReceiver.java    From WearPomodoro with GNU General Public License v2.0 6 votes vote down vote up
public static void startWakefullActity(Context context, Intent intent, ActivityOptions activityOptions) {
    synchronized (mActiveWakeLocks) {
        int id = mNextId;
        mNextId++;
        if (mNextId <= 0) {
            mNextId = 1;
        }

        PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
                        | PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                        | PowerManager.ACQUIRE_CAUSES_WAKEUP, "wake:activity");
        wl.setReferenceCounted(false);
        wl.acquire(60*1000);
        mActiveWakeLocks.put(id, wl);

        intent.putExtra(EXTRA_WAKE_LOCK_ID, id);
        context.startActivity(intent, activityOptions.toBundle());
    }
}
 
Example #11
Source File: Launcher.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
public Bundle getActivityLaunchOptions(View v) {
    if (AndroidVersion.isAtLeastMarshmallow) {
        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();
            }
        }
        return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height).toBundle();
    } else if (AndroidVersion.isAtLeastLollipopMR1) {
        // On L devices, we use the device default slide-up transition.
        // On L MR1 devices, we use a custom version of the slide-up transition which
        // doesn't have the delay present in the device default.
        return ActivityOptions.makeCustomAnimation(
                this, R.anim.task_open_enter, R.anim.no_anim).toBundle();
    }
    return null;
}
 
Example #12
Source File: MainActivity.java    From Synapse with Apache License 2.0 6 votes vote down vote up
/**
 * Transition animation may cause exception
 */
private void startNeuralNetworkConfig(@NonNull final View view) {
    view.setClickable(false);
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            view.setClickable(true);
        }
    }, 1000);

    try {
        final Intent intent = new Intent(this, NeuralModelActivity.class);

        FabTransform.addExtras(intent,
                ContextCompat.getColor(this, R.color.color_accent),
                R.drawable.ic_add_white_24dp);

        final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
                this, view, getString(R.string.transition_neural_config));

        startActivity(intent, options.toBundle());
    } catch (Exception e) {
        ExceptionHelper.getInstance()
                .caught(e);
    }
}
 
Example #13
Source File: MainActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
private void populateGrid() {
    grid.setAdapter(new PhotoAdapter(this, relevantPhotos));
    grid.addOnItemTouchListener(new OnItemSelectedListener(MainActivity.this) {
        public void onItemSelected(RecyclerView.ViewHolder holder, int position) {
            if (!(holder instanceof PhotoViewHolder)) {
                return;
            }
            PhotoItemBinding binding = ((PhotoViewHolder) holder).getBinding();
            final Intent intent = getDetailActivityStartIntent(MainActivity.this,
                    relevantPhotos, position, binding);
            final ActivityOptions activityOptions = getActivityOptions(binding);

            MainActivity.this.startActivityForResult(intent, IntentUtil.REQUEST_CODE,
                    activityOptions.toBundle());
        }
    });
    empty.setVisibility(View.GONE);
}
 
Example #14
Source File: MainActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(Post post, View v) {
    Intent intent = new Intent(MainActivity.this, PostDetailsActivity.class);
    intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, post.getId());

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        View imageView = v.findViewById(R.id.postImageView);
        View authorImageView = v.findViewById(R.id.authorImageView);

        ActivityOptions options = ActivityOptions.
                makeSceneTransitionAnimation(MainActivity.this,
                        new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name)),
                        new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name))
                );
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
    } else {
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
    }
}
 
Example #15
Source File: ProfileActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(Post post, View v) {
    Intent intent = new Intent(ProfileActivity.this, PostDetailsActivity.class);
    intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, post.getId());
    intent.putExtra(PostDetailsActivity.AUTHOR_ANIMATION_NEEDED_EXTRA_KEY, true);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        View imageView = v.findViewById(R.id.postImageView);

        ActivityOptions options = ActivityOptions.
                makeSceneTransitionAnimation(ProfileActivity.this,
                        new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name))
                );
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
    } else {
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
    }
}
 
Example #16
Source File: SearchPostsFragment.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
public void openProfileActivity(String userId, View view) {
    Intent intent = new Intent(getActivity(), ProfileActivity.class);
    intent.putExtra(ProfileActivity.USER_ID_EXTRA_KEY, userId);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view != null) {

        View authorImageView = view.findViewById(R.id.authorImageView);

        ActivityOptions options = ActivityOptions.
                makeSceneTransitionAnimation(getActivity(),
                        new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name)));
        startActivityForResult(intent, ProfileActivity.CREATE_POST_FROM_PROFILE_REQUEST, options.toBundle());
    } else {
        startActivityForResult(intent, ProfileActivity.CREATE_POST_FROM_PROFILE_REQUEST);
    }
}
 
Example #17
Source File: SearchUsersFragment.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
private void openProfileActivity(String userId, View view) {
    Intent intent = new Intent(getActivity(), ProfileActivity.class);
    intent.putExtra(ProfileActivity.USER_ID_EXTRA_KEY, userId);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && view != null) {

        ImageView imageView = view.findViewById(R.id.photoImageView);

        ActivityOptions options = ActivityOptions.
                makeSceneTransitionAnimation(getActivity(),
                        new android.util.Pair<>(imageView, getString(R.string.post_author_image_transition_name)));
        startActivityForResult(intent, UPDATE_FOLLOWING_STATE_REQ, options.toBundle());
    } else {
        startActivityForResult(intent, UPDATE_FOLLOWING_STATE_REQ);
    }
}
 
Example #18
Source File: FollowingPostsActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(String postId, View v) {
    Intent intent = new Intent(FollowingPostsActivity.this, PostDetailsActivity.class);
    intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, postId);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        View imageView = v.findViewById(R.id.postImageView);
        View authorImageView = v.findViewById(R.id.authorImageView);

        ActivityOptions options = ActivityOptions.
                makeSceneTransitionAnimation(FollowingPostsActivity.this,
                        new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name)),
                        new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name))
                );
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
    } else {
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
    }
}
 
Example #19
Source File: PostNewDesignerNewsStory.java    From android-proguards with Apache License 2.0 6 votes vote down vote up
@OnClick(R.id.new_story_post)
protected void postNewStory() {
    if (DesignerNewsPrefs.get(this).isLoggedIn()) {
        ImeUtils.hideIme(title);
        Intent postIntent = new Intent(PostStoryService.ACTION_POST_NEW_STORY, null,
                this, PostStoryService.class);
        postIntent.putExtra(PostStoryService.EXTRA_STORY_TITLE, title.getText().toString());
        postIntent.putExtra(PostStoryService.EXTRA_STORY_URL, url.getText().toString());
        postIntent.putExtra(PostStoryService.EXTRA_STORY_COMMENT, comment.getText().toString());
        postIntent.putExtra(PostStoryService.EXTRA_BROADCAST_RESULT,
                getIntent().getBooleanExtra(PostStoryService.EXTRA_BROADCAST_RESULT, false));
        startService(postIntent);
        setResult(RESULT_POSTING);
        finishAfterTransition();
    } else {
        Intent login = new Intent(this, DesignerNewsLogin.class);
        MorphTransform.addExtras(login, ContextCompat.getColor(this, R.color.designer_news), 0);
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
                this, post, getString(R.string.transition_designer_news_login));
        startActivity(login, options.toBundle());
    }
}
 
Example #20
Source File: JudgeUtils.java    From Awesome-WanAndroid with Apache License 2.0 6 votes vote down vote up
public static void startArticleDetailActivity(Context mActivity, ActivityOptions activityOptions, int id, String articleTitle,
                                              String articleLink, boolean isCollect,
                                              boolean isCollectPage,boolean isCommonSite) {
    Intent intent = new Intent(mActivity, ArticleDetailActivity.class);
    intent.putExtra(Constants.ARTICLE_ID, id);
    intent.putExtra(Constants.ARTICLE_TITLE, articleTitle);
    intent.putExtra(Constants.ARTICLE_LINK, articleLink);
    intent.putExtra(Constants.IS_COLLECT, isCollect);
    intent.putExtra(Constants.IS_COLLECT_PAGE, isCollectPage);
    intent.putExtra(Constants.IS_COMMON_SITE, isCommonSite);
    if (activityOptions != null && !Build.MANUFACTURER.contains("samsung") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        mActivity.startActivity(intent, activityOptions.toBundle());
    } else {
        mActivity.startActivity(intent);
    }
}
 
Example #21
Source File: ActivityRecord.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void setActivityType(boolean componentSpecified, int launchedFromUid, Intent intent,
        ActivityOptions options, ActivityRecord sourceRecord) {
    int activityType = ACTIVITY_TYPE_UNDEFINED;
    if ((!componentSpecified || canLaunchHomeActivity(launchedFromUid, sourceRecord))
            && isHomeIntent(intent) && !isResolverActivity()) {
        // This sure looks like a home activity!
        activityType = ACTIVITY_TYPE_HOME;

        if (info.resizeMode == RESIZE_MODE_FORCE_RESIZEABLE
                || info.resizeMode == RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION) {
            // We only allow home activities to be resizeable if they explicitly requested it.
            info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
        }
    } else if (realActivity.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME) ||
            service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) {
        activityType = ACTIVITY_TYPE_RECENTS;
    } else if (options != null && options.getLaunchActivityType() == ACTIVITY_TYPE_ASSISTANT
            && canLaunchAssistActivity(launchedFromPackage)) {
        activityType = ACTIVITY_TYPE_ASSISTANT;
    }
    setActivityType(activityType);
}
 
Example #22
Source File: MainActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
public void openPostDetailsActivity(Post post, View v) {
    Intent intent = new Intent(MainActivity.this, PostDetailsActivity.class);
    intent.putExtra(PostDetailsActivity.POST_ID_EXTRA_KEY, post.getId());

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        View imageView = v.findViewById(R.id.postImageView);
        View authorImageView = v.findViewById(R.id.authorImageView);

        ActivityOptions options = ActivityOptions.
                makeSceneTransitionAnimation(MainActivity.this,
                        new android.util.Pair<>(imageView, getString(R.string.post_image_transition_name)),
                        new android.util.Pair<>(authorImageView, getString(R.string.post_author_image_transition_name))
                );
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST, options.toBundle());
    } else {
        startActivityForResult(intent, PostDetailsActivity.UPDATE_POST_REQUEST);
    }
}
 
Example #23
Source File: JianDanMeiziFragment.java    From MoeQuest with Apache License 2.0 5 votes vote down vote up
private void finishTask() {

    if (page * count - count - 1 > 0) {
      mAdapter.notifyItemRangeChanged(page * count - count - 1, count);
    } else {
      mAdapter.notifyDataSetChanged();
    }

    if (mSwipeRefreshLayout.isRefreshing()) {
      mSwipeRefreshLayout.setRefreshing(false);
    }

    mIsRefreshing = false;

    mAdapter.setOnItemClickListener((position, holder) -> {

      Intent intent = SingleMeiziDetailsActivity.LuanchActivity(getActivity(),
          jianDanMeiziDataList.get(position).pics[0],
          jianDanMeiziDataList.get(position).commentAuthor);
      if (android.os.Build.VERSION.SDK_INT >= 21) {
        startActivity(intent, ActivityOptions.
            makeSceneTransitionAnimation(getActivity(),
                holder.getParentView().findViewById(R.id.item_fill_image),
                "transitionImg").toBundle());
      } else {
        startActivity(intent);
      }
    });
  }
 
Example #24
Source File: RecommendDetailsAdapter.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final NewViewHolder vh, int position) {
    final Comic comic = mTabList.getComics().get(position);
    vh.title.setText(comic.getTitle());
    vh.desc.setText(comic.getAuthor());
    vh.info.setText(comic.getComicStatus());

    mImageLoader.displayThumbnail(mContext, comic.getThumbnailUrl(), vh.iv,
            R.mipmap.blank, R.mipmap.blank, 165, 220);

    vh.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, ComicDetailsActivity.class);
            intent.putExtra("cid", comic.getCid());
            intent.putExtra("thumbnailUrl", comic.getThumbnailUrl());
            intent.putExtra("title", comic.getTitle());

            if (vh.iv.getDrawable() != null) {
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                    //如果是android5.0及以上,开启shareElement动画
                    String transitionName = mContext.getString(R.string.image_transition_name);

                    ActivityOptions transitionActivityOptions = ActivityOptions
                            .makeSceneTransitionAnimation((Activity) mContext, vh.iv, transitionName);
                    mContext.startActivity(intent, transitionActivityOptions.toBundle());
                } else {
                    mContext.startActivity(intent);
                }
            } else {
                mContext.startActivity(intent);
            }
        }
    });
}
 
Example #25
Source File: MainActivity.java    From YCGallery with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()){
        case R.id.tv_1:
            startActivity(new Intent(this, FirstActivity.class));
            break;
        case R.id.tv_2:
            Intent intent2 = new Intent(this, SecondActivity.class);
            startActivity(intent2);
            overridePendingTransition(R.anim.screen_zoom_in, R.anim.screen_zoom_out);
            break;
        case R.id.tv_3:
            Intent intent3 = new Intent(this, ThirdActivity.class);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                startActivity(intent3, ActivityOptions.makeSceneTransitionAnimation(
                        MainActivity.this).toBundle());
            }else {
                startActivity(intent3);
            }
            break;
        case R.id.tv_4:
            startActivity(new Intent(this, FourActivity.class));
            break;
        case R.id.tv_5:
            Intent intent5 = new Intent(this, FiveActivity.class);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                startActivity(intent5, ActivityOptions.makeSceneTransitionAnimation(
                        MainActivity.this, tv_5, "YangChong").toBundle());
            }
            break;
        default:
            break;
    }
}
 
Example #26
Source File: CardActivity.java    From Walrus with GNU General Public License v3.0 5 votes vote down vote up
public static void startActivity(Activity activity, Mode mode, Card card, View transitionView) {
    Intent intent = new Intent(activity, CardActivity.class);

    intent.putExtra(EXTRA_MODE, mode);
    intent.putExtra(EXTRA_CARD, Parcels.wrap(card));

    if (transitionView != null
            && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        List<Pair<View, String>> sharedElements = new ArrayList<>();

        View view = activity.findViewById(android.R.id.statusBarBackground);
        if (view != null) {
            sharedElements.add(new Pair<>(view, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME));
        }
        view = activity.findViewById(android.R.id.navigationBarBackground);
        if (view != null) {
            sharedElements.add(new Pair<>(view,
                    Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME));
        }
        view = activity.findViewById(R.id.toolbar);
        if (view != null) {
            sharedElements.add(new Pair<>(view, "toolbar"));
        }

        sharedElements.add(new Pair<>(transitionView, "card"));

        // noinspection unchecked, SuspiciousToArrayCall
        ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(activity,
                (Pair<View, String>[]) sharedElements.toArray(new Pair[sharedElements.size()]));

        activity.startActivity(intent, activityOptions.toBundle());
    } else {
        activity.startActivity(intent);
    }
}
 
Example #27
Source File: LockSettingActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void startActivityForAnim(Intent intent,int requestCode){
    // 5.0及以上则使用Activity动画
    if(Build.VERSION.SDK_INT>=21){
        Bundle bundle= ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle();
        getActivity().startActivityForResult(intent, requestCode, bundle);
    } else {
        getActivity().startActivityForResult(intent, requestCode);
    }
}
 
Example #28
Source File: U.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private static Bundle getActivityOptionsBundle(Context context,
                                               ApplicationType applicationType,
                                               View view,
                                               int left,
                                               int top,
                                               int right,
                                               int bottom) {
    ActivityOptions options = getActivityOptions(context, applicationType, view);
    if(options == null) return null;

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
        return options.toBundle();

    return options.setLaunchBounds(new Rect(left, top, right, bottom)).toBundle();
}
 
Example #29
Source File: RankDetailsAdapter.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final RankViewHolder vh, int position) {
    final Comic comic = mComics.get(position);
    vh.rank.setText((position + 1) + "");
    vh.title.setText(comic.getTitle());
    vh.desc.setText(comic.getAuthor());
    vh.info.setText(comic.getComicStatus());

    mImageLoader.displayThumbnail(mContext, comic.getThumbnailUrl(), vh.iv,
            R.mipmap.blank, R.mipmap.blank, 165, 220);

    vh.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, ComicDetailsActivity.class);
            intent.putExtra("cid", comic.getCid());
            intent.putExtra("thumbnailUrl", comic.getThumbnailUrl());
            intent.putExtra("title", comic.getTitle());

            if (vh.iv.getDrawable() != null) {
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                    //如果是android5.0及以上,开启shareElement动画
                    String transitionName = mContext.getString(R.string.image_transition_name);

                    ActivityOptions transitionActivityOptions = ActivityOptions
                            .makeSceneTransitionAnimation((Activity) mContext, vh.iv, transitionName);
                    mContext.startActivity(intent, transitionActivityOptions.toBundle());
                } else {
                    mContext.startActivity(intent);
                }
            } else {
                mContext.startActivity(intent);
            }
        }
    });
}
 
Example #30
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
public void onStartLaunchBoundsActivity(View view) {
    Log.d(mLogTag, "** starting LaunchBoundsActivity");

    // Define the bounds in which the Activity will be launched into.
    Rect bounds = new Rect(500, 300, 100, 0);

    // Set the bounds as an activity option.
    ActivityOptions options = ActivityOptions.makeBasic();
    options.setLaunchBounds(bounds);

    // Start the LaunchBoundsActivity with the specified options
    Intent intent = new Intent(this, LaunchBoundsActivity.class);
    startActivity(intent, options.toBundle());

}