List of usage examples for android.view ViewGroup getChildAt
public View getChildAt(int index)
From source file:cn.mailchat.view.PagerSlidingTabStrip.java
/** * ?????view//from ww w . ja v a 2s . c o m * @param position ??0 * @return ???view */ public View getCurrentTargetView(int position) { ViewGroup viewGroup = (ViewGroup) tabsContainer.getChildAt(position); View view = viewGroup.getChildAt(1); return view; }
From source file:com.taobao.weex.ui.component.WXVContainer.java
/** * transverse view tree, and recycle wximageview in container * *//*from w w w. ja v a 2 s .c o m*/ private void doViewTreeRecycleImageView(ViewGroup viewGroup, boolean isRelease) { int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { View view = viewGroup.getChildAt(i); if (view instanceof WXImageView) { if (isRelease) { ((WXImageView) view).autoReleaseImage(); } else { ((WXImageView) view).autoRecoverImage(); } } else if (view instanceof ViewGroup) { doViewTreeRecycleImageView((ViewGroup) view, isRelease); } } }
From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java
private View findCanScrollView(View v) { if (v instanceof ViewGroup) { ViewGroup target = (ViewGroup) v; if ((target instanceof UltraViewPager || target instanceof RecyclerView) && target.getVisibility() == View.VISIBLE) { return target; } else {//from w w w. j av a 2 s . co m for (int i = 0; i < target.getChildCount(); ++i) { View view = findCanScrollView(target.getChildAt(i)); if (view != null) { return view; } } return null; } } else { return null; } }
From source file:de.janniskilian.xkcdreader.presentation.components.showcomics.ShowComicsActivity.java
@Override public void startSearchMode(boolean animate) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (animate) { final View actionMenuView = toolbar.getChildAt(1); final ViewGroup actionMenuViewGroup = (ViewGroup) actionMenuView; final View addButton = actionMenuViewGroup.getChildAt(0); searchButtonCenter = new Point( (int) (addButton.getX() + actionMenuView.getX() + addButton.getWidth() / 2), (int) (addButton.getY() + actionMenuView.getY() + addButton.getHeight() / 2)); final Animator animator = ViewAnimationUtils.createCircularReveal(searchToolbar, searchButtonCenter.x, searchButtonCenter.y, 0, searchToolbar.getWidth()); animator.setDuration(revealStatusBarDuration); animator.addListener(new StartSearchModeAnimationListener(toolbar)); searchToolbar.setVisibility(View.VISIBLE); animator.start();// w w w.j a v a 2 s .c o m } else { searchToolbar.setVisibility(View.VISIBLE); } setSupportActionBar(searchToolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeAsUpIndicator(tintedBackArrow); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.toolbar_search); } } else { toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.background)); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeAsUpIndicator(tintedBackArrow); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.toolbar_search); } invalidateOptionsMenu(); } searchInput = (EditText) findViewById(R.id.search_input); searchInput.requestFocus(); searchInputSub = RxTextView.textChangeEvents(searchInput) .debounce(searchInputDebounceDuration, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()).subscribe(textViewTextChangeEvent -> { presenter.onSearchInputChanged(textViewTextChangeEvent.text().toString()); }); searchInputLengthSub = RxTextView.textChangeEvents(searchInput).observeOn(AndroidSchedulers.mainThread()) .subscribe(textViewTextChangeEvent -> { presenter.onSearchInputLengthChanged(textViewTextChangeEvent.text().toString(), textViewTextChangeEvent.count()); }); searchInput.setOnEditorActionListener((textView, actionId, keyEvent) -> { if (actionId == EditorInfo.IME_ACTION_SEARCH) { Utils.hideKeyboard(ShowComicsActivity.this); return true; } return false; }); Utils.showKeyboard(this); searchResults.setVisibility(View.VISIBLE); if (animate) { searchResults.animate().alpha(1).setDuration(crossfadeViewPagerSearchDuration).setListener(null); viewPager.animate().alpha(0).setDuration(crossfadeViewPagerSearchDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { viewPager.setVisibility(View.GONE); } }); } else { searchResults.setAlpha(1); viewPager.setAlpha(0); viewPager.setVisibility(View.GONE); } }
From source file:com.tr4android.support.extension.picker.date.DayPickerView.java
public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePickerDialog, defStyleAttr, 0); //TODO: add default style res final int firstDayOfWeek = a.getInt(R.styleable.DatePickerDialog_firstDayOfWeek, Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek()); final String minDate = a.getString(R.styleable.DatePickerDialog_minDate); final String maxDate = a.getString(R.styleable.DatePickerDialog_maxDate); final int monthTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_monthTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_Month); final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_weekDayTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_DayOfWeek); final int dayTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_dateTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_Day); // Set up day selected color, if available. final ColorStateList daySelectorColor; if (a.hasValue(R.styleable.DatePickerDialog_daySelectorColor)) { daySelectorColor = a.getColorStateList(R.styleable.DatePickerDialog_daySelectorColor); } else {//from www . j a va2s . c o m final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlActivated }); daySelectorColor = ta.getColorStateList(0); ta.recycle(); } // Set up day highlight color, if available. final ColorStateList dayHighlightColor; if (a.hasValue(R.styleable.DatePickerDialog_dayHighlightColor)) { dayHighlightColor = a.getColorStateList(R.styleable.DatePickerDialog_dayHighlightColor); } else { final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlHighlight }); dayHighlightColor = ta.getColorStateList(0); ta.recycle(); } a.recycle(); // Set up adapter. mAdapter = new DayPickerPagerAdapter(context, R.layout.day_picker_month_item_material, R.id.month_view); mAdapter.setMonthTextAppearance(monthTextAppearanceResId); mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId); mAdapter.setDayTextAppearance(dayTextAppearanceResId); mAdapter.setDaySelectorColor(daySelectorColor); mAdapter.setDayHighlightColor(dayHighlightColor); final LayoutInflater inflater = LayoutInflater.from(context); final ViewGroup content = (ViewGroup) inflater.inflate(DEFAULT_LAYOUT, this, false); // Transfer all children from content to here. while (content.getChildCount() > 0) { final View child = content.getChildAt(0); content.removeViewAt(0); addView(child); } mPrevButton = (ImageButton) findViewById(R.id.prev); mPrevButton.setOnClickListener(mOnClickListener); mNextButton = (ImageButton) findViewById(R.id.next); mNextButton.setOnClickListener(mOnClickListener); mViewPager = (ViewPager) findViewById(R.id.day_picker_view_pager); mViewPager.setAdapter(mAdapter); mViewPager.addOnPageChangeListener(mOnPageChangedListener); // Set up background of the previous and next buttons. ViewCompatUtils.setBackground(mPrevButton, PickerThemeUtils.getNavButtonBackground(context)); ViewCompatUtils.setBackground(mNextButton, PickerThemeUtils.getNavButtonBackground(context)); // Set up min and max dates. final Calendar tempDate = Calendar.getInstance(); if (!parseDate(minDate, tempDate)) { tempDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1); } final long minDateMillis = tempDate.getTimeInMillis(); if (!parseDate(maxDate, tempDate)) { tempDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31); } final long maxDateMillis = tempDate.getTimeInMillis(); if (maxDateMillis < minDateMillis) { throw new IllegalArgumentException("maxDate must be >= minDate"); } final long setDateMillis = MathUtils.constrain(System.currentTimeMillis(), minDateMillis, maxDateMillis); setFirstDayOfWeek(firstDayOfWeek); setMinDate(minDateMillis); setMaxDate(maxDateMillis); setDate(setDateMillis, false); // Proxy selection callbacks to our own listener. mAdapter.setOnDaySelectedListener(new DayPickerPagerAdapter.OnDaySelectedListener() { @Override public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) { if (mOnDaySelectedListener != null) { mOnDaySelectedListener.onDaySelected(DayPickerView.this, day); } } }); }
From source file:com.pluscubed.velociraptor.settings.SettingsActivity.java
private void enableDisableAllChildren(boolean enable, ViewGroup viewgroup) { for (int i = 0; i < viewgroup.getChildCount(); i++) { View child = viewgroup.getChildAt(i); child.setEnabled(enable);/* w w w. jav a2s .c o m*/ if (child instanceof ViewGroup) { enableDisableAllChildren(enable, (ViewGroup) child); } } }
From source file:com.mfh.framework.uikit.widget.SideSlidingTabStrip.java
/** * ViewPager/*from w w w . j a v a2 s. c o m*/ * * @param viewPager * ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { ViewGroup tabsLayout = getTabsLayout(); if (position < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(position); if (view != null) { currentPosition = position; currentPositionOffset = positionOffset; scrollToChild(position, (int) (positionOffset * view.getWidth())); invalidate(); } } if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } } @Override public void onPageSelected(int position) { // ZLogger.d("Main onPageSelected " + position); selectedTab(position); if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(position); } if (listener != null) listener.onChanged(position); } @Override public void onPageScrollStateChanged(int state) { if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(state); } } }); // //deprecated // this.viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { // @Override // public void onPageSelected(int position) { // selectedTab(position); // if (onPageChangeListener != null) { // onPageChangeListener.onPageSelected(position); // } // if (listener != null) // listener.onChanged(position); // } // // @Override // public void onPageScrolled(int nextPagePosition, // float positionOffset, int positionOffsetPixels) { // ViewGroup tabsLayout = getTabsLayout(); // if (nextPagePosition < tabsLayout.getChildCount()) { // View view = tabsLayout.getChildAt(nextPagePosition); // if (view != null) { // currentPosition = nextPagePosition; // currentPositionOffset = positionOffset; // scrollToChild(nextPagePosition, // (int) (positionOffset * view.getWidth())); // invalidate(); // } // } // if (onPageChangeListener != null) { // onPageChangeListener.onPageScrolled(nextPagePosition, // positionOffset, positionOffsetPixels); // } // } // // @Override // public void onPageScrollStateChanged(int arg0) { // if (onPageChangeListener != null) { // onPageChangeListener.onPageScrollStateChanged(arg0); // } // } // }); requestLayout(); }
From source file:android.support.v7.internal.view.menu.BaseMenuPresenter.java
/** * Reuses item views when it can//from w w w . j a va 2s. c om */ public void updateMenuView(boolean cleared) { final ViewGroup parent = (ViewGroup) mMenuView; if (parent == null) return; int childIndex = 0; if (mMenu != null) { mMenu.flagActionItems(); ArrayList<MenuItemImpl> visibleItems = mMenu.getVisibleItems(); final int itemCount = visibleItems.size(); for (int i = 0; i < itemCount; i++) { MenuItemImpl item = visibleItems.get(i); if (shouldIncludeItem(childIndex, item)) { final View convertView = parent.getChildAt(childIndex); final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ? ((MenuView.ItemView) convertView).getItemData() : null; final View itemView = getItemView(item, convertView, parent); if (item != oldItem) { // Don't let old states linger with new data. itemView.setPressed(false); ViewCompat.jumpDrawablesToCurrentState(itemView); } if (itemView != convertView) { addItemView(itemView, childIndex); } childIndex++; } } } // Remove leftover views. while (childIndex < parent.getChildCount()) { if (!filterLeftoverView(parent, childIndex)) { childIndex++; } } }
From source file:com.lgh.tool.myview.PagerSlidingTabStrip.java
/** * ?TAB/*from ww w . ja v a 2 s .c om*/ */ private void selectedTab(int newSelectedTabPosition) { ViewGroup tabsLayout = getTabsLayout(); if (newSelectedTabPosition > -1 && tabsLayout != null && newSelectedTabPosition < tabsLayout.getChildCount()) { for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) { View tabView = tabsLayout.getChildAt(w); tabView.setSelected(w == newSelectedTabPosition); } } }
From source file:com.summer.lib.view.pinnedheaderexpandablelistview.expandable.ui.PinnedHeaderExpandableListView.java
private View getTouchTarget(View view, int x, int y) { if (!(view instanceof ViewGroup)) { return view; }/*from www . j a v a 2 s . c o m*/ ViewGroup parent = (ViewGroup) view; int childrenCount = parent.getChildCount(); final boolean customOrder = isChildrenDrawingOrderEnabled(); View target = null; for (int i = childrenCount - 1; i >= 0; i--) { final int childIndex = customOrder ? getChildDrawingOrder(childrenCount, i) : i; final View child = parent.getChildAt(childIndex); if (isTouchPointInView(child, x, y)) { target = child; break; } } if (target == null) { target = parent; } return target; }