本文整理汇总了Java中android.support.v4.app.SharedElementCallback类的典型用法代码示例。如果您正苦于以下问题:Java SharedElementCallback类的具体用法?Java SharedElementCallback怎么用?Java SharedElementCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SharedElementCallback类属于android.support.v4.app包,在下文中一共展示了SharedElementCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCallback
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
@TargetApi(21)
private void setCallback(final int enterPosition) {
this.enterPosition = enterPosition;
setExitSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
if (exitPosition != enterPosition &&
names.size() > 0 && exitPosition < sharedViews.length) {
names.clear();
sharedElements.clear();
View view = sharedViews[exitPosition];
names.add(view.getTransitionName());
sharedElements.put(view.getTransitionName(), view);
}
setExitSharedElementCallback((SharedElementCallback) null);
sharedViews = null;
}
});
}
示例2: onCreate
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_restaurant);
if (!getIntent().getExtras().containsKey(ARG_RESTAURANT)) {
throw new RuntimeException("Restaurant missing.");
}
mRestaurant = getIntent().getExtras().getParcelable(ARG_RESTAURANT);
ButterKnife.bind(this);
initToolbar();
Glide.with(this).load(mRestaurant.mCoverUrl).into(mCover);
initList();
initPresenter();
if (getIntent().getBooleanExtra(ARG_ANIMATION, false)) {
mFoodRecycler.setAlpha(0);
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
mFoodRecycler.animate().setDuration(500).alpha(1).start();
}
});
}
}
示例3: setSharedElementCallback
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
@TargetApi(21)
private void setSharedElementCallback(final View view) {
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
names.clear();
sharedElements.clear();
names.add(view.getTransitionName());
sharedElements.put(view.getTransitionName(), view);
}
});
}
示例4: initEnterSharedElement
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
private void initEnterSharedElement() {
ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
sharedElements.clear();
sharedElements.put(SHARE_IMAGE, getBinding().image);
}
});
}
示例5: initEnterSharedElement
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
private void initEnterSharedElement() {
ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
Image image = mImages[getBinding().pager.getCurrentItem()];
sharedElements.clear();
sharedElements.put(String.format("%s.image", image.url), getCurrent().getSharedElement());
}
});
}
示例6: initViews
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void initViews() {
showProgress();
realm = Realm.getDefaultInstance();
gankMeizis = realm.where(GankMeizi.class).findAll();
initRecycleView();
RxBus.getInstance().toObserverable(Intent.class)
.compose(this.bindToLifecycle())
.subscribe(intent -> {
imageIndex = intent.getIntExtra("index", -1);
scrollIndex();
finishTask();
}, throwable -> {
LogUtil.all(throwable.getMessage());
});
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
super.onMapSharedElements(names, sharedElements);
String newTransitionName = gankMeizis.get(imageIndex).getUrl();
View newSharedView = mRecyclerView.findViewWithTag(newTransitionName);
if (newSharedView != null) {
names.clear();
names.add(newTransitionName);
sharedElements.clear();
sharedElements.put(newTransitionName, newSharedView);
}
}
});
}
示例7: setEnterSharedElementCallback
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
void setEnterSharedElementCallback(final CallVoid1<SharedElementCallback> superCall,
final SharedElementCallback callback) {
synchronized (mSuperListeners) {
mSuperListeners.push(superCall);
setEnterSharedElementCallback(callback);
}
}
示例8: setExitSharedElementCallback
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
void setExitSharedElementCallback(final CallVoid1<SharedElementCallback> superCall,
final SharedElementCallback callback) {
synchronized (mSuperListeners) {
mSuperListeners.push(superCall);
setExitSharedElementCallback(callback);
}
}
示例9: setExitSharedElementCallback
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
void setExitSharedElementCallback(final CallVoid1<SharedElementCallback> superCall,
final SharedElementCallback listener) {
synchronized (mSuperListeners) {
mSuperListeners.push(superCall);
setExitSharedElementCallback(listener);
}
}
示例10: launchPostTransitionAnimations
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
private void launchPostTransitionAnimations() {
if (LUtils.hasL()) {
ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
binding.detailsContainer.postDelayed(() -> {
binding.detailsContainer.startAnimation(LUtils.loadAnimationWithLInterpolator(ProjectDetailsActivity.this, R.anim.slide_from_top));
binding.scrollView.startAnimation(LUtils.loadAnimationWithLInterpolator(ProjectDetailsActivity.this, R.anim.slide_from_top_long));
}, 0);
}
});
}
// categoriesRv.post(() -> categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_from_bottom)));
}
示例11: animateAlphaAfterTransition
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
private void animateAlphaAfterTransition(final View view) {
view.setAlpha(0);
ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
Animator alphaAnimator = AnimatorUtils.getAlphaAnimator(view);
alphaAnimator.setDuration(600);
alphaAnimator.start();
ActivityCompat.setEnterSharedElementCallback(ProjectDetailsActivity.this, null);
}
});
}
示例12: launchPostTransitionAnimations
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
private void launchPostTransitionAnimations() {
if (category != null) {
int color = ContextCompat.getColor(this, category.colorResId);
binding.categoryCircleIv.setColorFilter(color);
binding.selectedCategoryIv.setImageResource(category.drawableResId);
binding.selectCategoryTv.setBackgroundColor(color);
binding.selectCategoryTv.getBackground().setAlpha(85);
}
if (LUtils.hasL()) {
binding.closeCategoriesIv.setScaleX(0);
binding.closeCategoriesIv.setScaleY(0);
ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
binding.closeCategoriesIv.postDelayed(() -> {
// remove listener, we do not want to trigger this animation on exit
ActivityCompat.setEnterSharedElementCallback(CategoriesListActivity.this, null);
if (isFinishing()) {
return;
}
AnimatorSet closeCategoryAnim = AnimatorUtils.getScaleAnimator(binding.closeCategoriesIv, 0, 1);
closeCategoryAnim.setInterpolator(new OvershootInterpolator());
closeCategoryAnim.start();
}, 160);
}
});
}
binding.categoriesRv.post(() -> binding.categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_from_bottom)));
}
示例13: onCreateView
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// image_detail_fragment.xml contains just an ImageView
final View v = inflater.inflate(R.layout.anime_recycler_layout, container, false);
if (!BuildUtils.isHoneycombOrLater())
v.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor(v.getContext()));
mRecyclerView = (GridRecyclerView) v.findViewById(R.id.list);
if (mRecyclerView != null) {
mRecyclerView.setPopupTextColor(ThemeManager.getInstance().getTextColor());
mRecyclerView.setPopupBgColor(ThemeManager.getInstance().getPrimaryColor(v.getContext()));
mRecyclerView.setThumbColor(ThemeManager.getInstance().getPrimaryDarkColor(v.getContext()));
mRecyclerView.setTrackColor(ThemeManager.getInstance().getAccentColor(v.getContext()));
}
//mRecyclerView.setItemAnimator(AnimatorManager.getInstance().getAnimator());
mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_container);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(ThemeManager.getInstance().getAccentColorResId()));
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateFavorites();
}
});
}
ActivityCompat.setExitSharedElementCallback(getActivity(), new SharedElementCallback() {
@Override
public Parcelable onCaptureSharedElementSnapshot(View sharedElement, Matrix viewToGlobalMatrix, RectF screenBounds) {
int bitmapWidth = Math.round(screenBounds.width());
int bitmapHeight = Math.round(screenBounds.height());
Bitmap bitmap = null;
if (bitmapWidth > 0 && bitmapHeight > 0) {
Matrix matrix = new Matrix();
matrix.set(viewToGlobalMatrix);
matrix.postTranslate(-screenBounds.left, -screenBounds.top);
bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.concat(matrix);
sharedElement.draw(canvas);
}
return bitmap;
}
});
return v;
}
示例14: initViews
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
@Override
public void initViews() {
type = getArguments().getString(EXTRA_TYPE);
showProgress();
realm = Realm.getDefaultInstance();
meizis = realm.where(MeiziTu.class)
.equalTo("type", type)
.findAll();
initRecycleView();
RxBus.getInstance().toObserverable(Intent.class)
.compose(this.bindToLifecycle())
.subscribe(intent -> {
imageIndex = intent.getIntExtra("index", -1);
scrollIndex();
finishTask();
}, throwable -> {
LogUtil.all(throwable.getMessage());
});
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
super.onMapSharedElements(names, sharedElements);
String newTransitionName = meizis.get(imageIndex).getImageurl();
View newSharedView = mRecyclerView.findViewWithTag(newTransitionName);
if (newSharedView != null) {
names.clear();
names.add(newTransitionName);
sharedElements.clear();
sharedElements.put(newTransitionName, newSharedView);
}
}
});
}
示例15: initViews
import android.support.v4.app.SharedElementCallback; //导入依赖的package包/类
@Override
public void initViews() {
cid = getArguments().getInt(EXTRA_CID);
type = getArguments().getInt(EXTRA_TYPE);
showProgress();
realm = Realm.getDefaultInstance();
doubanMeizis = realm.where(DoubanMeizi.class)
.equalTo("type", type)
.findAll();
initRecycleView();
RxBus.getInstance().toObserverable(Intent.class)
.compose(this.bindToLifecycle())
.subscribe(intent -> {
imageIndex = intent.getIntExtra("index", -1);
scrollIndex();
finishTask();
}, throwable -> {
LogUtil.all(throwable.getMessage());
});
setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
super.onMapSharedElements(names, sharedElements);
String newTransitionName = doubanMeizis.get(imageIndex).getUrl();
View newSharedView = mRecyclerView.findViewWithTag(newTransitionName);
if (newSharedView != null) {
names.clear();
names.add(newTransitionName);
sharedElements.clear();
sharedElements.put(newTransitionName, newSharedView);
}
}
});
}