当前位置: 首页>>代码示例>>Java>>正文


Java SharedElementCallback类代码示例

本文整理汇总了Java中android.app.SharedElementCallback的典型用法代码示例。如果您正苦于以下问题:Java SharedElementCallback类的具体用法?Java SharedElementCallback怎么用?Java SharedElementCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SharedElementCallback类属于android.app包,在下文中一共展示了SharedElementCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupTransitions

import android.app.SharedElementCallback; //导入依赖的package包/类
private void setupTransitions() {
    // grab the position that the search icon transitions in *from*
    // & use it to configure the return transition
    setEnterSharedElementCallback(new SharedElementCallback() {
        @Override
        public void onSharedElementStart(
                List<String> sharedElementNames,
                List<View> sharedElements,
                List<View> sharedElementSnapshots) {
            if (sharedElements != null && !sharedElements.isEmpty()) {
                View searchIcon = sharedElements.get(0);
                if (searchIcon.getId() != R.id.searchback) return;
                int centerX = (searchIcon.getLeft() + searchIcon.getRight()) / 2;
                CircularReveal hideResults = (CircularReveal) TransitionUtils.findTransition(
                        (TransitionSet) getWindow().getReturnTransition(),
                        CircularReveal.class, R.id.results_container);
                if (hideResults != null) {
                    hideResults.setCenter(new Point(centerX, 0));
                }
            }
        }
    });
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:24,代码来源:SearchActivity.java

示例2: setCallback

import android.app.SharedElementCallback; //导入依赖的package包/类
@TargetApi(21)
private void setCallback(final int chosenPosition) {
    DataManager.getInstance().setPosition(chosenPosition);
    ((AppCompatActivity) context).setExitSharedElementCallback(new SharedElementCallback() {
        @Override
        public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
            int pos = DataManager.getInstance().getPosition();
            if (chosenPosition != pos && names.size() > 0) {
                sharedElements.put(names.get(0), contentViewCache.get(pos));
            }
            ((AppCompatActivity) context).setExitSharedElementCallback((SharedElementCallback) null);
        }
    });
}
 
开发者ID:mingdroid,项目名称:tumbviewer,代码行数:15,代码来源:PhotoPostVH.java

示例3: setSharedElementCallback

import android.app.SharedElementCallback; //导入依赖的package包/类
@TargetApi(21)
private void setSharedElementCallback(final View view) {
    SharedElementCallback callback = 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);
        }
    };
    setEnterSharedElementCallback(callback);
}
 
开发者ID:mingdroid,项目名称:tumbviewer,代码行数:14,代码来源:ImageViewerActivity.java

示例4: handleElementOnClick

import android.app.SharedElementCallback; //导入依赖的package包/类
@Override
void handleElementOnClick(final View view) {
	final int itemPosition =  getRecyclerView().getChildAdapterPosition(view);
	VideoOnDemand item = getElements().get(itemPosition);
	if (activity instanceof VODActivity) {
		((VODActivity) activity).startNewVOD(item);
	} else {
		Intent intent = VODActivity.createVODIntent(item, getContext());

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			intent.putExtra(getContext().getString(R.string.stream_preview_url), item.getMediumPreview());
			intent.putExtra(getContext().getString(R.string.stream_preview_alpha), hasVodBeenWatched(item.getVideoId()) ? VOD_WATCHED_IMAGE_ALPHA : 1.0f);

			final View sharedView = view.findViewById(R.id.image_stream_preview);
			sharedView.setTransitionName(getContext().getString(R.string.stream_preview_transition));
			final ActivityOptionsCompat options = ActivityOptionsCompat.
					makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.stream_preview_transition));

			activity.setExitSharedElementCallback(new SharedElementCallback() {
				@SuppressLint("NewApi")
				@Override
				public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
					super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

					sharedView.animate().alpha(VOD_WATCHED_IMAGE_ALPHA).setDuration(300).start();
					activity.setExitSharedElementCallback(null);
				}
			});

			activity.startActivity(intent, options.toBundle());
		} else {
			getContext().startActivity(intent);
			activity.overridePendingTransition(R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
		}
	}
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:37,代码来源:VODAdapter.java

示例5: setup

import android.app.SharedElementCallback; //导入依赖的package包/类
private void setup() {
    String name = getIntent().getStringExtra(KEY_ID);
    if (name != null) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names,
                                            Map<String, View> sharedElements) {
                sharedElements.put(ELEMENT_NAME, mImageView);
            }
        });
    }
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:13,代码来源:ActivityTransition.java

示例6: onCreateView

import android.app.SharedElementCallback; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_rv, null);

    mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view);
    int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.spacing_card);
    mRecyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels));
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 1));
    mRecyclerView.setHasFixedSize(true);


    setUpList();

    getActivity().setExitSharedElementCallback(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;
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:35,代码来源:RecentFragment.java

示例7: onCreateView

import android.app.SharedElementCallback; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_rv, null);
    mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view);
    int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.spacing_card);
    mRecyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels));
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    mRecyclerView.setHasFixedSize(true);
    setUpList();
    getActivity().setExitSharedElementCallback(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;
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:31,代码来源:AllFragment.java

示例8: createCallback

import android.app.SharedElementCallback; //导入依赖的package包/类
private static SharedElementCallback createCallback(SharedElementCallback21 callback) {
    SharedElementCallback newListener = null;
    if (callback != null) {
        newListener = new SharedElementCallbackImpl(callback);
    }
    return newListener;
}
 
开发者ID:GigigoGreenLabs,项目名称:permissionsModule,代码行数:8,代码来源:ActivityCompat21.java

示例9: setupTransitions

import android.app.SharedElementCallback; //导入依赖的package包/类
private void setupTransitions() {
    // grab the position that the search icon transitions in *from*
    // & use it to configure the return transition
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void onSharedElementStart(
                    List<String> sharedElementNames,
                    List<View> sharedElements,
                    List<View> sharedElementSnapshots) {
                if (sharedElements != null && !sharedElements.isEmpty()) {
                    View searchIcon = sharedElements.get(0);
                    if (searchIcon.getId() != R.id.searchback) return;
                    int centerX = (searchIcon.getLeft() + searchIcon.getRight()) / 2;
                    CircularReveal hideResults = (CircularReveal) TransitionUtils.findTransition(
                            (TransitionSet) getWindow().getReturnTransition(),
                            CircularReveal.class, R.id.results_container);
                    if (hideResults != null) {
                        hideResults.setCenter(new Point(centerX, 0));
                    }
                }
            }
        });
        // focus the search view once the transition finishes
        getWindow().getEnterTransition().addListener(
                new TransitionUtils.TransitionListenerAdapter() {
                    @Override
                    public void onTransitionEnd(Transition transition) {
                        searchView.requestFocus();
                        ImeUtils.showIme(searchView);
                    }
                });
    } else {
        searchView.requestFocus();
        ImeUtils.showIme(searchView);
    }
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:39,代码来源:SearchActivity.java

示例10: createSharedElementReenterCallback

import android.app.SharedElementCallback; //导入依赖的package包/类
public static SharedElementCallback createSharedElementReenterCallback(
        @NonNull Context context) {
    final String shotTransitionName = context.getString(R.string.transition_shot);
    final String shotBackgroundTransitionName =
            context.getString(R.string.transition_shot_background);
    return new SharedElementCallback() {

        /**
         * We're performing a slightly unusual shared element transition i.e. from one view
         * (image in the grid) to two views (the image & also the background of the details
         * view, to produce the expand effect). After changing orientation, the transition
         * system seems unable to map both shared elements (only seems to map the shot, not
         * the background) so in this situation we manually map the background to the
         * same view.
         */
        @Override
        public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
            if (sharedElements.size() != names.size()) {
                // couldn't map all shared elements
                final View sharedShot = sharedElements.get(shotTransitionName);
                if (sharedShot != null) {
                    // has shot so add shot background, mapped to same view
                    sharedElements.put(shotBackgroundTransitionName, sharedShot);
                }
            }
        }
    };
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:29,代码来源:FeedAdapter.java

示例11: clearSharedElementsOnReturn

import android.app.SharedElementCallback; //导入依赖的package包/类
static void clearSharedElementsOnReturn(@NonNull final BaseActivity activity) {
    activity.setEnterSharedElementCallback(new SharedElementCallback() {

        @Override
        public void onMapSharedElements(final List<String> names,
                final Map<String, View> sharedElements) {
            super.onMapSharedElements(names, sharedElements);
            if (activity.isFinishingAfterTransition()) {
                names.clear();
                sharedElements.clear();
            }
        }
    });
}
 
开发者ID:Doctoror,项目名称:PainlessMusicPlayer,代码行数:15,代码来源:TransitionUtils.java

示例12: initTransitions

import android.app.SharedElementCallback; //导入依赖的package包/类
private void initTransitions() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			postponeEnterTransition();
			setEnterSharedElementCallback(new SharedElementCallback() {
				@SuppressLint("NewApi")
				@Override
				public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
					super.onMapSharedElements(names, sharedElements);
					if (mAdapter.getRegisteredFragment(mPosition) != null) {
						names.clear();
						sharedElements.clear();
						View view = ((ImageFragment) mAdapter.getRegisteredFragment(mPosition)).mImage;
						names.add(view.getTransitionName());
						sharedElements.put(view.getTransitionName(), view);
					}
				}
			});
		}

//		mPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
//			@SuppressLint("NewApi")
//			public boolean onPreDraw() {
//				mPager.getViewTreeObserver().removeOnPreDrawListener(this);
//				startPostponedEnterTransition();
//				return true;
//			}
//		});
	}
 
开发者ID:imallan,项目名称:tuchong-daily-android,代码行数:29,代码来源:ImagePagerActivity.java

示例13: initTransitions

import android.app.SharedElementCallback; //导入依赖的package包/类
private void initTransitions() {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		setExitSharedElementCallback(new SharedElementCallback() {
			@SuppressLint("NewApi")
			@Override
			public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
				super.onMapSharedElements(names, sharedElements);
				if (!isReenterTransition) {
					return;
				}
				isReenterTransition = false;
				names.clear();
				sharedElements.clear();
				final PostFragment postFragment = (PostFragment) mAdapter.getRegisteredFragment(mPager.getCurrentItem());
				final RecyclerView recyclerView = postFragment.mRecyclerView;
				View sharedView =
						((PostImagesRecyclerViewAdapter.ViewHolder) recyclerView.findViewHolderForPosition(mImagePosition)).getImage();
				names.add(sharedView.getTransitionName());
				sharedElements.put(sharedView.getTransitionName(), sharedView);
			}
		});

		Fade fadeExit = new Fade();
		fadeExit.addTarget(R.id.text_post_title);
		fadeExit.addTarget(R.id.button_show_gallery);
		fadeExit.addTarget(R.id.recycler_post_images);
		fadeExit.addTarget(R.id.image_post_author);
		fadeExit.addTarget(R.id.bottom_shadow_post);
		fadeExit.addTarget(R.id.toolbar);
		getWindow().setExitTransition(fadeExit);
	}

}
 
开发者ID:imallan,项目名称:tuchong-daily-android,代码行数:34,代码来源:MainActivity.java

示例14: createSharedElementReenterCallback

import android.app.SharedElementCallback; //导入依赖的package包/类
static SharedElementCallback createSharedElementReenterCallback(
        @NonNull Context context) {
    final String shotTransitionName = context.getString(R.string.transition_shot);
    final String shotBackgroundTransitionName =
            context.getString(R.string.transition_shot_background);
    return new SharedElementCallback() {

        /**
         * We're performing a slightly unusual shared element transition i.e. from one view
         * (image in the grid) to two views (the image & also the background of the details
         * view, to produce the expand effect). After changing orientation, the transition
         * system seems unable to map both shared elements (only seems to map the shot, not
         * the background) so in this situation we manually map the background to the
         * same view.
         */
        @Override
        public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
            if (sharedElements.size() != names.size()) {
                // couldn't map all shared elements
                final View sharedShot = sharedElements.get(shotTransitionName);
                if (sharedShot != null) {
                    // has shot so add shot background, mapped to same view
                    sharedElements.put(shotBackgroundTransitionName, sharedShot);
                }
            }
        }
    };
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:29,代码来源:FeedAdapter.java

示例15: setupHero

import android.app.SharedElementCallback; //导入依赖的package包/类
private void setupHero() {
    String name = getIntent().getStringExtra(KEY_ID);
    mHero = null;
    if (name != null) {
        mHero = (ImageView) findViewById(getIdForKey(name));
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names,
                    Map<String, View> sharedElements) {
                sharedElements.put("hero", mHero);
            }
        });
    }
}
 
开发者ID:luoqii,项目名称:ApkLauncher,代码行数:15,代码来源:ActivityTransition.java


注:本文中的android.app.SharedElementCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。