android.support.v4.app.SharedElementCallback Java Examples
The following examples show how to use
android.support.v4.app.SharedElementCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SourceActivity.java From SETransitionDemo with Apache License 2.0 | 6 votes |
@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; } }); }
Example #2
Source File: AboutActivity.java From NewsMe with Apache License 2.0 | 5 votes |
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); } }); }
Example #3
Source File: ViewerActivity.java From NewsMe with Apache License 2.0 | 5 votes |
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()); } }); }
Example #4
Source File: GankMeiziFragment.java From MoeQuest with Apache License 2.0 | 5 votes |
@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); } } }); }
Example #5
Source File: DestinationActivity.java From SETransitionDemo with Apache License 2.0 | 5 votes |
@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); } }); }
Example #6
Source File: ViewerActivity.java From GankMeizhi with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportPostponeEnterTransition(); setContentView(R.layout.activity_viewer); ButterKnife.bind(this); index = getIntent().getIntExtra("index", 0); realm = Realm.getDefaultInstance(); realm.addChangeListener(this); images = Image.all(realm); puller.setCallback(this); adapter = new PagerAdapter(); pager.setAdapter(adapter); pager.setCurrentItem(index); // 避免图片在进行 Shared Element Transition 时盖过 Toolbar if (Build.VERSION.SDK_INT >= 21) { getWindow().setSharedElementsUseOverlay(false); } setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { Image image = images.get(pager.getCurrentItem()); sharedElements.clear(); sharedElements.put(image.getUrl(), adapter.getCurrent().getSharedElement()); } }); }
Example #7
Source File: FragmentPlugin.java From CompositeAndroid with Apache License 2.0 | 5 votes |
void setExitSharedElementCallback(final CallVoid1<SharedElementCallback> superCall, SharedElementCallback callback) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setExitSharedElementCallback(callback); } }
Example #8
Source File: FragmentPlugin.java From CompositeAndroid with Apache License 2.0 | 5 votes |
void setEnterSharedElementCallback(final CallVoid1<SharedElementCallback> superCall, SharedElementCallback callback) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setEnterSharedElementCallback(callback); } }
Example #9
Source File: CompositeFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setExitSharedElementCallback(SharedElementCallback callback) { delegate.setExitSharedElementCallback(callback); }
Example #10
Source File: PeriodicTableApplication.java From android-periodic-table with GNU General Public License v3.0 | 4 votes |
public void setSharedElementCallback(SharedElementCallback callback) { mSharedElementCallback = callback; }
Example #11
Source File: CompositeFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void super_setEnterSharedElementCallback(SharedElementCallback callback) { super.setEnterSharedElementCallback(callback); }
Example #12
Source File: CompositeFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void super_setExitSharedElementCallback(SharedElementCallback callback) { super.setExitSharedElementCallback(callback); }
Example #13
Source File: CompositeDialogFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setEnterSharedElementCallback(SharedElementCallback callback) { delegate.setEnterSharedElementCallback(callback); }
Example #14
Source File: CompositeDialogFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setExitSharedElementCallback(SharedElementCallback callback) { delegate.setExitSharedElementCallback(callback); }
Example #15
Source File: CompositeDialogFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void super_setEnterSharedElementCallback(SharedElementCallback callback) { super.setEnterSharedElementCallback(callback); }
Example #16
Source File: CompositeDialogFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void super_setExitSharedElementCallback(SharedElementCallback callback) { super.setExitSharedElementCallback(callback); }
Example #17
Source File: ToolListActivity.java From auid2 with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tool_list); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE); if (mToolType == null) { throw new IllegalStateException("ToolType not available as extra; use startActivity"); } setTitle(mToolType.getToolNameResourceId()); // Set up tabs mViewPager = (ViewPager) findViewById(R.id.viewpager); final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType); tabLayout.setTabsFromPagerAdapter(toolPagerAdapter); mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); mViewPager.setAdapter(toolPagerAdapter); tabLayout.setOnTabSelectedListener(this); // Handle animation from previous activity postponeEnterTransition(); mViewPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { mViewPager.getViewTreeObserver().removeOnPreDrawListener(this); startPostponedEnterTransition(); return true; } }); setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { if (mViewPager.getCurrentItem() != 0) { // Not displaying the about page, which has the hero image names.clear(); sharedElements.clear(); } } }); }
Example #18
Source File: ToolListActivity.java From auid2 with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tool_list); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE); if (mToolType == null) { throw new IllegalStateException("ToolType not available as extra; use startActivity"); } setTitle(mToolType.getToolNameResourceId()); // Set up tabs mViewPager = (ViewPager) findViewById(R.id.viewpager); final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType); tabLayout.setTabsFromPagerAdapter(toolPagerAdapter); mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); mViewPager.setAdapter(toolPagerAdapter); tabLayout.setOnTabSelectedListener(this); // Handle animation from previous activity postponeEnterTransition(); mViewPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { mViewPager.getViewTreeObserver().removeOnPreDrawListener(this); startPostponedEnterTransition(); return true; } }); setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { if (mViewPager.getCurrentItem() != 0) { // Not displaying the about page, which has the hero image names.clear(); sharedElements.clear(); } } }); }
Example #19
Source File: MainActivity.java From mr-mantou-android with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MiuiStatusBarCompat.enableLightStatusBar(getWindow()); binding = DataBindingUtil.setContentView(this, R.layout.main_activity); setSupportActionBar(binding.toolbar); images = MrSharedState.getInstance().getImages(); Glide.get(this).setMemoryCategory(MemoryCategory.HIGH); binding.content.setAdapter(new MainAdapter(this, images, Glide.with(this), this)); setExitSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { if (reenterState != null) { int index = reenterState.getInt("index", 0); Image image = images.get(index); MainAdapter.ViewHolder holder = (MainAdapter.ViewHolder) binding.content .findViewHolderForLayoutPosition(index); sharedElements.clear(); if (holder != null && holder.binding != null) { sharedElements.put(String.format("%s.image", image.getObjectId()), holder.binding.image); } reenterState = null; } } }); Observable<List<Image>> load = Observable.just(images) .doOnSubscribe(() -> binding.refresher.setRefreshing(true)) .doOnCompleted(() -> binding.refresher.setRefreshing(false)) .map(whatever -> images.isEmpty() ? Image.all() : Image.since(images.get(0))) .observeOn(Schedulers.io()) .flatMap(RxAVQuery::find) .observeOn(AndroidSchedulers.mainThread()) .doOnNext(RxList.prependTo(images)); RxSwipeRefreshLayout.refreshes(binding.refresher) .compose(bindToLifecycle()) .flatMap(whatever -> load) .retry((count, tr) -> { Log.e(TAG, "An error occurred while fetching images", tr); ToastUtil.shorts(this, tr.getMessage()); binding.refresher.setRefreshing(false); return true; }) .filter(loaded -> !loaded.isEmpty()) .subscribe(loaded -> binding.content.smoothScrollToPosition(0)); load.compose(bindToLifecycle()) .onErrorReturn(tr -> { Log.e(TAG, "An error occurred while fetching images", tr); ToastUtil.shorts(this, tr.getMessage()); binding.refresher.setRefreshing(false); return null; }) .subscribe(); UpdateUtil.checkForUpdate(version -> UpdateUtil.promptUpdate(this, version)); }
Example #20
Source File: PeriodicTableApplication.java From android-periodic-table with GNU General Public License v3.0 | 4 votes |
public SharedElementCallback getSharedElementCallback() { return mSharedElementCallback; }
Example #21
Source File: DialogFragmentDelegate.java From CompositeAndroid with Apache License 2.0 | 4 votes |
public void setExitSharedElementCallback(SharedElementCallback callback) { mFragmentDelegate.setExitSharedElementCallback(callback); }
Example #22
Source File: MeiziTuSimpleFragment.java From MoeQuest with Apache License 2.0 | 4 votes |
@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); } } }); }
Example #23
Source File: DoubanSimpleMeiziFragment.java From MoeQuest with Apache License 2.0 | 4 votes |
@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); } } }); }
Example #24
Source File: BlueprintActivity.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setEnterSharedElementCallback(SharedElementCallback callback) { super.setEnterSharedElementCallback(callback); }
Example #25
Source File: BlueprintActivity.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setExitSharedElementCallback(SharedElementCallback listener) { super.setExitSharedElementCallback(listener); }
Example #26
Source File: BlueprintFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setEnterSharedElementCallback(SharedElementCallback callback) { super.setEnterSharedElementCallback(callback); }
Example #27
Source File: BlueprintFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setExitSharedElementCallback(SharedElementCallback callback) { super.setExitSharedElementCallback(callback); }
Example #28
Source File: FragmentPlugin.java From CompositeAndroid with Apache License 2.0 | 4 votes |
public void setEnterSharedElementCallback(SharedElementCallback callback) { verifyMethodCalledFromDelegate("setEnterSharedElementCallback(SharedElementCallback)"); ((CallVoid1<SharedElementCallback>) mSuperListeners.pop()).call(callback); }
Example #29
Source File: CompositeFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setEnterSharedElementCallback(SharedElementCallback callback) { delegate.setEnterSharedElementCallback(callback); }
Example #30
Source File: DialogFragmentDelegate.java From CompositeAndroid with Apache License 2.0 | 4 votes |
public void setEnterSharedElementCallback(SharedElementCallback callback) { mFragmentDelegate.setEnterSharedElementCallback(callback); }