Search in sources :

Example 1 with ActivityOptions

use of android.app.ActivityOptions in project UltimateAndroid by cymcsg.

the class MaterialAnimationActivity method setupLayout.

private void setupLayout() {
    sceneRoot = (LinearLayout) findViewById(R.id.scene_root);
    squareRed = findViewById(R.id.square_red);
    squareRed.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(MaterialAnimationActivity.this, DetailActivity1.class);
            ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation(MaterialAnimationActivity.this);
            startActivity(i, transitionActivityOptions.toBundle());
        }
    });
    squareBlue = findViewById(R.id.square_blue);
    squareBlue.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(MaterialAnimationActivity.this, DetailActivity2.class);
            View sharedView = squareBlue;
            String transitionName = "square_blue_name";
            ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation(MaterialAnimationActivity.this, sharedView, transitionName);
            startActivity(i, transitionActivityOptions.toBundle());
        }
    });
    squareGreen = findViewById(R.id.square_green);
    squareGreen.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TransitionManager.beginDelayedTransition(sceneRoot);
            setViewWidth(squareRed, 500);
            setViewWidth(squareBlue, 500);
            setViewWidth(squareGreen, 500);
            setViewWidth(squareOrange, 500);
        }
    });
    squareOrange = findViewById(R.id.square_orange);
    squareOrange.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(MaterialAnimationActivity.this, DetailActivity3.class);
            View sharedView = squareOrange;
            String transitionName = "square_orange_name";
            ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation(MaterialAnimationActivity.this, sharedView, transitionName);
            startActivity(i, transitionActivityOptions.toBundle());
        }
    });
}
Also used : Intent(android.content.Intent) View(android.view.View) ActivityOptions(android.app.ActivityOptions)

Example 2 with ActivityOptions

use of android.app.ActivityOptions in project GeekNews by codeestX.

the class DailyFragment method initEventAndData.

@Override
protected void initEventAndData() {
    currentDate = DateUtil.getTomorrowDate();
    mAdapter = new DailyAdapter(mContext, mList);
    mAdapter.setOnItemClickListener(new DailyAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(int position, View shareView) {
            mPresenter.insertReadToDB(mList.get(position).getId());
            mAdapter.setReadState(position, true);
            if (mAdapter.getIsBefore()) {
                mAdapter.notifyItemChanged(position + 1);
            } else {
                mAdapter.notifyItemChanged(position + 2);
            }
            Intent intent = new Intent();
            intent.setClass(mContext, ZhihuDetailActivity.class);
            intent.putExtra("id", mList.get(position).getId());
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, shareView, "shareView");
            mContext.startActivity(intent, options.toBundle());
        }
    });
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (currentDate.equals(DateUtil.getTomorrowDate())) {
                mPresenter.getDailyData();
            } else {
                int year = Integer.valueOf(currentDate.substring(0, 4));
                int month = Integer.valueOf(currentDate.substring(4, 6));
                int day = Integer.valueOf(currentDate.substring(6, 8));
                CalendarDay date = CalendarDay.from(year, month - 1, day);
                RxBus.getDefault().post(date);
            }
        }
    });
    rvDailyList.setLayoutManager(new LinearLayoutManager(mContext));
    rvDailyList.setAdapter(mAdapter);
    ivProgress.start();
    mPresenter.getDailyData();
}
Also used : Intent(android.content.Intent) CalendarDay(com.prolificinteractive.materialcalendarview.CalendarDay) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) ProgressImageView(com.codeest.geeknews.widget.ProgressImageView) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ZhihuDetailActivity(com.codeest.geeknews.ui.zhihu.activity.ZhihuDetailActivity) DailyAdapter(com.codeest.geeknews.ui.zhihu.adapter.DailyAdapter) ActivityOptions(android.app.ActivityOptions)

Example 3 with ActivityOptions

use of android.app.ActivityOptions in project GeekNews by codeestX.

the class HotFragment method initEventAndData.

@Override
protected void initEventAndData() {
    mList = new ArrayList<>();
    ivProgress.start();
    mAdapter = new HotAdapter(mContext, mList);
    rvHotContent.setVisibility(View.INVISIBLE);
    rvHotContent.setLayoutManager(new LinearLayoutManager(mContext));
    rvHotContent.setAdapter(mAdapter);
    mPresenter.getHotData();
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mPresenter.getHotData();
        }
    });
    mAdapter.setOnItemClickListener(new HotAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(int position, View shareView) {
            mPresenter.insertReadToDB(mList.get(position).getNews_id());
            mAdapter.setReadState(position, true);
            mAdapter.notifyItemChanged(position);
            Intent intent = new Intent();
            intent.setClass(mContext, ZhihuDetailActivity.class);
            intent.putExtra("id", mList.get(position).getNews_id());
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, shareView, "shareView");
            mContext.startActivity(intent, options.toBundle());
        }
    });
}
Also used : HotAdapter(com.codeest.geeknews.ui.zhihu.adapter.HotAdapter) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ProgressImageView(com.codeest.geeknews.widget.ProgressImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ZhihuDetailActivity(com.codeest.geeknews.ui.zhihu.activity.ZhihuDetailActivity) ActivityOptions(android.app.ActivityOptions)

Example 4 with ActivityOptions

use of android.app.ActivityOptions in project cw-omnibus by commonsguy.

the class FreecarTileService method onClick.

@Override
public void onClick() {
    super.onClick();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String cnFlat = prefs.getString(PREF_TO_LAUNCH, null);
    if (cnFlat != null) {
        ComponentName cn = ComponentName.unflattenFromString(cnFlat);
        try {
            ActivityInfo info = getPackageManager().getActivityInfo(cn, 0);
            ActivityInfo.WindowLayout layout = info.windowLayout;
            Intent i = new Intent().setComponent(cn).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Point size = new Point();
            getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getSize(size);
            if (layout == null) {
                size.x = size.x / 2;
                size.y = size.y / 2;
            } else {
                if (layout.widthFraction > 0.0f) {
                    size.x = Math.max(layout.minWidth, (int) (size.x * layout.widthFraction));
                } else {
                    size.x = layout.width;
                }
                if (layout.heightFraction > 0.0f) {
                    size.y = Math.max(layout.minHeight, (int) (size.y * layout.heightFraction));
                } else {
                    size.y = layout.height;
                }
            }
            ActivityOptions opts = ActivityOptions.makeBasic().setLaunchBounds(new Rect(0, 0, size.x, size.y));
            startActivity(i, opts.toBundle());
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "Exception trying to launch activity", e);
            toast(R.string.msg_sorry);
        }
    } else {
        toast(R.string.msg_choose);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Rect(android.graphics.Rect) SharedPreferences(android.content.SharedPreferences) ComponentName(android.content.ComponentName) Intent(android.content.Intent) Point(android.graphics.Point) ActivityOptions(android.app.ActivityOptions)

Example 5 with ActivityOptions

use of android.app.ActivityOptions in project GeekNews by codeestX.

the class GirlFragment method initEventAndData.

@Override
protected void initEventAndData() {
    mList = new ArrayList<>();
    mAdapter = new GirlAdapter(mContext, mList);
    mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(SPAN_COUNT, StaggeredGridLayoutManager.VERTICAL);
    mStaggeredGridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
    //fix issue #52 https://github.com/codeestX/GeekNews/issues/52
    mStaggeredGridLayoutManager.setItemPrefetchEnabled(false);
    rvGirlContent.setLayoutManager(mStaggeredGridLayoutManager);
    rvGirlContent.setAdapter(mAdapter);
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mPresenter.getGirlData();
        }
    });
    rvGirlContent.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int[] visibleItems = mStaggeredGridLayoutManager.findLastVisibleItemPositions(null);
            int lastItem = Math.max(visibleItems[0], visibleItems[1]);
            if (lastItem > mAdapter.getItemCount() - 5 && !isLoadingMore && dy > 0) {
                isLoadingMore = true;
                mPresenter.getMoreGirlData();
            }
        }
    });
    mAdapter.setOnItemClickListener(new GirlAdapter.OnItemClickListener() {

        @Override
        public void onItemClickListener(int position, View shareView) {
            Intent intent = new Intent();
            intent.setClass(mContext, GirlDetailActivity.class);
            intent.putExtra("url", mList.get(position).getUrl());
            intent.putExtra("id", mList.get(position).get_id());
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, shareView, "shareView");
            mContext.startActivity(intent, options.toBundle());
        }
    });
    ivProgress.start();
    mPresenter.getGirlData();
}
Also used : StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) Intent(android.content.Intent) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ProgressImageView(com.codeest.geeknews.widget.ProgressImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) GirlDetailActivity(com.codeest.geeknews.ui.gank.activity.GirlDetailActivity) GirlAdapter(com.codeest.geeknews.ui.gank.adapter.GirlAdapter) RecyclerView(android.support.v7.widget.RecyclerView) ActivityOptions(android.app.ActivityOptions)

Aggregations

ActivityOptions (android.app.ActivityOptions)178 Intent (android.content.Intent)88 RemoteException (android.os.RemoteException)33 Point (android.graphics.Point)30 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)20 TaskStack (com.android.systemui.recents.model.TaskStack)20 PendingIntent (android.app.PendingIntent)18 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 ActivityManager (android.app.ActivityManager)14 ComponentName (android.content.ComponentName)13 ActivityInfo (android.content.pm.ActivityInfo)13 ResolveInfo (android.content.pm.ResolveInfo)12 UserHandle (android.os.UserHandle)12 Configuration (android.content.res.Configuration)10 ReferrerIntent (com.android.internal.content.ReferrerIntent)10 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)10 Task (com.android.systemui.recents.model.Task)10 Bundle (android.os.Bundle)9 ActivityNotFoundException (android.content.ActivityNotFoundException)8 RecyclerView (android.support.v7.widget.RecyclerView)8