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());
}
});
}
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();
}
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());
}
});
}
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);
}
}
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();
}
Aggregations