@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; }
private void onBindImages(ImagesViewHolder holder, ListItem item, int pos) { // Computing number of hidden images, starting with no visible images int hidden = item.paintings == null ? 0 : item.paintings.size(); // Going through all available image views for (int i = 0, size = holder.images.length; i < size; i++) { // Getting painting for current position (if there is one) final Painting painting = item.paintings != null && i < item.paintings.size() ? item.paintings.get(i) : null; if (painting == null) { // No more paintings, hiding current image holder.images[i].setVisibility(View.GONE); } else { // Showing painting's image for current position holder.images[i].setVisibility(View.VISIBLE); GlideHelper.loadThumb(holder.images[i], painting.thumbId); hidden--; } } // Displaying number of hidden paintings, if any final String countText = "+" + hidden; holder.count.setText(countText); holder.count.setVisibility(hidden > 0 ? View.VISIBLE : View.GONE); holder.row.setTag(R.id.tag_item, pos); }
/** * 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; } }
mStatusBarView.setBackgroundColor(statusColor); mDecorView.addView(mStatusBarView, 0); mDecorView.setTag(true);
@Override public void setTag(int key, Object tag) { super.setTag(key, tag); if (key == R.id.component_node_info && tag != null) { refreshAccessibilityDelegatesIfNeeded(isAccessibilityEnabled(getContext())); if (mComponentAccessibilityDelegate != null) { mComponentAccessibilityDelegate.setNodeInfo((NodeInfo) tag); } } }
@Test public void shouldNotFindViewWithTagReturnNull() { root.removeAllViews(); child1.setTag("tag1"); child2.setTag("tag2"); child3.setTag("tag3"); root.addView(child1); root.addView(child2); root.addView(child3, 1); assertThat((View) root.findViewWithTag("tag21")).isNull(); assertThat((ViewGroup) root.findViewWithTag("tag23")).isNull(); }
mDecorView.setTag(false);
@Test public void shouldFindViewWithTag() { root.removeAllViews(); child1.setTag("tag1"); child2.setTag("tag2"); child3.setTag("tag3"); root.addView(child1); root.addView(child2); root.addView(child3, 1); assertThat((View) root.findViewWithTag("tag1")).isSameAs(child1); assertThat((View) root.findViewWithTag("tag2")).isSameAs((View) child2); assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameAs(child3); }
sl = new Common(); lv.setOnScrollListener(sl); parent.setTag(AQuery.TAG_SCROLL_LISTENER, sl);
@Test public void shouldfindViewWithTagFromCorrectViewGroup() { root.removeAllViews(); child1.setTag("tag1"); child2.setTag("tag2"); child3.setTag("tag3"); root.addView(child1); root.addView(child2); root.addView(child3); child3a.setTag("tag1"); child3b.setTag("tag2"); //can find views by tag from root assertThat((View) root.findViewWithTag("tag1")).isSameAs(child1); assertThat((View) root.findViewWithTag("tag2")).isSameAs((View) child2); assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameAs(child3); //can find views by tag from child3 assertThat((View) child3.findViewWithTag("tag1")).isSameAs(child3a); assertThat((View) child3.findViewWithTag("tag2")).isSameAs(child3b); }
LayoutTransition layoutTransition = group.getLayoutTransition(); if (layoutTransition != null && layoutTransition != sEmptyLayoutTransition) { group.setTag(R.id.group_layouttransition_backup, group.getLayoutTransition()); group.getTag(R.id.group_layouttransition_backup); if (layoutTransition != null) { group.setTag(R.id.group_layouttransition_backup, null); group.setLayoutTransition(layoutTransition);
... View root = inflater.inflate(R.layout.fragment_page, container, false); ViewGroup ref = (ViewGroup)root.findViewById(R.id.fragment_reference); ref.setTag(this); ref.getChildAt(0).setTag("fragment:" + pageIndex); return root;
... View root = inflater.inflate(R.layout.fragment_page, container, false); ViewGroup ref = (ViewGroup)root.findViewById(R.id.fragment_reference); ref.setTag(this); ref.getChildAt(0).setTag("fragment:" + pageIndex); return root;
public void removeMyNoteView(ViewGroup parent) { boolean isMynoteTextEdit = isMyNoteViewShowing(parent); if (isMynoteTextEdit) { parent.setTag(""); parent.removeView(myNoteText); mainActivity.unregisterForContextMenu(myNoteText); } }
public void addMyNoteView(ViewGroup parent) { boolean isMynoteTextEdit = isMyNoteViewShowing(parent); parent.setTag(TAG); if (!isMynoteTextEdit) { parent.addView(myNoteText); mainActivity.registerForContextMenu(myNoteText); } }
ViewGroup inflateVideoView(ViewGroup container) { ViewGroup v = ItemViewUtil.inflateVideoView(container); v.setTag(albumItem.getPath()); this.itemView = v; return v; }
ViewGroup inflatePhotoView(ViewGroup container) { ViewGroup v = ItemViewUtil.inflatePhotoView(container); v.setTag(albumItem.getPath()); this.itemView = v; return v; }
private TraversalState ensureTag(ViewGroup container) { TraversalState traversalState = (TraversalState) container.getTag(tagKey); if (traversalState == null) { traversalState = new TraversalState(); container.setTag(tagKey, traversalState); } return traversalState; } }
@NonNull private View initViews(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.introduction_fragment, container, false); ViewGroup contentContainer = root.findViewById(R.id.introduction_fragment_content_container); if (slide.getCustomViewBuilder() == null) { contentContainer.addView(initDefaultViews(inflater, container)); } else { contentContainer.addView(slide.getCustomViewBuilder().buildView(inflater, container)); } root.setBackgroundColor(slide.getColor()); root.setTag(slide.getPosition()); return root; }
protected void initView( LayoutInflater layoutInflater, ViewGroup parentView ) { // container if ( mIsArray ){ // create array container view mContainer = (ViewGroup) layoutInflater.inflate( R.layout.container_for_array, parentView, false ); // spinner for array size initSpinner( layoutInflater.getContext(), MAX_ARRAY_SIZE ); } else { mContainer = (ViewGroup)getItemView( layoutInflater, parentView, generateLabel(-1) ); } mContainer.setTag( this ); }