當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。