@Override public View getView(int position, View convertView, ViewGroup parent) { CheckedTextView view = (CheckedTextView) super.getView(position, convertView, parent); DialogOption option = mOptions[position]; view.setChecked(mSelectedOptions.contains(option)); view.setEnabled(!mDisabledOptions.contains(option)); return view; }
private void onClickShutter() { boolean isRecording = RecorderModel.getModel().isRecorderRunning(); LogUtil.i(MODULE_TAG, "onClick() isRecording=" + isRecording); mShutter.toggle(); mShutter.setEnabled(false); if (!isRecording) { start_rec(); getActivity().finish(); EventBus.getDefault().unregister(this); } else { stop_rec(); } }
private void maybeUpdateCheckedState(int position, PromptListItem item, ViewHolder viewHolder) { if (item.isGroup || mSelected == null) return; CheckedTextView ct; try { ct = (CheckedTextView) viewHolder.textView; } catch (Exception e) { return; } ct.setEnabled(!item.disabled); ct.setClickable(item.disabled); // Apparently just using ct.setChecked(true) doesn't work, so this // is stolen from the android source code as a way to set the checked // state of these items if (listView != null) listView.setItemChecked(position, mSelected[position]); ct.setPadding( (item.inGroup ? mGroupPaddingSize : viewHolder.paddingLeft), viewHolder.paddingTop, viewHolder.paddingRight, viewHolder.paddingBottom); }
private void setEnabled() { super.setEnabled(isInRange && !isDecoratedDisabled); setVisibility(isInRange || showOtherDates ? View.VISIBLE : View.INVISIBLE); }
public void onEvent(RecorderEvent event) { LogUtil.i( MODULE_TAG, "onEvent isRecording:" + event.isRecording + ", fileName:" + event.fileName); mShutter.setEnabled(true); mShutter.setChecked(event.isRecording); }
@Override public View getChildView( int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.restrictionchild, parent, false); final CheckedTextView ctvMethodName = (CheckedTextView) row.findViewById(R.id.ctvMethodName); // Get entry final String restrictionName = (String) getGroup(groupPosition); final String methodName = (String) getChild(groupPosition, childPosition); long lastUsage = PrivacyManager.getUsed(row.getContext(), mAppInfo.getUid(), restrictionName, methodName); // Display method name if (lastUsage == 0) ctvMethodName.setText(methodName); else { Date date = new Date(lastUsage); SimpleDateFormat format = new SimpleDateFormat("dd/HH:mm", Locale.US); ctvMethodName.setText(String.format("%s %s", methodName, format.format(date))); } boolean parentRestricted = PrivacyManager.getRestricted( null, row.getContext(), mAppInfo.getUid(), restrictionName, null, false, false); ctvMethodName.setEnabled(parentRestricted); // Display if used if (lastUsage != 0) ctvMethodName.setTypeface(null, Typeface.BOLD_ITALIC); // Display restriction boolean restricted = PrivacyManager.getRestricted( null, row.getContext(), mAppInfo.getUid(), restrictionName, methodName, false, false); ctvMethodName.setChecked(restricted); // Listen for restriction changes ctvMethodName.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { boolean restricted = PrivacyManager.getRestricted( null, view.getContext(), mAppInfo.getUid(), restrictionName, methodName, false, false); restricted = !restricted; ctvMethodName.setChecked(restricted); PrivacyManager.setRestricted( null, view.getContext(), mAppInfo.getUid(), restrictionName, methodName, restricted); } }); return row; }