Java Code Examples for android.widget.TextView#isSelected()

The following examples show how to use android.widget.TextView#isSelected() . 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 check out the related API usage on the sidebar.
Example 1
Source File: LabelsView.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void onClick(View v) {
    if (v instanceof TextView) {
        TextView label = (TextView) v;
        if (this.mSelectType != SelectType.NONE) {
            if (label.isSelected()) {
                if (!(this.mSelectType == SelectType.SINGLE_IRREVOCABLY || this.mCompulsorys.contains((Integer) label.getTag(KEY_POSITION)))) {
                    setLabelSelect(label, false);
                }
            } else if (this.mSelectType == SelectType.SINGLE || this.mSelectType == SelectType.SINGLE_IRREVOCABLY) {
                innerClearAllSelect();
                setLabelSelect(label, true);
            } else if (this.mSelectType == SelectType.MULTI && (this.mMaxSelect <= 0 || this.mMaxSelect > this.mSelectLabels.size())) {
                setLabelSelect(label, true);
            }
        }
        if (this.mLabelClickListener != null) {
            this.mLabelClickListener.onLabelClick(label, label.getTag(KEY_DATA), ((Integer) label.getTag(KEY_POSITION)).intValue());
        }
    }
}
 
Example 2
Source File: SetAlarmActivity.java    From PrayTime-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onBackPressed() {
  boolean anyAlarmSelected = false;
  for (TextView tv : mPrayers) {
    if (tv.isSelected()) {
      anyAlarmSelected = true;
    }
  }

  if (!anyAlarmSelected) {
    mAlarm.setChecked(false);
  }

  Intent data = new Intent();
  if (getParent() == null) {
    setResult(RESULT_OK, data);
  } else {
    getParent().setResult(RESULT_OK, data);
  }

  super.onBackPressed();
}
 
Example 3
Source File: LabelsView.java    From FimiX8-RE with MIT License 5 votes vote down vote up
private void setLabelSelect(TextView label, boolean isSelect) {
    if (label.isSelected() != isSelect) {
        label.setSelected(isSelect);
        if (isSelect) {
            this.mSelectLabels.add((Integer) label.getTag(KEY_POSITION));
        } else {
            this.mSelectLabels.remove((Integer) label.getTag(KEY_POSITION));
        }
        if (this.mLabelSelectChangeListener != null) {
            this.mLabelSelectChangeListener.onLabelSelectChange(label, label.getTag(KEY_DATA), isSelect, ((Integer) label.getTag(KEY_POSITION)).intValue());
        }
    }
}
 
Example 4
Source File: LabelsView.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (v instanceof TextView) {
        TextView label = (TextView) v;
        if (!isIndicator) {
            if (mSelectType != SelectType.NONE) {
                if (label.isSelected()) {
                    boolean irrevocable = mSelectType == SelectType.MULTI && mCompulsorys.contains((Integer) label.getTag(KEY_POSITION));
                    irrevocable = irrevocable || (mSelectType == SelectType.MULTI && mSelectLabels.size() <= mMinSelect);
                    irrevocable = irrevocable || mSelectType == SelectType.SINGLE_IRREVOCABLY;
                    if (!irrevocable) {
                        setLabelSelect(label, false);
                    }
                } else {
                    if (mSelectType == SelectType.SINGLE || mSelectType == SelectType.SINGLE_IRREVOCABLY) {
                        innerClearAllSelect();
                        setLabelSelect(label, true);
                    } else if (mSelectType == SelectType.MULTI
                            && (mMaxSelect <= 0 || mMaxSelect > mSelectLabels.size())) {
                        setLabelSelect(label, true);
                    }
                }
            }
        }

        if (mLabelClickListener != null) {
            mLabelClickListener.onLabelClick(label, label.getTag(KEY_DATA), (int) label.getTag(KEY_POSITION));
        }
    }
}
 
Example 5
Source File: LabelsView.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
private void setLabelSelect(TextView label, boolean isSelect) {
    if (label.isSelected() != isSelect) {
        label.setSelected(isSelect);
        if (isSelect) {
            mSelectLabels.add((Integer) label.getTag(KEY_POSITION));
        } else {
            mSelectLabels.remove((Integer) label.getTag(KEY_POSITION));
        }
        if (mLabelSelectChangeListener != null) {
            mLabelSelectChangeListener.onLabelSelectChange(label, label.getTag(KEY_DATA),
                    isSelect, (int) label.getTag(KEY_POSITION));
        }
    }
}
 
Example 6
Source File: LabelsView.java    From LabelsView with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (v instanceof TextView) {
        TextView label = (TextView) v;
        if (!isIndicator) {
            if (mSelectType != SelectType.NONE) {
                if (label.isSelected()) {
                    boolean irrevocable = mSelectType == SelectType.MULTI && mCompulsorys.contains((Integer) label.getTag(KEY_POSITION));
                    irrevocable = irrevocable || (mSelectType == SelectType.MULTI && mSelectLabels.size() <= mMinSelect);
                    irrevocable = irrevocable || mSelectType == SelectType.SINGLE_IRREVOCABLY;
                    if (!irrevocable && !selectChangeIntercept(label)) {
                        setLabelSelect(label, false);
                    }
                } else {
                    if (mSelectType == SelectType.SINGLE || mSelectType == SelectType.SINGLE_IRREVOCABLY) {
                        if (!selectChangeIntercept(label)) {
                            innerClearAllSelect();
                            setLabelSelect(label, true);
                        }
                    } else if (mSelectType == SelectType.MULTI
                            && (mMaxSelect <= 0 || mMaxSelect > mSelectLabels.size())) {
                        if (!selectChangeIntercept(label)) {
                            setLabelSelect(label, true);
                        }
                    }
                }
            }
        }

        if (mLabelClickListener != null) {
            mLabelClickListener.onLabelClick(label, label.getTag(KEY_DATA), (int) label.getTag(KEY_POSITION));
        }
    }
}
 
Example 7
Source File: LabelsView.java    From LabelsView with Apache License 2.0 5 votes vote down vote up
private void setLabelSelect(TextView label, boolean isSelect) {
    if (label.isSelected() != isSelect) {
        label.setSelected(isSelect);
        if (isSelect) {
            mSelectLabels.add((Integer) label.getTag(KEY_POSITION));
        } else {
            mSelectLabels.remove((Integer) label.getTag(KEY_POSITION));
        }
        if (mLabelSelectChangeListener != null) {
            mLabelSelectChangeListener.onLabelSelectChange(label, label.getTag(KEY_DATA),
                    isSelect, (int) label.getTag(KEY_POSITION));
        }
    }
}