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

The following are Jave code examples for showing how to use isSelected() 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: FastAndroid   File: MultiVideoCallActivity.java   Source Code and License Vote up 7 votes
public void onDisableCameraBtnClick(View view) {
    TextView text = (TextView) bottomButtonContainer.findViewById(R.id.rc_voip_disable_camera_text);
    String currentUserId = RongIMClient.getInstance().getCurrentUserId();

    RongCallClient.getInstance().setEnableLocalVideo(view.isSelected());
    if (view.isSelected()) {
        text.setText(R.string.rc_voip_disable_camera);
        if (localViewUserId.equals(currentUserId)) {
            localView.setVisibility(View.VISIBLE);
        } else {
            remoteViewContainer.findViewWithTag(currentUserId).setVisibility(View.VISIBLE);
        }
    } else {
        text.setText(R.string.rc_voip_enable_camera);
        if (localViewUserId.equals(currentUserId)) {
            localView.setVisibility(View.GONE);
        } else {
            remoteViewContainer.findViewWithTag(currentUserId).setVisibility(View.GONE);
        }
    }
    view.setSelected(!view.isSelected());
}
 
Example 2
Project: Expert-Android-Programming   File: CollectionDetailActivity.java   Source Code and License Vote up 7 votes
public void selectChange(View view) {
    if (view.isSelected()) {
        view.setSelected(false);
    } else {
        view.setSelected(true);
    }

    if (view.getId() == R.id.saveButton) {
        int save;
        if (view.isSelected()) {
            ((TextView) view).setText("Saved");
            save = 1;
        } else {
            ((TextView) view).setText("Save");
            save = 0;
        }

        saveCollection(save);

        iconAnim(view);
    }

}
 
Example 3
Project: sealtalk-android-master   File: MultiVideoCallActivity.java   Source Code and License Vote up 7 votes
public void onDisableCameraBtnClick(View view) {
    TextView text = (TextView) bottomButtonContainer.findViewById(R.id.rc_voip_disable_camera_text);
    String currentUserId = RongIMClient.getInstance().getCurrentUserId();

    RongCallClient.getInstance().setEnableLocalVideo(view.isSelected());
    if (view.isSelected()) {
        text.setText(R.string.rc_voip_disable_camera);
        if (localViewUserId.equals(currentUserId)) {
            localView.setVisibility(View.VISIBLE);
        } else {
            remoteViewContainer.findViewWithTag(currentUserId).setVisibility(View.VISIBLE);
        }
    } else {
        text.setText(R.string.rc_voip_enable_camera);
        if (localViewUserId.equals(currentUserId)) {
            localView.setVisibility(View.GONE);
        } else {
            remoteViewContainer.findViewWithTag(currentUserId).setVisibility(View.GONE);
        }
    }
    view.setSelected(!view.isSelected());
}
 
Example 4
Project: ArcLayout-master   File: DemoLikeTumblrActivity.java   Source Code and License Vote up 6 votes
private void onFabClick(View v) {
  int x = (v.getLeft() + v.getRight()) / 2;
  int y = (v.getTop() + v.getBottom()) / 2;
  float radiusOfFab = 1f * v.getWidth() / 2f;
  float radiusFromFabToRoot = (float) Math.hypot(
      Math.max(x, rootLayout.getWidth() - x),
      Math.max(y, rootLayout.getHeight() - y));

  if (v.isSelected()) {
    hideMenu(x, y, radiusFromFabToRoot, radiusOfFab);
  } else {
    showMenu(x, y, radiusOfFab, radiusFromFabToRoot);
  }
  v.setSelected(!v.isSelected());
}
 
Example 5
Project: GitHub   File: VideoPlayerActivity.java   Source Code and License Vote up 6 votes
@OnClick({R.id.iv_video_share, R.id.iv_video_download, R.id.sb_send})
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.iv_video_share:
            new ShareBottomDialog(this).show();
            break;
        case R.id.iv_video_download:
            if (view.isSelected()) {
                DialogHelper.checkDialog(this, mVideoData);
            } else {
                DialogHelper.downloadDialog(this, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        DownloaderWrapper.start(mVideoData);
                        mIvVideoDownload.setSelected(true);
                        SnackbarUtils.showDownloadSnackbar(VideoPlayerActivity.this, "任务正在下载", true);
                    }
                });
            }
            break;
        case R.id.sb_send:
            mPlayerView.sendDanmaku(mEtContent.getText().toString(), false);
            mEtContent.setText("");
            _closeSoftInput();
            break;
    }
}
 
Example 6
Project: FriendBook   File: ReaderSettingDialog.java   Source Code and License Vote up 6 votes
private void selectedThemeView(@NonNull View selectedView) {
    selectedView.setSelected(true);

    for (View view : themeViews) {
        if (view != selectedView && view.isSelected()) {
            view.setSelected(false);
        }
    }

}
 
Example 7
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 8
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 9
Project: mdb-android-application   File: MoviesGridAdapter.java   Source Code and License Vote up 6 votes
@OnClick(R.id.grid_favorite_button)
public void onFavoritesButton(View view) {
    if (view.isSelected()) {
        favoritesRepository.removeFromFavorites(movieEntity);
        view.setSelected(false);
    } else {
        favoritesRepository.addToFavorites(movieEntity);
        view.setSelected(true);
    }
}
 
Example 10
Project: ArcLayout-master   File: MainActivity.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 11
Project: Expert-Android-Programming   File: NotificationPreferenceActivity.java   Source Code and License Vote up 6 votes
public void onOptionClick(View view) {
    if (view.isSelected()) {
        view.setSelected(false);
    } else {
        view.setSelected(true);
    }
}
 
Example 12
Project: Expert-Android-Programming   File: NotificationPreferenceActivity.java   Source Code and License Vote up 6 votes
public void onEnableAllClick(View view) {

        if (view.isSelected()) {
            enableAllChildren(parent, false);
        } else {
            enableAllChildren(parent, true);
        }

    }
 
Example 13
Project: GitHub   File: BaseViewHolder.java   Source Code and License Vote up 5 votes
public boolean isSelected(int viewId) {
    View view = getView(viewId);
    return view.isSelected();
}
 
Example 14
Project: HorizontalLoopView   File: HorizontalLoopView.java   Source Code and License Vote up 5 votes
/**
 * 移动 元素的值
 *
 * @param steps
 */
protected void moveChildres(int steps) {

    if (steps == 0 || loopViewAdapter == null) {
        return;
    }
    int start;
    int end;
    int incr;
    if (steps < 0) {
        start = 0;
        end = getChildCount();
        incr = 1;
    } else {
        start = getChildCount() - 1;
        end = -1;
        incr = -1;
    }
    for (int i = start; i != end; i += incr) {
        //获取View
        View childAtView = getChildAt(i);
        //获取tag中的数据
        int mNowIndex = (int) childAtView.getTag(INDEX_TAG);
        //向右滑动
        if (steps > 0) {
            //当前为0了,赋值为最后一个
            if (mNowIndex == 0 /*&& isLoop*/) {
                //赋值
                mNowIndex = loopViewAdapter.getItemCount();
            }
            mNowIndex--;
            //显示视图 循环 并且 当前下标 大于等于0  显示
           /* if (isLoop && mNowIndex >= 0) {
                childAtView.setVisibility(VISIBLE);
            }
            if (!isLoop && mNowIndex < 0) {
                childAtView.setVisibility(INVISIBLE);
            }*/
        } else {
            //向左滑动 已经是最后一个 赋值为第一个
            if (mNowIndex == loopViewAdapter.getItemCount() - 1/* && isLoop*/) {
                mNowIndex = -1;
            }
            mNowIndex++;
            //显示视图  循环 并且 下标小于等于总条数
           /* if (isLoop && mNowIndex <= loopViewAdapter.getItemCount() - 1) {
                childAtView.setVisibility(VISIBLE);
            }
            if (!isLoop && mNowIndex > loopViewAdapter.getItemCount() - 1) {
                childAtView.setVisibility(INVISIBLE);
            }*/
        }

        //保存选中的View
        if (childAtView.isSelected()) {
            mCenterView = childAtView;
        }
        //保存当前的下标
        childAtView.setTag(INDEX_TAG, mNowIndex);

        //适配器不为空  回调数据
        if (loopViewAdapter != null && childAtView.getVisibility() == VISIBLE) {
            loopViewAdapter.setData(childAtView, mNowIndex);
        }

    }
}
 
Example 15
Project: FastAndroid   File: SingleCallActivity.java   Source Code and License Vote up 5 votes
public void onHandFreeButtonClick(View view) {
    RongCallClient.getInstance().setEnableSpeakerphone(!view.isSelected());
    view.setSelected(!view.isSelected());
    handFree = view.isSelected();
}
 
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: letv   File: HListView.java   Source Code and License Vote up 5 votes
@TargetApi(11)
private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, 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();
    LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        p = (LayoutParams) generateDefaultLayoutParams();
    }
    p.viewType = this.mAdapter.getItemViewType(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 (!(this.mChoiceMode == 0 || this.mCheckStates == null)) {
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        } else if (VERSION.SDK_INT >= 11) {
            child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        }
    }
    if (needToMeasure) {
        int childWidthSpec;
        int childHeightSpec = ViewGroup.getChildMeasureSpec(this.mHeightMeasureSpec, this.mListPadding.top + this.mListPadding.bottom, p.height);
        int lpWidth = p.width;
        if (lpWidth > 0) {
            childWidthSpec = MeasureSpec.makeMeasureSpec(lpWidth, 1073741824);
        } else {
            childWidthSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        child.measure(childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childLeft = flowDown ? x : x - w;
    if (needToMeasure) {
        child.layout(childLeft, childrenTop, childLeft + w, childrenTop + h);
    } else {
        child.offsetLeftAndRight(childLeft - child.getLeft());
        child.offsetTopAndBottom(childrenTop - child.getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
    if (VERSION.SDK_INT >= 11 && recycled && ((LayoutParams) child.getLayoutParams()).scrappedFromPosition != position) {
        child.jumpDrawablesToCurrentState();
    }
}
 
Example 18
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);
    }
}
 
Example 19
Project: sealtalk-android-master   File: SingleCallActivity.java   Source Code and License Vote up 5 votes
public void onHandFreeButtonClick(View view) {
    RongCallClient.getInstance().setEnableSpeakerphone(!view.isSelected());
    view.setSelected(!view.isSelected());
    handFree = view.isSelected();
}
 
Example 20
Project: sealtalk-android-master   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();
}