use of com.example.android.unsplash.ui.DetailSharedElementEnterCallback in project atlas by alibaba.
the class DetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_detail);
postponeEnterTransition();
TransitionSet transitions = new TransitionSet();
Slide slide = new Slide(Gravity.BOTTOM);
slide.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
transitions.addTransition(slide);
transitions.addTransition(new Fade());
getWindow().setEnterTransition(transitions);
Intent intent = getIntent();
sharedElementCallback = new DetailSharedElementEnterCallback(intent);
setEnterSharedElementCallback(sharedElementCallback);
try {
initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
} catch (NumberFormatException e) {
initialItem = 0;
}
PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {
@Override
public void success(ArrayList<Photo> photos) {
setUpViewPager(photos);
findViewById(android.R.id.empty).setVisibility(View.GONE);
}
@Override
public void error() {
finishAfterTransition();
}
});
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(navigationOnClickListener);
super.onCreate(savedInstanceState);
}
use of com.example.android.unsplash.ui.DetailSharedElementEnterCallback in project atlas by alibaba.
the class MainActivity method onActivityReenter.
@Override
public void onActivityReenter(int resultCode, Intent data) {
postponeEnterTransition();
// Start the postponed transition when the recycler view is ready to be drawn.
grid.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
grid.getViewTreeObserver().removeOnPreDrawListener(this);
startPostponedEnterTransition();
return true;
}
});
if (data == null) {
return;
}
final int selectedItem = data.getIntExtra(IntentUtil.INSTANCE.getSELECTED_ITEM_POSITION(), 0);
grid.scrollToPosition(selectedItem);
PhotoViewHolder holder = (PhotoViewHolder) grid.findViewHolderForAdapterPosition(selectedItem);
if (holder == null) {
Log.w(TAG, "onActivityReenter: Holder is null, remapping cancelled.");
return;
}
DetailSharedElementEnterCallback callback = new DetailSharedElementEnterCallback(getIntent());
callback.setView(holder.itemView);
setExitSharedElementCallback(callback);
}
Aggregations