Search in sources :

Example 86 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project FastHub by k0shk0sh.

the class ActivityHelper method startReveal.

public static void startReveal(@NonNull Activity activity, Intent intent, @NonNull View sharedElement) {
    if (!PrefGetter.isAppAnimationDisabled()) {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeClipRevealAnimation(sharedElement, sharedElement.getWidth() / 2, sharedElement.getHeight() / 2, sharedElement.getWidth(), sharedElement.getHeight());
        activity.startActivity(intent, options.toBundle());
    } else {
        activity.startActivity(intent);
    }
}
Also used : ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 87 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project LollipopShowcase by mikepenz.

the class MainActivity method animateActivity.

/**
 * helper class to start the new detailActivity animated
 *
 * @param appInfo
 * @param appIcon
 */
public void animateActivity(AppInfo appInfo, View appIcon) {
    Intent i = new Intent(this, DetailActivity.class);
    i.putExtra("appInfo", appInfo.getComponentName());
    ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this, Pair.create((View) mFabButton, "fab"), Pair.create(appIcon, "appIcon"));
    startActivity(i, transitionActivityOptions.toBundle());
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 88 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project GeometricWeather by WangDaYeeeeee.

the class IntentHelper method startSearchActivityForResult.

public static void startSearchActivityForResult(GeoActivity geoActivity, View bar) {
    Intent intent = new Intent(geoActivity, SearcActivity.class);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        geoActivity.startActivityForResult(intent, ManageActivity.SEARCH_ACTIVITY);
        geoActivity.overridePendingTransition(R.anim.activity_search_in, 0);
    } else {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(geoActivity, Pair.create(bar, geoActivity.getString(R.string.transition_activity_search_bar)));
        ActivityCompat.startActivityForResult(geoActivity, intent, ManageActivity.SEARCH_ACTIVITY, options.toBundle());
    }
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 89 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project ARouter by alibaba.

the class MainActivity method onClick.

/**
 * Called when a view has been clicked.
 *
 * @param v The view that was clicked.
 */
@Override
public void onClick(View v) {
    // Build test data.
    TestSerializable testSerializable = new TestSerializable("Titanic", 555);
    TestParcelable testParcelable = new TestParcelable("jack", 666);
    TestObj testObj = new TestObj("Rose", 777);
    List<TestObj> objList = new ArrayList<>();
    objList.add(testObj);
    Map<String, List<TestObj>> map = new HashMap<>();
    map.put("testMap", objList);
    switch(v.getId()) {
        case R.id.openLog:
            ARouter.openLog();
            break;
        case R.id.openDebug:
            ARouter.openDebug();
            break;
        case R.id.init:
            // 调试模式不是必须开启,但是为了防止有用户开启了InstantRun,但是
            // 忘了开调试模式,导致无法使用Demo,如果使用了InstantRun,必须在
            // 初始化之前开启调试模式,但是上线前需要关闭,InstantRun仅用于开
            // 发阶段,线上开启调试模式有安全风险,可以使用BuildConfig.DEBUG
            // 来区分环境
            ARouter.openDebug();
            ARouter.init(getApplication());
            break;
        case R.id.normalNavigation:
            ARouter.getInstance().build("/test/activity2").navigation();
            // Entrance.redirect2Test1Activity("张飞", 48, this);
            break;
        case R.id.kotlinNavigation:
            ARouter.getInstance().build("/kotlin/test").withString("name", "老王").withInt("age", 23).navigation();
            break;
        case R.id.normalNavigationWithParams:
            // ARouter.getInstance()
            // .build("/test/activity2")
            // .withString("key1", "value1")
            // .navigation();
            Uri testUriMix = Uri.parse("arouter://m.aliyun.com/test/activity2");
            ARouter.getInstance().build(testUriMix).withString("key1", "value1").navigation();
            break;
        case R.id.oldVersionAnim:
            ARouter.getInstance().build("/test/activity2").withTransition(R.anim.slide_in_bottom, R.anim.slide_out_bottom).navigation(this);
            break;
        case R.id.newVersionAnim:
            if (Build.VERSION.SDK_INT >= 16) {
                ActivityOptionsCompat compat = ActivityOptionsCompat.makeScaleUpAnimation(v, v.getWidth() / 2, v.getHeight() / 2, 0, 0);
                ARouter.getInstance().build("/test/activity2").withOptionsCompat(compat).navigation();
            } else {
                Toast.makeText(this, "API < 16,不支持新版本动画", Toast.LENGTH_SHORT).show();
            }
            break;
        case R.id.interceptor:
            ARouter.getInstance().build("/test/activity4").navigation(this, new NavCallback() {

                @Override
                public void onArrival(Postcard postcard) {
                }

                @Override
                public void onInterrupt(Postcard postcard) {
                    Log.d("ARouter", "被拦截了");
                }
            });
            break;
        case R.id.navByUrl:
            ARouter.getInstance().build("/test/webview").withString("url", "file:///android_asset/scheme-test.html").navigation();
            break;
        case R.id.autoInject:
            ARouter.getInstance().build("/test/activity1").withString("name", "老王").withInt("age", 18).withBoolean("boy", true).withLong("high", 180).withString("url", "https://a.b.c").withSerializable("ser", testSerializable).withParcelable("pac", testParcelable).withObject("obj", testObj).withObject("objList", objList).withObject("map", map).navigation();
            break;
        case R.id.navByName:
            ((HelloService) ARouter.getInstance().build("/yourservicegroupname/hello").navigation()).sayHello("mike");
            break;
        case R.id.navByType:
            ARouter.getInstance().navigation(HelloService.class).sayHello("mike");
            break;
        case R.id.navToMoudle1:
            ARouter.getInstance().build("/module/1").navigation();
            break;
        case R.id.navToMoudle2:
            // 这个页面主动指定了Group名
            ARouter.getInstance().build("/module/2", "m2").navigation();
            break;
        case R.id.destroy:
            ARouter.getInstance().destroy();
            break;
        case R.id.failNav:
            ARouter.getInstance().build("/xxx/xxx").navigation(this, new NavCallback() {

                @Override
                public void onFound(Postcard postcard) {
                    Log.d("ARouter", "找到了");
                }

                @Override
                public void onLost(Postcard postcard) {
                    Log.d("ARouter", "找不到了");
                }

                @Override
                public void onArrival(Postcard postcard) {
                    Log.d("ARouter", "跳转完了");
                }

                @Override
                public void onInterrupt(Postcard postcard) {
                    Log.d("ARouter", "被拦截了");
                }
            });
            break;
        case R.id.callSingle:
            ARouter.getInstance().navigation(SingleService.class).sayHello("Mike");
            break;
        case R.id.failNav2:
            ARouter.getInstance().build("/xxx/xxx").navigation();
            break;
        case R.id.failNav3:
            ARouter.getInstance().navigation(MainActivity.class);
            break;
        case R.id.normalNavigation2:
            ARouter.getInstance().build("/test/activity2").navigation(this, 666);
            break;
        case R.id.getFragment:
            Fragment fragment = (Fragment) ARouter.getInstance().build("/test/fragment").withString("name", "老王").withInt("age", 18).withBoolean("boy", true).withLong("high", 180).withString("url", "https://a.b.c").withSerializable("ser", testSerializable).withParcelable("pac", testParcelable).withObject("obj", testObj).withObject("objList", objList).withObject("map", map).navigation();
            Toast.makeText(this, "找到Fragment:" + fragment.toString(), Toast.LENGTH_SHORT).show();
            break;
        case R.id.addGroup:
            ARouter.getInstance().addRouteGroup(new IRouteGroup() {

                @Override
                public void loadInto(Map<String, RouteMeta> atlas) {
                    atlas.put("/dynamic/activity", RouteMeta.build(RouteType.ACTIVITY, TestDynamicActivity.class, "/dynamic/activity", "dynamic", 0, 0));
                }
            });
            break;
        case R.id.dynamicNavigation:
            // 该页面未配置 Route 注解,动态注册到 ARouter
            ARouter.getInstance().build("/dynamic/activity").withString("name", "老王").withInt("age", 18).withBoolean("boy", true).withLong("high", 180).withString("url", "https://a.b.c").withSerializable("ser", testSerializable).withParcelable("pac", testParcelable).withObject("obj", testObj).withObject("objList", objList).withObject("map", map).navigation(this);
            break;
        default:
            break;
    }
}
Also used : IRouteGroup(com.alibaba.android.arouter.facade.template.IRouteGroup) RouteMeta(com.alibaba.android.arouter.facade.model.RouteMeta) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HelloService(com.alibaba.android.arouter.demo.service.HelloService) TestObj(com.alibaba.android.arouter.demo.service.model.TestObj) NavCallback(com.alibaba.android.arouter.facade.callback.NavCallback) Uri(android.net.Uri) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Fragment(android.support.v4.app.Fragment) Postcard(com.alibaba.android.arouter.facade.Postcard) SingleService(com.alibaba.android.arouter.demo.module1.testservice.SingleService) TestSerializable(com.alibaba.android.arouter.demo.service.model.TestSerializable) TestParcelable(com.alibaba.android.arouter.demo.service.model.TestParcelable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 90 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project animate by hitherejoe.

the class SharedTransitionsActivity method startSharedTransition.

@OnClick(R.id.text_shared_transition)
public void startSharedTransition(View view) {
    Intent intent = new Intent(SharedTransitionsActivity.this, SharedTransitionInToolbarActivity.class);
    intent.putExtra(TransitionInActivity.EXTRA_TRANSITION, TransitionInActivity.TRANSITION_FADE_FAST);
    Pair participants = new Pair<>(view, ViewCompat.getTransitionName(view));
    ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(SharedTransitionsActivity.this, participants);
    ActivityCompat.startActivity(SharedTransitionsActivity.this, intent, transitionActivityOptions.toBundle());
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair) OnClick(butterknife.OnClick)

Aggregations

ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)94 Intent (android.content.Intent)74 View (android.view.View)32 Pair (android.support.v4.util.Pair)18 RecyclerView (android.support.v7.widget.RecyclerView)15 Activity (android.app.Activity)14 ImageView (android.widget.ImageView)14 TextView (android.widget.TextView)13 OnClick (butterknife.OnClick)7 ActivityOptions (android.app.ActivityOptions)4 Context (android.content.Context)4 Bundle (android.os.Bundle)4 Handler (android.os.Handler)4 BindView (butterknife.BindView)4 CardView (android.support.v7.widget.CardView)3 Explode (android.transition.Explode)3 AdapterView (android.widget.AdapterView)3 LinearLayout (android.widget.LinearLayout)3 Uri (android.net.Uri)2 LayoutInflater (android.view.LayoutInflater)2