Java Code Examples for android.view.View#findViewWithTag()

The following examples show how to use android.view.View#findViewWithTag() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: android_9.0.0_r45   File: ListView.java    License: Apache License 2.0 6 votes vote down vote up
View findViewWithTagInHeadersOrFooters(ArrayList<FixedViewInfo> where, Object tag) {
    // Look in the passed in list of headers or footers for the view with
    // the tag.
    if (where != null) {
        int len = where.size();
        View v;

        for (int i = 0; i < len; i++) {
            v = where.get(i).view;

            if (!v.isRootNamespace()) {
                v = v.findViewWithTag(tag);

                if (v != null) {
                    return v;
                }
            }
        }
    }
    return null;
}
 
Example 2
Source Project: MCPDict   File: FavoriteCursorAdapter.java    License: MIT License 6 votes vote down vote up
public void expandItem(final char unicode, final View view, final ListView list) {
    expandedItems.add(unicode);
    if (view == null) return;
    final View container = view.findViewWithTag("container");
    final SearchResultFragment fragment = (SearchResultFragment) view.getTag();
    new AsyncTask<Void, Void, Cursor>() {
        @Override
        protected Cursor doInBackground(Void... params) {
            return MCPDatabase.directSearch(unicode);
        }
        @Override
        protected void onPostExecute(Cursor data) {
            fragment.setData(data);
            container.setVisibility(View.VISIBLE);
            if (list == null) return;
            scrollListToShowItem(list, view);
        }
    }.execute();
}
 
Example 3
Source Project: holo-calendar   File: CalendarView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public TextView getTextViewForDate(final long dayInMillis) {
    // Loop through all children
    final int childCount = getChildCount();
    for(int i = 0; i < childCount; i++) {
        final View weekLayout = getChildAt(i);
        if(weekLayout != null) {
            // Let the weekLayout find a view with a correct tag
            final View dayLayout = weekLayout.findViewWithTag(dayInMillis);
            if(dayLayout != null) {
                // Find the TextView, and return it
                return (TextView) dayLayout.findViewById(R.id.lib_calendar_day_text);
            }
        }
    }
    // No suitable TextView found, return null
    return null;
}
 
Example 4
Source Project: BlurView   File: BlurBehindView.java    License: Apache License 2.0 6 votes vote down vote up
private void printViewsBehind(ViewGroup rootView) {
    if (!this.isInEditMode() && !(rootView instanceof BlurBehindView) && rootView.getVisibility() == View.VISIBLE && rootView.getAlpha() != 0.0F) {
        if (rootView.getBackground() != null) {
            this.blurCanvas.save();
            this.blurCanvas.translate((float) (this.childPositionInWindow[0] - this.thisPositionInWindow[0] + this.halfPaddingOnSides), (float) (this.halfPaddingOnSides + this.childPositionInWindow[1] - this.thisPositionInWindow[1]));
            rootView.getBackground().draw(this.blurCanvas);
            this.blurCanvas.restore();
        }

        for (int i = 0; i < rootView.getChildCount(); ++i) {
            View childView = rootView.getChildAt(i);
            if (childView.findViewWithTag(TAG_VIEW) != null & rootView.getVisibility() == View.VISIBLE) {
                this.printViewsBehind((ViewGroup) childView);
            } else if (childView.getVisibility() == View.VISIBLE) {
                this.blurCanvas.save();
                childView.getLocationOnScreen(this.childPositionInWindow);
                this.blurCanvas.translate((float) (this.halfPaddingOnSides + this.childPositionInWindow[0] - this.thisPositionInWindow[0]), (float) (this.halfPaddingOnSides + this.childPositionInWindow[1] - this.thisPositionInWindow[1]));
                this.blurCanvas.scale(childView.getScaleX(), childView.getScaleY());
                childView.draw(this.blurCanvas);
                this.blurCanvas.restore();
            }
        }
    }
}
 
Example 5
@Override
public void onClick(View view) {

    // Extract day selected
    ViewGroup dayOfTheMonthContainer = (ViewGroup) view;
    String tagId = (String) dayOfTheMonthContainer.getTag();
    tagId = tagId.substring(DAY_OF_THE_MONTH_LAYOUT.length(), tagId.length());
    TextView dayOfTheMonthText = view.findViewWithTag(DAY_OF_THE_MONTH_TEXT + tagId);

    // Extract the day from the text
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, currentCalendar.get(Calendar.YEAR));
    calendar.set(Calendar.MONTH, currentCalendar.get(Calendar.MONTH));
    calendar.set(Calendar.DAY_OF_MONTH, Integer.valueOf(dayOfTheMonthText.getText().toString()));

    markDayAsSelectedDay(calendar.getTime());

    // Fire event
    if (robotoCalendarListener == null) {
        throw new IllegalStateException("You must assign a valid RobotoCalendarListener first!");
    } else {
        robotoCalendarListener.onDayClick(calendar.getTime());
    }
}
 
Example 6
@Override
public boolean onLongClick(View view) {

    // Extract day selected
    ViewGroup dayOfTheMonthContainer = (ViewGroup) view;
    String tagId = (String) dayOfTheMonthContainer.getTag();
    tagId = tagId.substring(DAY_OF_THE_MONTH_LAYOUT.length(), tagId.length());
    TextView dayOfTheMonthText = view.findViewWithTag(DAY_OF_THE_MONTH_TEXT + tagId);

    // Extract the day from the text
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, currentCalendar.get(Calendar.YEAR));
    calendar.set(Calendar.MONTH, currentCalendar.get(Calendar.MONTH));
    calendar.set(Calendar.DAY_OF_MONTH, Integer.valueOf(dayOfTheMonthText.getText().toString()));

    markDayAsSelectedDay(calendar.getTime());

    // Fire event
    if (robotoCalendarListener == null) {
        throw new IllegalStateException("You must assign a valid RobotoCalendarListener first!");
    } else {
        robotoCalendarListener.onDayLongClick(calendar.getTime());
    }
    return true;
}
 
Example 7
private void setWatermarkPadding(View view, int left, int top, int right, int bottom) {
  ImageView watermark = view.findViewWithTag("GoogleWatermark");
  // Watermark may be null if Maps failed to load.
  if (watermark == null) {
    return;
  }
  RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) watermark.getLayoutParams();
  params.setMargins(left, top, right, bottom);
  watermark.setLayoutParams(params);
}
 
Example 8
/**
 * Returns a {@code View} with a given tag.
 *
 * @param tag the <code>tag</code> of the {@code View} to be returned
 * @param index the index of the {@link View}. {@code 0} if only one is available
 * @param timeout the timeout in milliseconds
 * @return a {@code View} with a given tag if available, <code>null</code> otherwise
 */

public View getView(Object tag, int index, int timeout){
	//Because https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/View.java#L17005-L17007
	if(tag == null) {
		return null;
	}

	final Activity activity = activityUtils.getCurrentActivity(false);
	View viewToReturn = null;

	if(index < 1){
		index = 0;
		if(activity != null){
			//Using https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/Activity.java#L2070-L2072
			Window window = activity.getWindow();
			if(window != null) {
				View decorView = window.getDecorView();
				if(decorView != null) {
					viewToReturn = decorView.findViewWithTag(tag);
				}
			}
		}
	}

	if (viewToReturn != null) {
		return viewToReturn;
	}

	return waiter.waitForView(tag, index, timeout);
}
 
Example 9
Source Project: NCalendar   File: ViewUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static View getTargetView(Context context, View view) {
    View targetView = view.findViewWithTag(context.getString(R.string.N_factual_scroll_view));

    if (targetView != null && isViewVisible(targetView)) {
        return targetView;
    } else {
        try {
            traverseView(view);
        } catch (ViewUtil.ViewException e) {
            e.printStackTrace();
            return e.getExceptionView();
        }
    }
    return null;
}
 
Example 10
private void findViewsById(View view) {

        robotoCalendarMonthLayout = view.findViewById(R.id.robotoCalendarDateTitleContainer);
        leftButton = view.findViewById(R.id.leftButton);
        rightButton = view.findViewById(R.id.rightButton);
        dateTitle = view.findViewById(R.id.monthText);

        LayoutInflater inflate = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        for (int i = 0; i < 42; i++) {

            int weekIndex = (i % 7) + 1;
            ViewGroup dayOfTheWeekLayout = view.findViewWithTag(DAY_OF_THE_WEEK_LAYOUT + weekIndex);

            // Create day of the month
            View dayOfTheMonthLayout = inflate.inflate(R.layout.roboto_calendar_day_of_the_month_layout, null);
            View dayOfTheMonthText = dayOfTheMonthLayout.findViewWithTag(DAY_OF_THE_MONTH_TEXT);
            View dayOfTheMonthBackground = dayOfTheMonthLayout.findViewWithTag(DAY_OF_THE_MONTH_BACKGROUND);
            View dayOfTheMonthCircleImage1 = dayOfTheMonthLayout.findViewWithTag(DAY_OF_THE_MONTH_CIRCLE_IMAGE_1);
            View dayOfTheMonthCircleImage2 = dayOfTheMonthLayout.findViewWithTag(DAY_OF_THE_MONTH_CIRCLE_IMAGE_2);

            // Set tags to identify them
            int viewIndex = i + 1;
            dayOfTheMonthLayout.setTag(DAY_OF_THE_MONTH_LAYOUT + viewIndex);
            dayOfTheMonthText.setTag(DAY_OF_THE_MONTH_TEXT + viewIndex);
            dayOfTheMonthBackground.setTag(DAY_OF_THE_MONTH_BACKGROUND + viewIndex);
            dayOfTheMonthCircleImage1.setTag(DAY_OF_THE_MONTH_CIRCLE_IMAGE_1 + viewIndex);
            dayOfTheMonthCircleImage2.setTag(DAY_OF_THE_MONTH_CIRCLE_IMAGE_2 + viewIndex);

            dayOfTheWeekLayout.addView(dayOfTheMonthLayout);
        }
    }
 
Example 11
Source Project: MCPDict   File: FavoriteCursorAdapter.java    License: MIT License 5 votes vote down vote up
public void collapseItem(char unicode, View view, ListView list) {
    expandedItems.remove(unicode);
    if (view == null) return;
    View container = view.findViewWithTag("container");
    container.setVisibility(View.GONE);
    if (list == null) return;
    scrollListToShowItem(list, view);
}
 
Example 12
/**
 * Find and sets the BottomSheetHeader to manage colors
 * @param child
 */
private void setBottomSheetHeader(View child) {
    if (child instanceof BottomSheetBehaviorView) {
        View view = child.findViewWithTag(BottomSheetHeaderView.TAG);
        if (view != null && view instanceof BottomSheetHeaderView) {
            BottomSheetBehaviorView b = (BottomSheetBehaviorView) child;
            RNBottomSheetBehavior behavior = b.behavior;
            headerView = (BottomSheetHeaderView) view;
            headerView.registerFields();
            headerView.toggle(behavior.getState() == RNBottomSheetBehavior.STATE_COLLAPSED);
            behavior.setHeader(headerView);
        }
    }
}
 
Example 13
@Override
public void run() {
    View v;
    if( (v = mWeakView.get())==null){
        return;
    }
    View itemView = v.findViewWithTag(CustomSwipeListView.ITEMMAIN_LAYOUT_TAG);
    View swipeView = v.findViewWithTag(CustomSwipeListView.ITEMSWIPE_LAYOUT_TAG);
    if(swipeView.getHeight() != itemView.getHeight()) {
        swipeView.getLayoutParams().height = itemView.getHeight();
        swipeView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
        v.requestLayout();
    }
}
 
Example 14
public ViewHolder(View linearLayoutView) {
    super(linearLayoutView);
    image = (ImageView) linearLayoutView.findViewWithTag("image");
}
 
Example 15
@OnEvent(VisibleEvent.class)
static void onVisible(ComponentContext c, @Prop View rootView, @Prop Output<View> foundView) {
  final View view = rootView.findViewWithTag("test_vt");
  foundView.set(view);
}
 
Example 16
IconHolder(View itemView) {
    super(itemView);

    ivIcon = (ImageView) itemView.findViewWithTag("iv");
}
 
Example 17
CateHolder(View itemView) {
    super(itemView);

    tvCate = (TextView) itemView.findViewWithTag("cate");
    tvCount = (TextView) itemView.findViewWithTag("count");
}
 
Example 18
IconHolder(View itemView) {
    super(itemView);

    ivIcon = (ImageView) itemView.findViewWithTag("iv");
}
 
Example 19
public AAH_CustomViewHolder(View x) {
    super(x);
    aah_vi = (AAH_VideoImage) x.findViewWithTag("aah_vi");
}
 
Example 20
SectionViewHolder(View itemView) {
    super(itemView);
    this.titleView = (TextView) itemView.findViewWithTag("TITLE");
}