下面列出了android.view.View#setTagInternal ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* This method should be called when the {@link #startSharedElementAnimation(Window, Pair[])}
* animation must be stopped and the Views reset. This can happen if there was an error
* from startActivity or a springboard activity and the animation should stop and reset.
*
* @hide
*/
public static void stopSharedElementAnimation(Window window) {
final View decorView = window.getDecorView();
if (decorView == null) {
return;
}
final ExitTransitionCoordinator exit = (ExitTransitionCoordinator)
decorView.getTag(com.android.internal.R.id.cross_task_transition);
if (exit != null) {
exit.cancelPendingTransitions();
decorView.setTagInternal(com.android.internal.R.id.cross_task_transition, null);
TransitionManager.endTransitions((ViewGroup) decorView);
exit.resetViews();
exit.clearState();
decorView.setVisibility(View.VISIBLE);
}
}
public HideWindowListener(Window window, ExitTransitionCoordinator exit) {
mWindow = window;
mExit = exit;
mSharedElements = new ArrayList<>(exit.mSharedElements);
Transition transition = mWindow.getExitTransition();
if (transition != null) {
transition.addListener(this);
mWaitingForTransition = true;
} else {
mWaitingForTransition = false;
}
View decorView = mWindow.getDecorView();
if (decorView != null) {
if (decorView.getTag(com.android.internal.R.id.cross_task_transition) != null) {
throw new IllegalStateException(
"Cannot start a transition while one is running");
}
decorView.setTagInternal(com.android.internal.R.id.cross_task_transition, exit);
}
}
private void hideWhenDone() {
if (mSharedElementHidden && (!mWaitingForTransition || mTransitionEnded)) {
mExit.resetViews();
int numSharedElements = mSharedElements.size();
for (int i = 0; i < numSharedElements; i++) {
View view = mSharedElements.get(i);
view.requestLayout();
}
View decorView = mWindow.getDecorView();
if (decorView != null) {
decorView.setTagInternal(
com.android.internal.R.id.cross_task_transition, null);
decorView.setVisibility(View.GONE);
}
}
}
@Override
public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
final View target = root.findViewById(viewId);
if (target == null) return;
target.setTagInternal(R.id.remote_input_tag, remoteInputs);
}
/**
* Set the scene that the given view is in. The current scene is set only
* on the root view of a scene, not for every view in that hierarchy. This
* information is used by Scene to determine whether there is a previous
* scene which should be exited before the new scene is entered.
*
* @param view The view on which the current scene is being set
*/
static void setCurrentScene(View view, Scene scene) {
view.setTagInternal(com.android.internal.R.id.current_scene, scene);
}