Search in sources :

Example 61 with Checkable

use of android.widget.Checkable in project developmentDependencyLibrary by MatchlessBrother.

the class StickyHVAListViewAdapter method getView.

public ItemAView getView(int position, View convertView, ViewGroup parent) {
    ItemAView itemAView = (convertView == null) ? new ItemAView(mContext) : (ItemAView) convertView;
    View item = mStickyHeadersAdapter.getView(position, itemAView.mItem, parent);
    View header = null;
    if (previousPositionHasSameHeader(position))
        recycleStickyHeadersViewIfExist(itemAView);
    else
        header = configureHeader(itemAView, position);
    if ((item instanceof Checkable) && !(itemAView instanceof ItemCheckableView))
        itemAView = new ItemCheckableView(mContext);
    else if (!(item instanceof Checkable) && (itemAView instanceof ItemCheckableView))
        itemAView = new ItemAView(mContext);
    itemAView.updateView(item, header, mDivider, mDividerHeight);
    return itemAView;
}
Also used : Checkable(android.widget.Checkable) View(android.view.View)

Example 62 with Checkable

use of android.widget.Checkable in project incubator-weex by apache.

the class WXPickersModule method performSinglePick.

private void performSinglePick(final List<String> items, final Map<String, Object> options, final JSCallback callback) {
    selected = getOption(options, KEY_INDEX, 0);
    final int textColor = getColor(options, KEY_TEXT_COLOR, Color.TRANSPARENT);
    final int selectionColor = getColor(options, KEY_SELECTION_COLOR, Color.TRANSPARENT);
    final ArrayAdapter adapter = new ArrayAdapter<String>(mWXSDKInstance.getContext(), android.R.layout.simple_list_item_single_choice, items) {

        @NonNull
        @Override
        public View getView(int position, View convertView, @Nullable ViewGroup parent) {
            View itemView = super.getView(position, convertView, parent);
            if (itemView != null && itemView instanceof Checkable) {
                boolean needSelected = position == selected;
                ((Checkable) itemView).setChecked(needSelected);
                if (needSelected) {
                    itemView.setBackgroundColor(selectionColor);
                } else {
                    itemView.setBackgroundColor(Color.TRANSPARENT);
                }
            }
            if (itemView instanceof TextView && textColor != Color.TRANSPARENT) {
                ((TextView) itemView).setTextColor(textColor);
            }
            return itemView;
        }
    };
    final AlertDialog dialog = new AlertDialog.Builder(mWXSDKInstance.getContext()).setAdapter(adapter, null).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // which == -1
            Map<String, Object> ret = new HashMap<>(2);
            ret.put(RESULT, SUCCESS);
            ret.put(DATA, selected);
            callback.invoke(ret);
        }
    }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // which == -2
            Map<String, Object> ret = new HashMap<>(2);
            ret.put(RESULT, CANCEL);
            ret.put(DATA, -1);
            callback.invoke(ret);
        }
    }).setCustomTitle(makeTitleView(mWXSDKInstance.getContext(), options)).create();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // pre create the content view on dialog.
        // if not , the content view will not be created until dialog.show() called
        dialog.create();
    }
    final ListView listView = dialog.getListView();
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selected = position;
            adapter.notifyDataSetChanged();
        }
    });
    dialog.getWindow().getDecorView().post(WXThread.secure(new Runnable() {

        @Override
        public void run() {
            Button confirm = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            Button cancel = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
            if (confirm != null) {
                String confirmTitle = getOption(options, KEY_CONFIRM_TITLE, null);
                int confirmColor = getColor(options, KEY_CONFIRM_TITLE_COLOR, Color.TRANSPARENT);
                if (confirmTitle != null) {
                    confirm.setText(confirmTitle);
                    confirm.setAllCaps(false);
                }
                if (confirmColor != Color.TRANSPARENT) {
                    confirm.setTextColor(confirmColor);
                    confirm.setAllCaps(false);
                }
            }
            if (cancel != null) {
                String cancelTitle = getOption(options, KEY_CANCEL_TITLE, null);
                int cancelColor = getColor(options, KEY_CANCEL_TITLE_COLOR, Color.TRANSPARENT);
                if (cancelTitle != null) {
                    cancel.setText(cancelTitle);
                }
                if (cancelColor != Color.TRANSPARENT) {
                    cancel.setTextColor(cancelColor);
                }
            }
        }
    }));
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) HashMap(java.util.HashMap) ListView(android.widget.ListView) Button(android.widget.Button) TextView(android.widget.TextView) ViewGroup(android.view.ViewGroup) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) Checkable(android.widget.Checkable) HashMap(java.util.HashMap) Map(java.util.Map) ArrayAdapter(android.widget.ArrayAdapter) Nullable(android.support.annotation.Nullable)

Example 63 with Checkable

use of android.widget.Checkable in project android_packages_apps_Settings by SudaMod.

the class UsbModeChooserActivity method inflateOption.

private void inflateOption(final int mode, boolean selected, LinearLayout container, final boolean disallowedByAdmin) {
    View v = mLayoutInflater.inflate(R.layout.restricted_radio_with_summary, container, false);
    TextView titleView = (TextView) v.findViewById(android.R.id.title);
    titleView.setText(getTitle(mode));
    TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
    updateSummary(summaryView, mode);
    if (disallowedByAdmin) {
        if (mEnforcedAdmin != null) {
            setDisabledByAdmin(v, titleView, summaryView);
        } else {
            return;
        }
    }
    v.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (disallowedByAdmin && mEnforcedAdmin != null) {
                RestrictedLockUtils.sendShowAdminSupportDetailsIntent(UsbModeChooserActivity.this, mEnforcedAdmin);
                return;
            }
            if (!ActivityManager.isUserAMonkey()) {
                mBackend.setMode(mode);
            }
            mDialog.dismiss();
            finish();
        }
    });
    ((Checkable) v).setChecked(selected);
    container.addView(v);
}
Also used : OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) Checkable(android.widget.Checkable) View(android.view.View) TextView(android.widget.TextView)

Example 64 with Checkable

use of android.widget.Checkable in project platform_packages_apps_Settings by BlissRoms.

the class UsbModeChooserActivity method inflateOption.

private void inflateOption(final int mode, boolean selected, LinearLayout container, final boolean disallowedByAdmin) {
    View v = mLayoutInflater.inflate(R.layout.restricted_radio_with_summary, container, false);
    TextView titleView = (TextView) v.findViewById(android.R.id.title);
    titleView.setText(getTitle(mode));
    TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
    updateSummary(summaryView, mode);
    if (disallowedByAdmin) {
        if (mEnforcedAdmin != null) {
            setDisabledByAdmin(v, titleView, summaryView);
        } else {
            return;
        }
    }
    v.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (disallowedByAdmin && mEnforcedAdmin != null) {
                RestrictedLockUtils.sendShowAdminSupportDetailsIntent(UsbModeChooserActivity.this, mEnforcedAdmin);
                return;
            }
            if (!ActivityManager.isUserAMonkey()) {
                mBackend.setMode(mode);
            }
            mDialog.dismiss();
            finish();
        }
    });
    ((Checkable) v).setChecked(selected);
    container.addView(v);
}
Also used : OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) Checkable(android.widget.Checkable) View(android.view.View) TextView(android.widget.TextView)

Example 65 with Checkable

use of android.widget.Checkable in project platform_packages_apps_Settings by BlissRoms.

the class CellDataPreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    View switchView = holder.findViewById(android.R.id.switch_widget);
    switchView.setClickable(false);
    ((Checkable) switchView).setChecked(mChecked);
}
Also used : Checkable(android.widget.Checkable) View(android.view.View)

Aggregations

Checkable (android.widget.Checkable)79 View (android.view.View)47 TextView (android.widget.TextView)18 ViewGroup (android.view.ViewGroup)9 OnClickListener (android.view.View.OnClickListener)7 ImageView (android.widget.ImageView)7 Switch (android.widget.Switch)7 ResourceReference (com.android.ide.common.rendering.api.ResourceReference)6 Resources (android.content.res.Resources)5 Paint (android.graphics.Paint)5 Point (android.graphics.Point)4 SuppressLint (android.annotation.SuppressLint)3 AdapterView (android.widget.AdapterView)3 CheckBox (android.widget.CheckBox)3 ListView (android.widget.ListView)3 Spinner (android.widget.Spinner)3 Map (java.util.Map)3 Switch (org.holoeverywhere.widget.Switch)3 SimpleArrayMap (android.support.v4.util.SimpleArrayMap)2 AlertDialog (android.support.v7.app.AlertDialog)2