当前位置: 首页>>代码示例>>Java>>正文


Java ActivityOptionsCompat类代码示例

本文整理汇总了Java中android.support.v4.app.ActivityOptionsCompat的典型用法代码示例。如果您正苦于以下问题:Java ActivityOptionsCompat类的具体用法?Java ActivityOptionsCompat怎么用?Java ActivityOptionsCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ActivityOptionsCompat类属于android.support.v4.app包,在下文中一共展示了ActivityOptionsCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showVideoDetails

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
public static void showVideoDetails(Activity activity, Video video, Presenter.ViewHolder itemViewHolder, boolean animate, boolean forceSelection, boolean shouldLoadBackdrop, long listId) {
    Intent intent = new Intent(activity, VideoDetailsActivity.class);
    intent.putExtra(VideoDetailsFragment.EXTRA_VIDEO, video);
    intent.putExtra(VideoDetailsFragment.EXTRA_LIST_ID, listId);
    intent.putExtra(VideoDetailsFragment.EXTRA_FORCE_VIDEO_SELECTION, forceSelection);
    intent.putExtra(VideoDetailsFragment.EXTRA_SHOULD_LOAD_BACKDROP,shouldLoadBackdrop);
    View sourceView = null;
    if (itemViewHolder.view instanceof ImageCardView) {
        sourceView = ((ImageCardView) itemViewHolder.view).getMainImageView();
    } else if (itemViewHolder instanceof ListPresenter.ListViewHolder){
        sourceView = ((ListPresenter.ListViewHolder)itemViewHolder).getImageView();
    }
    if(animate) {
        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity,
                sourceView,
                VideoDetailsActivity.SHARED_ELEMENT_NAME).toBundle();

        activity.startActivity(intent,bundle);
    }
    else{
        activity.startActivity(intent);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:25,代码来源:VideoViewClickedListener.java

示例2: gotoDetail

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
@Override
public void gotoDetail() {
    Activity activity = (Activity) getContext();
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
            new Pair(imageView, DetailActivity.IMAGE_TRANSITION_NAME),
            new Pair(address1, DetailActivity.ADDRESS1_TRANSITION_NAME),
            new Pair(address2, DetailActivity.ADDRESS2_TRANSITION_NAME),
            new Pair(address3, DetailActivity.ADDRESS3_TRANSITION_NAME),
            new Pair(address4, DetailActivity.ADDRESS4_TRANSITION_NAME),
            new Pair(address5, DetailActivity.ADDRESS5_TRANSITION_NAME),
            new Pair(ratingBar, DetailActivity.RATINGBAR_TRANSITION_NAME),
            new Pair(head1, DetailActivity.HEAD1_TRANSITION_NAME),
            new Pair(head2, DetailActivity.HEAD2_TRANSITION_NAME),
            new Pair(head3, DetailActivity.HEAD3_TRANSITION_NAME),
            new Pair(head4, DetailActivity.HEAD4_TRANSITION_NAME)
    );
    Intent intent = new Intent(activity, DetailActivity.class);
    intent.putExtra(DetailActivity.EXTRA_IMAGE_URL, imageUrl);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:CommonFragment.java

示例3: OrgHolder

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
public OrgHolder(View itemView) {
    super(itemView);
    orgImage = itemView.findViewById(R.id.org_image);
    orgCard = itemView.findViewById(R.id.card_view_org);
    orgName = itemView.findViewById(R.id.org_name);
    orgTagline = itemView.findViewById(R.id.org_tagline);

    orgCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = new Intent(context, OrgDetailActivity.class);
            i.putExtra(ORG_TAG, getItem(getAdapterPosition()));
            i.putExtra("EXTRA_TRANSITION_NAME", ViewCompat.getTransitionName(orgImage));
            ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation((AppCompatActivity) context,
                    orgImage,
                    ViewCompat.getTransitionName(orgImage));
            i.putExtra("ORG_ID", getItem(getAdapterPosition()).getOrgID());
            context.startActivity(i, optionsCompat.toBundle());
        }
    });
}
 
开发者ID:coding-blocks,项目名称:GSoC-Info-Android,代码行数:22,代码来源:OrgAdapter.java

示例4: onItemClick

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
@Override
public void onItemClick(View itemView, int position) {
    IconBean bean = mIcons.get(position);
    Intent intent = new Intent(getActivity(), IconViewActivity.class);
    intent.putExtra("icon_name", bean.name);
    intent.putExtra("resource_id", bean.id);

    if (mIsInstalledFragment) {
        // 已适配 Fragment,传入包名
        intent.putExtra("package_name", bean.iconPkgName);
    }

    ActivityOptionsCompat options = ActivityOptionsCompat
            .makeSceneTransitionAnimation(getActivity(), itemView, "dialog_icon");

    startActivity(intent, options.toBundle());
}
 
开发者ID:iAcn,项目名称:MBEStyle,代码行数:18,代码来源:IconShowFragment.java

示例5: onCreate

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_a);

    final ImageView imageView = (ImageView) findViewById(R.id.simple_activity_a_imageView);

    Button button = (Button) findViewById(R.id.simple_activity_a_btn);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(SimpleActivityA.this, SimpleActivityB.class);
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                    SimpleActivityA.this,
                    imageView,
                    ViewCompat.getTransitionName(imageView));
            startActivity(intent, options.toBundle());
        }
    });

}
 
开发者ID:mikescamell,项目名称:shared-element-transitions,代码行数:22,代码来源:SimpleActivityA.java

示例6: startActivityForResult

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
/**
 * Safe Start activity for result with ActivityOptionsCompats
 *
 * @param a           current activity
 * @param i           intent to launch
 * @param requestCode requestCcde
 * @param options     ActivityOptionsCompat
 */
public static void startActivityForResult(Activity a,
                                          Intent i,
                                          int requestCode,
                                          ActivityOptionsCompat options) {
    if (a == null) {
        return;
    }
    if (options != null) {
        a.startActivityForResult(
                i,
                requestCode,
                options.toBundle()
        );
    } else {
        a.startActivityForResult(
                i,
                requestCode);
    }
}
 
开发者ID:yajnesh,项目名称:AndroidGeneralUtils,代码行数:28,代码来源:ActivityUtil.java

示例7: launch

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
public static void launch(@NonNull Activity activity,
                          @NonNull ArrayList<String> labels,
                          @Nullable View transitionView) {
    Intent launchIntent = new Intent(activity, InfoActivity.class);
    launchIntent.putStringArrayListExtra(ARA_RECOGNITION_LIST, labels);

    if (transitionView != null) {
        ActivityOptionsCompat options = ActivityOptionsCompat.
                makeSceneTransitionAnimation(activity,
                        transitionView,
                        activity.getString(R.string.info_activity_transition_name));
        activity.startActivity(launchIntent, options.toBundle());
        activity.overridePendingTransition(0, 0);
    } else {
        activity.startActivity(launchIntent);
    }
}
 
开发者ID:kevalpatel2106,项目名称:smart-lens,代码行数:18,代码来源:InfoActivity.java

示例8: getTransitionAnimationForProduct

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
/**
 * Get the transition animation between activity for view
 *
 * @param activity current activity
 * @param v        view on which animation is bound
 * @param name     custom name of animation
 * @return ActivityOptionsCompat constructed
 */
public static ActivityOptionsCompat getTransitionAnimationForProduct(Activity activity, View v, String name) {
    try {
        if (activity == null || v == null) {
            return null;
        }
        ViewCompat.setTransitionName(v, name);

        return ActivityOptionsCompat.
                makeSceneTransitionAnimation(activity,
                        Pair.create(v, ViewCompat.getTransitionName(v))
                );
    } catch (Throwable e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:yajnesh,项目名称:AndroidGeneralUtils,代码行数:25,代码来源:ActivityUtil.java

示例9: startZhiHuDetailActivity

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
private void startZhiHuDetailActivity(int id, View view) {
    Intent intent = new Intent();
    intent.setClass(getActivity(), ZhiHuDetailActivity.class);
    intent.putExtra("id", id);
    intent.putExtra("isNotTransition", true);
    /**
     * 用这个ActivityOptionsCompat比用ActivityOptions兼容性更好,前者是V4下的兼容到16后者到21.
     * ActivityOptionsCompat.makeSceneTransitionAnimation()的第三个参数则是跳转后图片显示的transitionName的值
     *     <android.support.design.widget.AppBarLayout
     android:transitionName="zhihu_detail_title"
     android:fitsSystemWindows="true">
     */
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
            view, getActivity().getResources().getString(R.string.zhihu_detail_title));
    getActivity().startActivity(intent, options.toBundle());
}
 
开发者ID:paterWang,项目名称:EasyReader,代码行数:17,代码来源:ZhiHuHomeFragment.java

示例10: onPreferenceClick

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
    String key = preference.getKey();
    if (key.equals(prefAboutPageKey)) {

        ActivityOptionsCompat options =
                ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity());
        ((NavigationDrawerActivity) getActivity()).newAchievementUnlocked(1L << Constants.CURIOUS);
        startActivity(new Intent(getActivity(), AboutActivity.class), options.toBundle());
        return true;
    } else if (key.equals(prefLogoutButtonKey)) {
        //Clear login cache
        CacheUtils.clearLoginInfo(context);
        //Now launch on-board activity
        startActivity(new Intent(context, OnBoardActivity.class));
        //Now finish the activity
        ((NavigationDrawerActivity) context).finish();
        return true;
    }
    return false;
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:22,代码来源:SettingsFragment.java

示例11: onClick

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
@Override
public void onClick(View view) {
    int id = view.getId();
    switch (id) {
        case R.id.item_task_programmed_repeating_container:
            Pair[] pairs = new Pair[1];
            pairs[0] = new Pair<View, String>(mCategoryIcon, mFragment.getResources().getString(R.string.transition_task_list_category));
            //pairs[1] = new Pair<View, String>(mTitle, mFragment.getResources().getString(R.string.transition_task_list_title));
            //pairs[2] = new Pair<View, String>(mDescription, mFragment.getResources().getString(R.string.transition_task_list_description));
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(mFragment.getActivity(), pairs);

            Intent openTaskDetailActivity = new Intent(mFragment.getActivity(), TaskDetailActivity.class);
            openTaskDetailActivity.putExtra(TaskDetailActivity.TASK_ID_TO_DISPLAY, mCurrent.getId());
            openTaskDetailActivity.putExtra(TaskDetailActivity.TASK_POSITION, mReminderPosition);
            //mFragment.getActivity().startActivityForResult(openTaskDetailActivity, TaskDetailActivity.TASK_DETAIL_REQUEST_CODE, options.toBundle());

            if (mClickListener != null) {
                mClickListener.onItemClicked(mReminderPosition, openTaskDetailActivity, options.toBundle());
            }

            break;
    }
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:24,代码来源:ProgrammedRepeatingTaskViewHolder.java

示例12: startZhiHuDetailActivity

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
private void startZhiHuDetailActivity(String id, String imgUrl, View view) {
    Intent intent = new Intent();
    intent.setClass(getActivity(), TopNewsActivity.class);
    intent.putExtra("id", id);
    intent.putExtra("url", imgUrl);
    /**
     * 用这个ActivityOptionsCompat比用ActivityOptions兼容性更好,前者是V4下的兼容到16后者到21.
     * ActivityOptionsCompat.makeSceneTransitionAnimation()的第三个参数则是跳转后图片显示的transitionName的值
     *     <android.support.design.widget.AppBarLayout
     android:transitionName="zhihu_detail_title"
     android:fitsSystemWindows="true">
     */
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
            view, getActivity().getResources().getString(R.string.zhihu_detail_title));
    getActivity().startActivity(intent, options.toBundle());
}
 
开发者ID:paterWang,项目名称:EasyReader,代码行数:17,代码来源:TopNewsFragment.java

示例13: makeOptionsCompat

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
public static ActivityOptionsCompat makeOptionsCompat(Activity fromActivity, Pair<View, String>... sharedElements) {
    ArrayList<Pair<View, String>> list = new ArrayList<>(Arrays.asList(sharedElements));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        list.add(Pair.create(fromActivity.findViewById(android.R.id.statusBarBackground), Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME));
        list.add(Pair.create(fromActivity.findViewById(android.R.id.navigationBarBackground), Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME));
    }

    //remove any views that are null
    for (ListIterator<Pair<View, String>> iter = list.listIterator(); iter.hasNext();) {
        Pair pair = iter.next();
        if (pair.first == null) iter.remove();
    }

    sharedElements = list.toArray(new Pair[list.size()]);
    return ActivityOptionsCompat.makeSceneTransitionAnimation(
            fromActivity,
            sharedElements
    );
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:21,代码来源:TransitionHelper.java

示例14: goToMain

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
public static void goToMain(AppCompatActivity activity, View view) {
    ActivityOptionsCompat aoc;
    if (AndroidVersions.isLollipop() && view != null) {
        aoc = ActivityOptionsCompat.makeClipRevealAnimation(view,
                0,
                0,
                view.getWidth(),
                view.getHeight());
    } else {
        aoc = ActivityOptionsCompat.makeBasic();
    }
    Intent intent = new Intent(activity, MainActivity.class);
    ActivityCompat.startActivity(activity, intent, aoc.toBundle());
    ActivityCompat.finishAffinity(activity);
}
 
开发者ID:maddog05,项目名称:whatanime-android,代码行数:16,代码来源:Navigator.java

示例15: openGeraltWoman

import android.support.v4.app.ActivityOptionsCompat; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void openGeraltWoman(final long id, final ClickInfo clickInfo) {
    SampleApplication.createWomanComponent(id);
    if (multiWindow) {
        final GeraltWomanFragment geraltWomanFragment = GeraltWomanFragment.create();
        activity.getSupportFragmentManager().beginTransaction()
                .replace(R.id.details, geraltWomanFragment, TAG_DETAILS_FRAGMENT)
                .commitNow();
    } else {
        final View view = clickInfo.getView();
        Bundle bundle = null;
        if (view != null) {
            bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                    activity, Pair.create(view.findViewWithTag("photo"), "photo")
            ).toBundle();
        }
        activity.startActivity(GeraltWomanActivity.intent(activity), bundle);
    }
}
 
开发者ID:dmitrikudrenko,项目名称:MDRXL,代码行数:20,代码来源:Router.java


注:本文中的android.support.v4.app.ActivityOptionsCompat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。