Java Code Examples for android.view.View.setSelected()

The following are Jave code examples for showing how to use setSelected() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: boohee_v5.6   File: SlidingTabLayout.java   Source Code and License Vote up 7 votes
public void onPageSelected(int position) {
    if (this.mScrollState == 0) {
        SlidingTabLayout.this.mTabStrip.onViewPagerPageChanged(position, 0.0f);
        SlidingTabLayout.this.scrollToTab(position, 0);
    }
    for (int i = 0; i < SlidingTabLayout.this.mTabStrip.getChildCount(); i++) {
        boolean z;
        View childAt = SlidingTabLayout.this.mTabStrip.getChildAt(i);
        if (position == i) {
            z = true;
        } else {
            z = false;
        }
        childAt.setSelected(z);
    }
    if (SlidingTabLayout.this.mViewPagerPageChangeListener != null) {
        SlidingTabLayout.this.mViewPagerPageChangeListener.onPageSelected(position);
    }
}
 
Example 2
Project: boohee_v5.6   File: IconPageIndicator.java   Source Code and License Vote up 7 votes
public void setCurrentItem(int item) {
    if (this.mViewPager == null) {
        throw new IllegalStateException("ViewPager has not been bound.");
    }
    this.mSelectedIndex = item;
    this.mViewPager.setCurrentItem(item);
    int tabCount = this.mIconsLayout.getChildCount();
    int i = 0;
    while (i < tabCount) {
        View child = this.mIconsLayout.getChildAt(i);
        boolean isSelected = i == item;
        child.setSelected(isSelected);
        if (isSelected) {
            animateToIcon(item);
        }
        i++;
    }
}
 
Example 3
Project: Hotspot-master-devp   File: TabPageIndicator.java   Source Code and License Vote up 7 votes
@Override
public void setCurrentItem(int item) {
    if (mViewPager == null) {
        throw new IllegalStateException("ViewPager has not been bound.");
    }
    mSelectedTabIndex = item;
    mViewPager.setCurrentItem(item);

    final int tabCount = mTabLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        final View child = mTabLayout.getChildAt(i);
        final boolean isSelected = (i == item);
        child.setSelected(isSelected);
        if (isSelected) {
            animateToTab(item);
        }
    }
}
 
Example 4
Project: letv   File: HotTabPageIndicator.java   Source Code and License Vote up 7 votes
public void setCurrentItem(int item) {
    if (this.mViewPager != null) {
        if (!(item == -1 || this.mSelectedTabIndex == item)) {
            this.mViewPager.setCurrentItem(item);
        }
        this.mSelectedTabIndex = item;
        int tabCount = this.mTabLayout.getChildCount();
        int i = 0;
        while (i < tabCount) {
            View child = this.mTabLayout.getChildAt(i);
            boolean isSelected = i == item;
            child.setSelected(isSelected);
            if (isSelected) {
                animateToTab(item);
                ((TabView) child).setTextColor(this.mContext.getResources().getColor(2131493202));
                child.setBackgroundResource(2130839011);
            } else {
                ((TabView) child).setTextColor(this.mContext.getResources().getColor(2131493237));
                child.setBackgroundDrawable(null);
            }
            i++;
        }
    }
}
 
Example 5
Project: Huochexing12306   File: TabPageIndicator.java   Source Code and License Vote up 7 votes
@Override
public void setCurrentItem(int item) {
    if (mViewPager == null) {
        throw new IllegalStateException("ViewPager has not been bound.");
    }
    mSelectedTabIndex = item;
    mViewPager.setCurrentItem(item);

    final int tabCount = mTabLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        final View child = mTabLayout.getChildAt(i);
        final boolean isSelected = (i == item);
        child.setSelected(isSelected);
        if (isSelected) {
            animateToTab(item);
        }
    }
}
 
Example 6
Project: android-project-gallery   File: TabPageIndicator.java   Source Code and License Vote up 7 votes
@Override
public void setCurrentItem(int item) {
    if (mViewPager == null) {
        throw new IllegalStateException("ViewPager has not been bound.");
    }
    mSelectedTabIndex = item;
    mViewPager.setCurrentItem(item);

    final int tabCount = mTabLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        final View child = mTabLayout.getChildAt(i);
        final boolean isSelected = (i == item);
        child.setSelected(isSelected);
        if (isSelected) {
            animateToTab(item);
        }
    }
}
 
Example 7
Project: renderingPerformance   File: Manager.java   Source Code and License Vote up 7 votes
private void init() {
    mDrawingBoardView = (DrawingBoardView) mCoverView.findViewById(R.id.drawingBoard);
    View btn = mCoverView.findViewById(R.id.on_off);
    btn.setSelected(false);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            v.setSelected(!v.isSelected());
            if (v.isSelected()) {
                mMetronome.post(mRhythm);
            } else {
                mMetronome.removeCallbacks(mRhythm);
                mPerformance.eraseColor(0);
                mDrawingBoardView.drawPerformance(mPerformance);
            }
        }
    });
}
 
Example 8
Project: Phial   File: ExpandedView.java   Source Code and License Vote up 6 votes
public void setSelected(Page selected) {
    final int childCount = iconsHolder.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = iconsHolder.getChildAt(i);
        final boolean isSelected = ObjectUtil.equals(child.getTag(), selected.getId());
        child.setSelected(isSelected);
        if (isSelected) {
            setupArrowPosition(child);
        }
    }
    setupPage(selected);
    title.setText(selected.getTitle());
}
 
Example 9
Project: ArcLayout-master   File: DemoLikePathActivity.java   Source Code and License Vote up 6 votes
private void onFabClick(View v) {
  if (v.isSelected()) {
    hideMenu();
  } else {
    showMenu();
  }
  v.setSelected(!v.isSelected());
}
 
Example 10
Project: letv   File: ChannelTabPageIndicator.java   Source Code and License Vote up 6 votes
public void setCurrentItem(int item) {
    if (this.mViewPager != null) {
        if (item != -1 || this.mSelectedTabIndex != item) {
            this.mSelectedTabIndex = item;
            int tabCount = this.mTabLayout.getChildCount();
            for (int i = 0; i < tabCount; i++) {
                RelativeLayout childLayout = (RelativeLayout) this.mTabLayout.getChildAt(i);
                for (int j = 0; j < childLayout.getChildCount(); j++) {
                    boolean isSelected;
                    if (i == item) {
                        isSelected = true;
                    } else {
                        isSelected = false;
                    }
                    View view = childLayout.getChildAt(j);
                    if (view instanceof TabView) {
                        view.setSelected(isSelected);
                        if (isSelected) {
                            animateToTab(item);
                        }
                    } else {
                        view.setSelected(isSelected);
                    }
                }
            }
            this.mViewPager.setCurrentItem(item, false);
        }
    }
}
 
Example 11
Project: MobileMedia   File: UnderLinePageIndicator.java   Source Code and License Vote up 6 votes
@Override
public void setCurrentItem(int item) {
	if (mViewPager == null) {
		throw new IllegalStateException("ViewPager has not been bound.");
	}
	mSelectedTabIndex = item;
	mViewPager.setCurrentItem(item);

	final int tabCount = mTabLayout.getChildCount();
	for (int i = 0; i < tabCount; i++) {
		final View child = mTabLayout.getChildAt(i);

		final boolean isSelected = (i == item);
		child.setSelected(isSelected);

		if (isSelected) {
			if (child instanceof TabView) {
				((TabView) child).text.setTextColor(selectedTextColor);
				((TabView) child).view.setVisibility(View.VISIBLE);
			}
			animateToTab(item);
		} else {
			if (child instanceof TabView) {
				((TabView) child).text.setTextColor(unSelectedTextColor);
				((TabView) child).view.setVisibility(View.GONE);
			}

		}
	}
}
 
Example 12
Project: FastAndroid   File: SingleCallActivity.java   Source Code and License Vote up 6 votes
private void initAudioCallView() {
    mLPreviewContainer.removeAllViews();
    mLPreviewContainer.setVisibility(View.GONE);
    mSPreviewContainer.removeAllViews();
    mSPreviewContainer.setVisibility(View.GONE);

    findViewById(R.id.rc_voip_call_information).setBackgroundColor(getResources().getColor(R.color.rc_voip_background_color));
    findViewById(R.id.rc_voip_audio_chat).setVisibility(View.GONE);

    View userInfoView = inflater.inflate(R.layout.rc_voip_audio_call_user_info, null);
    TextView timeView = (TextView) userInfoView.findViewById(R.id.rc_voip_call_remind_info);
    setupTime(timeView);

    mUserInfoContainer.removeAllViews();
    mUserInfoContainer.addView(userInfoView);
    UserInfo userInfo = RongContext.getInstance().getUserInfoFromCache(targetId);
    if (userInfo != null) {
        TextView userName = (TextView) mUserInfoContainer.findViewById(R.id.rc_voip_user_name);
        userName.setText(userInfo.getName());
        if (callSession.getMediaType().equals(RongCallCommon.CallMediaType.AUDIO)) {
            AsyncImageView userPortrait = (AsyncImageView) mUserInfoContainer.findViewById(R.id.rc_voip_user_portrait);
            if (userPortrait != null) {
                userPortrait.setAvatar(userInfo.getPortraitUri().toString(), R.drawable.rc_default_portrait);
            }
        }
    }
    mUserInfoContainer.setVisibility(View.VISIBLE);
    mUserInfoContainer.findViewById(R.id.rc_voip_call_minimize).setVisibility(View.VISIBLE);

    View button = inflater.inflate(R.layout.rc_voip_call_bottom_connected_button_layout, null);
    mButtonContainer.removeAllViews();
    mButtonContainer.addView(button);
    mButtonContainer.setVisibility(View.VISIBLE);
    View handFreeV = mButtonContainer.findViewById(R.id.rc_voip_handfree);
    handFreeV.setSelected(handFree);

    if (pickupDetector != null) {
        pickupDetector.register(this);
    }
}
 
Example 13
Project: FriendBook   File: ReaderSettingDialog.java   Source Code and License Vote up 6 votes
private void setPageMode(int pageMode) {
    View selectedView = null;
    switch (pageMode) {
        case PageView.PAGE_MODE_COVER:
            readTvFlipOverCover.setSelected(true);
            selectedView = readTvFlipOverCover;
            break;
        case PageView.PAGE_MODE_SIMULATION:
            readTvFlipOverSimulation.setSelected(true);
            selectedView = readTvFlipOverSimulation;
            break;
        case PageView.PAGE_MODE_SLIDE:
            readTvFlipOverSlide.setSelected(true);
            selectedView = readTvFlipOverSlide;
            break;
        case PageView.PAGE_MODE_NONE:
            readTvFlipOverNone.setSelected(true);
            selectedView = readTvFlipOverNone;
            break;
    }
    for (View view : flipOverViews) {
        if (view != selectedView && view.isSelected()) {
            view.setSelected(false);
        }
    }
    if (pageMode != mPageView.getPageMode()) {
        mPageView.setPageAnimMode(pageMode);
        ReaderSettingManager
                .getInstance()
                .setPageMode(pageMode);
    }

}
 
Example 14
Project: PicShow-zhaipin   File: RecyclerIndicatorView.java   Source Code and License Vote up 6 votes
private void updateSelectTab(int selectItem) {
    View preview = getItemView(preSelectItem);
    if (preview != null) {
        preview.setSelected(false);
    }
    View selectView = getItemView(selectItem);
    if (selectView != null) {
        selectView.setSelected(true);
    }
}
 
Example 15
Project: KUtils   File: SmartTabLayout.java   Source Code and License Vote up 6 votes
private void populateTabStrip() {
  final PagerAdapter adapter = viewPager.getAdapter();

  for (int i = 0; i < adapter.getCount(); i++) {

    final View tabView = (tabProvider == null)
        ? createDefaultTabView(adapter.getPageTitle(i))
        : tabProvider.createTabView(tabStrip, i, adapter);

    if (tabView == null) {
      throw new IllegalStateException("tabView is null.");
    }

    if (distributeEvenly) {
      LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
      lp.width = 0;
      lp.weight = 1;
    }

    if (internalTabClickListener != null) {
      tabView.setOnClickListener(internalTabClickListener);
    }

    tabStrip.addView(tabView);

    if (i == viewPager.getCurrentItem()) {
      tabView.setSelected(true);
    }

  }
}
 
Example 16
Project: FastAndroid   File: SingleCallActivity.java   Source Code and License Vote up 5 votes
public void onMuteButtonClick(View view) {
    RongCallClient.getInstance().setEnableLocalAudio(view.isSelected());
    view.setSelected(!view.isSelected());
    muted = view.isSelected();
}
 
Example 17
Project: FastAndroid   File: MultiVideoCallActivity.java   Source Code and License Vote up 5 votes
public void onMuteButtonClick(View view) {
    RongCallClient.getInstance().setEnableLocalAudio(view.isSelected());
    view.setSelected(!view.isSelected());
}
 
Example 18
Project: PlusGram   File: ActionBarMenuItem.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
            showMenuRunnable = new Runnable() {
                @Override
                public void run() {
                    if (getParent() != null) {
                        getParent().requestDisallowInterceptTouchEvent(true);
                    }
                    toggleSubMenu();
                }
            };
            AndroidUtilities.runOnUIThread(showMenuRunnable, 200);
        }
    } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
            if (event.getY() > getHeight()) {
                if (getParent() != null) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                }
                toggleSubMenu();
                return true;
            }
        } else if (popupWindow != null && popupWindow.isShowing()) {
            getLocationOnScreen(location);
            float x = event.getX() + location[0];
            float y = event.getY() + location[1];
            popupLayout.getLocationOnScreen(location);
            x -= location[0];
            y -= location[1];
            selectedMenuView = null;
            for (int a = 0; a < popupLayout.getItemsCount(); a++) {
                View child = popupLayout.getItemAt(a);
                child.getHitRect(rect);
                if ((Integer) child.getTag() < 100) {
                    if (!rect.contains((int) x, (int) y)) {
                        child.setPressed(false);
                        child.setSelected(false);
                        if (Build.VERSION.SDK_INT == 21) {
                            child.getBackground().setVisible(false, false);
                        }
                    } else {
                        child.setPressed(true);
                        child.setSelected(true);
                        if (Build.VERSION.SDK_INT >= 21) {
                            if (Build.VERSION.SDK_INT == 21) {
                                child.getBackground().setVisible(true, false);
                            }
                            child.drawableHotspotChanged(x, y - child.getTop());
                        }
                        selectedMenuView = child;
                    }
                }
            }
        }
    } else if (popupWindow != null && popupWindow.isShowing() && event.getActionMasked() == MotionEvent.ACTION_UP) {
        if (selectedMenuView != null) {
            selectedMenuView.setSelected(false);
            if (parentMenu != null) {
                parentMenu.onItemClick((Integer) selectedMenuView.getTag());
            } else if (delegate != null) {
                delegate.onItemClick((Integer) selectedMenuView.getTag());
            }
            popupWindow.dismiss(allowCloseAnimation);
        } else {
            popupWindow.dismiss();
        }
    } else {
        if (selectedMenuView != null) {
            selectedMenuView.setSelected(false);
            selectedMenuView = null;
        }
    }
    return super.onTouchEvent(event);
}
 
Example 19
Project: airgram   File: ActionBarMenuItem.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
            showMenuRunnable = new Runnable() {
                @Override
                public void run() {
                    if (getParent() != null) {
                        getParent().requestDisallowInterceptTouchEvent(true);
                    }
                    toggleSubMenu();
                }
            };
            AndroidUtilities.runOnUIThread(showMenuRunnable, 200);
        }
    } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
            if (event.getY() > getHeight()) {
                if (getParent() != null) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                }
                toggleSubMenu();
                return true;
            }
        } else if (popupWindow != null && popupWindow.isShowing()) {
            getLocationOnScreen(location);
            float x = event.getX() + location[0];
            float y = event.getY() + location[1];
            popupLayout.getLocationOnScreen(location);
            x -= location[0];
            y -= location[1];
            selectedMenuView = null;
            for (int a = 0; a < popupLayout.getItemsCount(); a++) {
                View child = popupLayout.getItemAt(a);
                child.getHitRect(rect);
                if ((Integer) child.getTag() < 100) {
                    if (!rect.contains((int) x, (int) y)) {
                        child.setPressed(false);
                        child.setSelected(false);
                        if (Build.VERSION.SDK_INT == 21) {
                            child.getBackground().setVisible(false, false);
                        }
                    } else {
                        child.setPressed(true);
                        child.setSelected(true);
                        if (Build.VERSION.SDK_INT >= 21) {
                            if (Build.VERSION.SDK_INT == 21) {
                                child.getBackground().setVisible(true, false);
                            }
                            child.drawableHotspotChanged(x, y - child.getTop());
                        }
                        selectedMenuView = child;
                    }
                }
            }
        }
    } else if (popupWindow != null && popupWindow.isShowing() && event.getActionMasked() == MotionEvent.ACTION_UP) {
        if (selectedMenuView != null) {
            selectedMenuView.setSelected(false);
            if (parentMenu != null) {
                parentMenu.onItemClick((Integer) selectedMenuView.getTag());
            } else if (delegate != null) {
                delegate.onItemClick((Integer) selectedMenuView.getTag());
            }
            popupWindow.dismiss(allowCloseAnimation);
        } else {
            popupWindow.dismiss();
        }
    } else {
        if (selectedMenuView != null) {
            selectedMenuView.setSelected(false);
            selectedMenuView = null;
        }
    }
    return super.onTouchEvent(event);
}
 
Example 20
Project: boohee_v5.6   File: PLA_ListView.java   Source Code and License Vote up 5 votes
private void setupChild(View child, int position, int y, boolean flowDown, int childrenLeft,
                        boolean selected, boolean recycled) {
    boolean isSelected = selected && shouldShowSelector();
    boolean updateChildSelected = isSelected != child.isSelected();
    int mode = this.mTouchMode;
    boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
    boolean updateChildPressed = isPressed != child.isPressed();
    boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    ViewGroup.LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        ViewGroup.LayoutParams layoutParams = new LayoutParams(-1, -2, 0);
    }
    p.viewType = this.mAdapter.getItemViewType(position);
    p.scrappedFromPosition = position;
    if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
        p.forceAdd = false;
        if (p.viewType == -2) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    } else {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (needToMeasure) {
        int childHeightSpec;
        int childWidthSpec = ViewGroup.getChildMeasureSpec(this.mWidthMeasureSpec, this
                .mListPadding.left + this.mListPadding.right, p.width);
        int lpHeight = p.height;
        if (lpHeight > 0) {
            childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, 1073741824);
        } else {
            childHeightSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        onMeasureChild(child, position, childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childTop = flowDown ? y : y - h;
    if (needToMeasure) {
        onLayoutChild(child, position, childrenLeft, childTop, childrenLeft + w, childTop + h);
    } else {
        onOffsetChild(child, position, childrenLeft - child.getLeft(), childTop - child
                .getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
}