Java Code Examples for android.view.ViewGroup#getTag()
The following examples show how to use
android.view.ViewGroup#getTag() .
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: Scene.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Returns a Scene described by the resource file associated with the given * <code>layoutId</code> parameter. If such a Scene has already been created for * the given <code>sceneRoot</code>, that same Scene will be returned. * This caching of layoutId-based scenes enables sharing of common scenes * between those created in code and those referenced by {@link TransitionManager} * XML resource files. * * @param sceneRoot The root of the hierarchy in which scene changes * and transitions will take place. * @param layoutId The id of a standard layout resource file. * @param context The context used in the process of inflating * the layout resource. * @return The scene for the given root and layout id */ public static Scene getSceneForLayout(ViewGroup sceneRoot, int layoutId, Context context) { SparseArray<Scene> scenes = (SparseArray<Scene>) sceneRoot.getTag( com.android.internal.R.id.scene_layoutid_cache); if (scenes == null) { scenes = new SparseArray<Scene>(); sceneRoot.setTagInternal(com.android.internal.R.id.scene_layoutid_cache, scenes); } Scene scene = scenes.get(layoutId); if (scene != null) { return scene; } else { scene = new Scene(sceneRoot, layoutId, context); scenes.put(layoutId, scene); return scene; } }
Example 2
Source File: Scene.java From Transitions-Everywhere with Apache License 2.0 | 6 votes |
/** * Returns a Scene described by the resource file associated with the given * <code>layoutId</code> parameter. If such a Scene has already been created, * that same Scene will be returned. This caching of layoutId-based scenes enables * sharing of common scenes between those created in code and those referenced * by {@link TransitionManager} XML resource files. * * @param sceneRoot The root of the hierarchy in which scene changes * and transitions will take place. * @param layoutId The id of a standard layout resource file. * @param context The context used in the process of inflating * the layout resource. * @return */ @NonNull public static Scene getSceneForLayout(@NonNull ViewGroup sceneRoot, int layoutId, @NonNull Context context) { SparseArray<Scene> scenes = (SparseArray<Scene>) sceneRoot.getTag(R.id.scene_layoutid_cache); if (scenes == null) { scenes = new SparseArray<Scene>(); sceneRoot.setTag(R.id.scene_layoutid_cache, scenes); } Scene scene = scenes.get(layoutId); if (scene != null) { return scene; } else { scene = new Scene(sceneRoot, layoutId, context); scenes.put(layoutId, scene); return scene; } }
Example 3
Source File: ViewGroupAdapter.java From MVVM-JueJin with MIT License | 6 votes |
/** * (δΌͺ)εε databinding: ε {@link RecyclerViewAdapter#setDataTwoWay(RecyclerView, ListVM, List)} * * @param container * @param vm * @param datas * @param <T> */ @BindingAdapter({"vm", "data"}) public static <T> void setDataTwoWay(final ViewGroup container, final ListVM<T> vm, List<T> datas){ if(vm == null){ return ; } bind(container, vm, datas); if(vm instanceof TwoWayListVM){ boolean isInited = container.getTag(R.id.db_inited) != null; if(!isInited) { container.setTag(R.id.db_inited, true); loadData(container, (TwoWayListVM<T>)vm, null, null); } } }
Example 4
Source File: ThemeableActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 6 votes |
private static ArrayList<View> findViewsWithTag(String TAG, ViewGroup rootView, ArrayList<View> views) { Object tag = rootView.getTag(); if (tag != null && tag.equals(TAG)) { views.add(rootView); } for (int i = 0; i < rootView.getChildCount(); i++) { View v = rootView.getChildAt(i); tag = v.getTag(); if (tag != null && tag.equals(TAG)) { views.add(v); } if (v instanceof ViewGroup) { findViewsWithTag(TAG, (ViewGroup) v, views); } } return views; }
Example 5
Source File: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void reuseView(ViewGroup view) { if (view == null) { return; } int tag = (Integer) view.getTag(); view.setVisibility(View.GONE); if (tag == 1) { textViews.add(view); } else if (tag == 2) { imageViews.add(view); } else if (tag == 3) { audioViews.add(view); } }
Example 6
Source File: ListAdapter.java From GestureViews with Apache License 2.0 | 5 votes |
private void onImageClick(View image) { final ViewGroup parent = (ViewGroup) image.getParent(); final int itemPos = (int) parent.getTag(R.id.tag_item); final int imagePos = (int) image.getTag(R.id.tag_item); listener.onImageClick(itemPos, imagePos); }
Example 7
Source File: TransitionManager.java From Transitions-Everywhere with Apache License 2.0 | 5 votes |
@NonNull private static ArrayList<Transition> getRunningTransitions(@NonNull ViewGroup viewGroup) { ArrayList<Transition> transitions = (ArrayList<Transition>) viewGroup.getTag(R.id.runningTransitions); if (transitions == null) { transitions = new ArrayList<Transition>(); viewGroup.setTag(R.id.runningTransitions, transitions); } return transitions; }
Example 8
Source File: PopupNotificationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void reuseView(ViewGroup view) { if (view == null) { return; } int tag = (Integer) view.getTag(); view.setVisibility(View.GONE); if (tag == 1) { textViews.add(view); } else if (tag == 2) { imageViews.add(view); } else if (tag == 3) { audioViews.add(view); } }
Example 9
Source File: ChildrenAlphaProperty.java From material-components-android with Apache License 2.0 | 5 votes |
@NonNull @Override public Float get(@NonNull ViewGroup object) { Float alpha = (Float) object.getTag(R.id.mtrl_internal_children_alpha_tag); if (alpha != null) { return alpha; } else { return 1f; } }
Example 10
Source File: PopupNotificationActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void reuseView(ViewGroup view) { if (view == null) { return; } int tag = (Integer) view.getTag(); view.setVisibility(View.GONE); if (tag == 1) { textViews.add(view); } else if (tag == 2) { imageViews.add(view); } else if (tag == 3) { audioViews.add(view); } }
Example 11
Source File: PopupNotificationActivity.java From Yahala-Messenger with MIT License | 5 votes |
private void reuseView(ViewGroup view) { if (view == null) { return; } int tag = (Integer) view.getTag(); view.setVisibility(View.GONE); if (tag == 1) { textViews.add(view); } else if (tag == 2) { imageViews.add(view); } else if (tag == 3) { audioViews.add(view); } }
Example 12
Source File: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void reuseView(ViewGroup view) { if (view == null) { return; } int tag = (Integer) view.getTag(); view.setVisibility(View.GONE); if (tag == 1) { textViews.add(view); } else if (tag == 2) { imageViews.add(view); } else if (tag == 3) { audioViews.add(view); } }
Example 13
Source File: StatusBarCompat.java From GalleryLayoutManager with Apache License 2.0 | 4 votes |
/** * change to full screen mode * @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it */ public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) { Window window = activity.getWindow(); ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int statusBarHeight = getStatusBarHeight(activity); //First translucent status bar. window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //set child View not fill the system window View mChildView = mContentView.getChildAt(0); if (mChildView != null) { ViewCompat.setFitsSystemWindows(mChildView, false); //must call requestApplyInsets, otherwise it will have space in screen bottom ViewCompat.requestApplyInsets(mChildView); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //After LOLLIPOP just set LayoutParams. window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (hideStatusBarBackground) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(COLOR_TRANSLUCENT); } else { window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA)); } } else { ViewGroup mDecorView = (ViewGroup) window.getDecorView(); if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean) mDecorView.getTag()) { mChildView = mDecorView.getChildAt(0); //remove fake status bar view. mDecorView.removeView(mChildView); mChildView = mContentView.getChildAt(0); if (mChildView != null) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams(); //cancel the margin top if (lp != null && lp.topMargin >= statusBarHeight) { lp.topMargin -= statusBarHeight; mChildView.setLayoutParams(lp); } } mDecorView.setTag(false); } } } }
Example 14
Source File: StatusBarCompat.java From gank.io-unofficial-android-client with Apache License 2.0 | 4 votes |
/** * change to full screen mode * * @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it */ public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) { Window window = activity.getWindow(); ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT); //set child View not fill the system window View mChildView = mContentView.getChildAt(0); if (mChildView != null) { ViewCompat.setFitsSystemWindows(mChildView, false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int statusBarHeight = getStatusBarHeight(activity); //First translucent status bar. window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //After LOLLIPOP just set LayoutParams. window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (hideStatusBarBackground) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(COLOR_TRANSLUCENT); } else { window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA)); } //must call requestApplyInsets, otherwise it will have space in screen bottom if (mChildView != null) { ViewCompat.requestApplyInsets(mChildView); } } else { ViewGroup mDecorView = (ViewGroup) window.getDecorView(); if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean) mDecorView.getTag()) { mChildView = mDecorView.getChildAt(0); //remove fake status bar view. mContentView.removeView(mChildView); mChildView = mContentView.getChildAt(0); if (mChildView != null) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams(); //cancel the margin top if (lp != null && lp.topMargin >= statusBarHeight) { lp.topMargin -= statusBarHeight; mChildView.setLayoutParams(lp); } } mDecorView.setTag(false); } } } }
Example 15
Source File: ExpandableListItemAdapter.java From ListViewAnimations with Apache License 2.0 | 4 votes |
@Override @NonNull public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) { ViewGroup view = (ViewGroup) convertView; ViewHolder viewHolder; if (view == null) { view = createView(parent); viewHolder = new ViewHolder(); viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId); viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent); if (!titleView.equals(viewHolder.titleView)) { viewHolder.titleParent.removeAllViews(); viewHolder.titleParent.addView(titleView); if (mActionViewResId == 0) { view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } else { view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } } viewHolder.titleView = titleView; View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent); if (!contentView.equals(viewHolder.contentView)) { viewHolder.contentParent.removeAllViews(); viewHolder.contentParent.addView(contentView); } viewHolder.contentView = contentView; viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE); viewHolder.contentParent.setTag(getItemId(position)); LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; viewHolder.contentParent.setLayoutParams(layoutParams); return view; }
Example 16
Source File: StatusBarCompat.java From LeisureRead with Apache License 2.0 | 4 votes |
/** * change to full screen mode * * @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it */ public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) { Window window = activity.getWindow(); ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT); //set child View not fill the system window View mChildView = mContentView.getChildAt(0); if (mChildView != null) { ViewCompat.setFitsSystemWindows(mChildView, false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int statusBarHeight = getStatusBarHeight(activity); //First translucent status bar. window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //After LOLLIPOP just set LayoutParams. window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (hideStatusBarBackground) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(COLOR_TRANSLUCENT); } else { window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA)); } //must call requestApplyInsets, otherwise it will have space in screen bottom if (mChildView != null) { ViewCompat.requestApplyInsets(mChildView); } } else { ViewGroup mDecorView = (ViewGroup) window.getDecorView(); if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean) mDecorView.getTag()) { mChildView = mDecorView.getChildAt(0); //remove fake status bar view. mContentView.removeView(mChildView); mChildView = mContentView.getChildAt(0); if (mChildView != null) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams(); //cancel the margin top if (lp != null && lp.topMargin >= statusBarHeight) { lp.topMargin -= statusBarHeight; mChildView.setLayoutParams(lp); } } mDecorView.setTag(false); } } } }
Example 17
Source File: ExpandableListItemAdapter.java From UltimateAndroid with Apache License 2.0 | 4 votes |
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { ViewGroup view = (ViewGroup) convertView; ViewHolder viewHolder; if (view == null) { view = createView(parent); viewHolder = new ViewHolder(); viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId); viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent); if (titleView != viewHolder.titleView) { viewHolder.titleParent.removeAllViews(); viewHolder.titleParent.addView(titleView); if (mActionViewResId == 0) { view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } else { view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } } viewHolder.titleView = titleView; View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent); if (contentView != viewHolder.contentView) { viewHolder.contentParent.removeAllViews(); viewHolder.contentParent.addView(contentView); } viewHolder.contentView = contentView; viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE); viewHolder.contentParent.setTag(getItemId(position)); LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; viewHolder.contentParent.setLayoutParams(layoutParams); return view; }
Example 18
Source File: ExpandableListItemAdapter.java From android-open-project-demo with Apache License 2.0 | 4 votes |
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { ViewGroup view = (ViewGroup) convertView; ViewHolder viewHolder; if (view == null) { view = createView(parent); viewHolder = new ViewHolder(); viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId); viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent); if (titleView != viewHolder.titleView) { viewHolder.titleParent.removeAllViews(); viewHolder.titleParent.addView(titleView); if (mActionViewResId == 0) { view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } else { view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } } viewHolder.titleView = titleView; View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent); if (contentView != viewHolder.contentView) { viewHolder.contentParent.removeAllViews(); viewHolder.contentParent.addView(contentView); } viewHolder.contentView = contentView; viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE); viewHolder.contentParent.setTag(getItemId(position)); ViewGroup.LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; viewHolder.contentParent.setLayoutParams(layoutParams); return view; }
Example 19
Source File: ThemedActivity.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
public void setTranslucentStatusBar() { Window window = getWindow(); ViewGroup mContentView = findViewById(Window.ID_ANDROID_CONTENT); // set child View not fill the system window View mChildView = mContentView.getChildAt(0); if (mChildView != null) { mChildView.setFitsSystemWindows(false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int statusBarHeight = ViewUtils.getStatusBarHeight(this); // First translucent status bar. window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // After LOLLIPOP just set LayoutParams. window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(Color.TRANSPARENT); // must call requestApplyInsets, otherwise it will have space in screen bottom if (mChildView != null) { ViewCompat.requestApplyInsets(mChildView); } } else { ViewGroup mDecorView = (ViewGroup) window.getDecorView(); if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean)mDecorView.getTag()) { mChildView = mDecorView.getChildAt(0); // remove fake status bar view. mContentView.removeView(mChildView); mChildView = mContentView.getChildAt(0); if (mChildView != null) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams(); // cancel the margin top if (lp != null && lp.topMargin >= statusBarHeight) { lp.topMargin -= statusBarHeight; mChildView.setLayoutParams(lp); } } mDecorView.setTag(false); } } } }
Example 20
Source File: StatusBarCompat.java From youqu_master with Apache License 2.0 | 4 votes |
/** * change to full screen mode * @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it */ public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) { Window window = activity.getWindow(); ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT); //set child View not fill the system window View mChildView = mContentView.getChildAt(0); if (mChildView != null) { ViewCompat.setFitsSystemWindows(mChildView, false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int statusBarHeight = getStatusBarHeight(activity); //First translucent status bar. window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //After LOLLIPOP just set LayoutParams. window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (hideStatusBarBackground) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(COLOR_TRANSLUCENT); } else { window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA)); } //must call requestApplyInsets, otherwise it will have space in screen bottom if (mChildView != null) { ViewCompat.requestApplyInsets(mChildView); } } else { ViewGroup mDecorView = (ViewGroup) window.getDecorView(); if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean)mDecorView.getTag()) { mChildView = mDecorView.getChildAt(0); //remove fake status bar view. mContentView.removeView(mChildView); mChildView = mContentView.getChildAt(0); if (mChildView != null) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams(); //cancel the margin top if (lp != null && lp.topMargin >= statusBarHeight) { lp.topMargin -= statusBarHeight; mChildView.setLayoutParams(lp); } } mDecorView.setTag(false); } } } }