Java 类android.support.v4.app.SharedElementCallback 实例源码

项目:SETransitionDemo    文件:SourceActivity.java   
@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;
        }
    });
}
项目:today-menu-android    文件:RestaurantActivity.java   
@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();
            }
        });
    }
}
项目:SETransitionDemo    文件:DestinationActivity.java   
@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);
        }
    });
}
项目:NewsMe    文件:AboutActivity.java   
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);
        }
    });
}
项目:NewsMe    文件:ViewerActivity.java   
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());
        }
    });
}
项目:MoeQuest    文件:GankMeiziFragment.java   
@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);
      }
    }
  });
}
项目:CompositeAndroid    文件:FragmentPlugin.java   
void setEnterSharedElementCallback(final CallVoid1<SharedElementCallback> superCall,
        final SharedElementCallback callback) {
    synchronized (mSuperListeners) {
        mSuperListeners.push(superCall);
        setEnterSharedElementCallback(callback);
    }
}
项目:CompositeAndroid    文件:FragmentPlugin.java   
void setExitSharedElementCallback(final CallVoid1<SharedElementCallback> superCall,
        final SharedElementCallback callback) {
    synchronized (mSuperListeners) {
        mSuperListeners.push(superCall);
        setExitSharedElementCallback(callback);
    }
}
项目:CompositeAndroid    文件:ActivityPlugin.java   
void setEnterSharedElementCallback(final CallVoid1<SharedElementCallback> superCall,
        final SharedElementCallback callback) {
    synchronized (mSuperListeners) {
        mSuperListeners.push(superCall);
        setEnterSharedElementCallback(callback);
    }
}
项目:CompositeAndroid    文件:ActivityPlugin.java   
void setEnterSharedElementCallback(final CallVoid1<android.app.SharedElementCallback> superCall,
        final android.app.SharedElementCallback callback) {
    synchronized (mSuperListeners) {
        mSuperListeners.push(superCall);
        setEnterSharedElementCallback(callback);
    }
}
项目:CompositeAndroid    文件:ActivityPlugin.java   
void setExitSharedElementCallback(final CallVoid1<SharedElementCallback> superCall,
        final SharedElementCallback listener) {
    synchronized (mSuperListeners) {
        mSuperListeners.push(superCall);
        setExitSharedElementCallback(listener);
    }
}
项目:CompositeAndroid    文件:ActivityPlugin.java   
void setExitSharedElementCallback(final CallVoid1<android.app.SharedElementCallback> superCall,
        final android.app.SharedElementCallback callback) {
    synchronized (mSuperListeners) {
        mSuperListeners.push(superCall);
        setExitSharedElementCallback(callback);
    }
}
项目:kickmaterial    文件:ProjectDetailsActivity.java   
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)));
    }
项目:kickmaterial    文件:ProjectDetailsActivity.java   
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);
        }
    });
}
项目:kickmaterial    文件:CategoriesListActivity.java   
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)));
}
项目:onyxbeacon-android-sdk    文件:ProjectDetailsActivity.java   
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)));
    }
项目:onyxbeacon-android-sdk    文件:ProjectDetailsActivity.java   
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);
        }
    });
}
项目:onyxbeacon-android-sdk    文件:CategoriesListActivity.java   
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)));
}
项目:MyAnimeViewer    文件:FavoritesFragment.java   
@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;
}
项目:MoeQuest    文件:MeiziTuSimpleFragment.java   
@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);
      }
    }
  });
}
项目:MoeQuest    文件:DoubanSimpleMeiziFragment.java   
@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);
      }
    }
  });
}
项目:CompositeAndroid    文件:BlueprintActivity.java   
@Override
public void setEnterSharedElementCallback(final SharedElementCallback callback) {
    super.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:BlueprintActivity.java   
@Override
public void setEnterSharedElementCallback(final android.app.SharedElementCallback callback) {
    super.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:BlueprintActivity.java   
@Override
public void setExitSharedElementCallback(final SharedElementCallback listener) {
    super.setExitSharedElementCallback(listener);
}
项目:CompositeAndroid    文件:BlueprintActivity.java   
@Override
public void setExitSharedElementCallback(final android.app.SharedElementCallback callback) {
    super.setExitSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:BlueprintFragment.java   
@Override
public void setEnterSharedElementCallback(final SharedElementCallback callback) {
    super.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:BlueprintFragment.java   
@Override
public void setExitSharedElementCallback(final SharedElementCallback callback) {
    super.setExitSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:FragmentPlugin.java   
public void setEnterSharedElementCallback(final SharedElementCallback callback) {
    verifyMethodCalledFromDelegate("setEnterSharedElementCallback(SharedElementCallback)");
    ((CallVoid1<SharedElementCallback>) mSuperListeners.pop()).call(callback);
}
项目:CompositeAndroid    文件:FragmentPlugin.java   
public void setExitSharedElementCallback(final SharedElementCallback callback) {
    verifyMethodCalledFromDelegate("setExitSharedElementCallback(SharedElementCallback)");
    ((CallVoid1<SharedElementCallback>) mSuperListeners.pop()).call(callback);
}
项目:CompositeAndroid    文件:DialogFragmentDelegate.java   
public void setEnterSharedElementCallback(final SharedElementCallback callback) {
    mFragmentDelegate.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:DialogFragmentDelegate.java   
public void setExitSharedElementCallback(final SharedElementCallback callback) {
    mFragmentDelegate.setExitSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeFragment.java   
@Override
public void setEnterSharedElementCallback(final SharedElementCallback callback) {
    delegate.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeFragment.java   
@Override
public void setExitSharedElementCallback(final SharedElementCallback callback) {
    delegate.setExitSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeFragment.java   
@Override
public void super_setEnterSharedElementCallback(final SharedElementCallback callback) {
    super.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeFragment.java   
@Override
public void super_setExitSharedElementCallback(final SharedElementCallback callback) {
    super.setExitSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeDialogFragment.java   
@Override
public void setEnterSharedElementCallback(final SharedElementCallback callback) {
    delegate.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeDialogFragment.java   
@Override
public void setExitSharedElementCallback(final SharedElementCallback callback) {
    delegate.setExitSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeDialogFragment.java   
@Override
public void super_setEnterSharedElementCallback(final SharedElementCallback callback) {
    super.setEnterSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeDialogFragment.java   
@Override
public void super_setExitSharedElementCallback(final SharedElementCallback callback) {
    super.setExitSharedElementCallback(callback);
}
项目:CompositeAndroid    文件:CompositeActivity.java   
@Override
public void setEnterSharedElementCallback(final SharedElementCallback callback) {
    delegate.setEnterSharedElementCallback(callback);
}