Search in sources :

Example 91 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project PhoneProfilesPlus by henrichg.

the class BluetoothNamePreference method showDialog.

@Override
protected void showDialog(Bundle state) {
    value = getPersistedString(value);
    PPApplication.forceRegisterReceiversForBluetoothScanner(context);
    forceRegister = true;
    MaterialDialog.Builder mBuilder = new MaterialDialog.Builder(getContext()).title(getDialogTitle()).icon(getDialogIcon()).positiveText(getPositiveButtonText()).negativeText(getNegativeButtonText()).autoDismiss(false).content(getDialogMessage()).customView(R.layout.activity_bluetooth_name_pref_dialog, false).dividerColor(0).onPositive(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
            if (shouldPersist()) {
                if (callChangeListener(value)) {
                    persistString(value);
                }
            }
            mDialog.dismiss();
        }
    }).onNegative(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
            mDialog.dismiss();
        }
    });
    mDialog = mBuilder.build();
    View layout = mDialog.getCustomView();
    // noinspection ConstantConditions
    progressLinearLayout = layout.findViewById(R.id.bluetooth_name_pref_dlg_linla_progress);
    // noinspection ConstantConditions
    dataRelativeLayout = layout.findViewById(R.id.bluetooth_name_pref_dlg_rella_data);
    addIcon = layout.findViewById(R.id.bluetooth_name_pref_dlg_addIcon);
    addIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String btName = bluetoothName.getText().toString();
            addBluetoothName(btName);
            boolean found = false;
            for (BluetoothDeviceData customBtNameData : customBluetoothList) {
                if (customBtNameData.getName().equalsIgnoreCase(btName)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                // if (android.os.Build.VERSION.SDK_INT >= 18)
                customBluetoothList.add(new BluetoothDeviceData(btName, "", BluetoothDevice.DEVICE_TYPE_DUAL, true, 0));
            // else
            // customBluetoothList.add(new BluetoothDeviceData(btName, "", 0, true, 0));
            }
            refreshListView(false, btName);
        }
    });
    bluetoothName = layout.findViewById(R.id.bluetooth_name_pref_dlg_bt_name);
    bluetoothName.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            GlobalGUIRoutines.setImageButtonEnabled(!bluetoothName.getText().toString().isEmpty(), addIcon, R.drawable.ic_action_location_add, context.getApplicationContext());
        }
    });
    GlobalGUIRoutines.setImageButtonEnabled(!bluetoothName.getText().toString().isEmpty(), addIcon, R.drawable.ic_action_location_add, context.getApplicationContext());
    bluetoothListView = layout.findViewById(R.id.bluetooth_name_pref_dlg_listview);
    listAdapter = new BluetoothNamePreferenceAdapter(context, this);
    bluetoothListView.setAdapter(listAdapter);
    refreshListView(false, "");
    bluetoothListView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            // BluetoothNamePreferenceAdapter.ViewHolder viewHolder =
            // (BluetoothNamePreferenceAdapter.ViewHolder) v.getTag();
            String btName = bluetoothList.get(position).getName();
            if (!(btName.equals(EventPreferencesBluetooth.ALL_BLUETOOTH_NAMES_VALUE) || btName.equals(EventPreferencesBluetooth.CONFIGURED_BLUETOOTH_NAMES_VALUE))) {
                bluetoothName.setText(btName);
            }
        /*
                viewHolder.checkBox.setChecked(!viewHolder.checkBox.isChecked());

                if (viewHolder.checkBox.isChecked()) {
                    addBluetoothName(bluetoothList.get(position).getName());
                }
                else {
                    removeBluetoothName(bluetoothList.get(position).getName());
                }
                */
        }
    });
    final ImageView helpIcon = layout.findViewById(R.id.bluetooth_name_pref_dlg_helpIcon);
    helpIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String helpString = context.getString(R.string.event_preference_bluetooth_bt_types) + "\n\n" + context.getString(R.string.pref_dlg_info_about_wildcards_1) + " " + context.getString(R.string.pref_dlg_info_about_wildcards_2) + " " + context.getString(R.string.bluetooth_name_pref_dlg_info_about_wildcards) + " " + context.getString(R.string.pref_dlg_info_about_wildcards_3);
            DialogHelpPopupWindow.showPopup(helpIcon, context, helpString);
        }
    });
    ImageView changeSelectionIcon = layout.findViewById(R.id.bluetooth_name_pref_dlg_changeSelection);
    changeSelectionIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mSelectorDialog = new MaterialDialog.Builder(context).title(R.string.pref_dlg_change_selection_title).items(R.array.bluetoothNameDChangeSelectionArray).itemsCallbackSingleChoice(0, new MaterialDialog.ListCallbackSingleChoice() {

                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    switch(which) {
                        case 0:
                            value = "";
                            break;
                        case 1:
                            for (BluetoothDeviceData bluetooth : bluetoothList) {
                                if (bluetooth.name.equals(bluetoothName.getText().toString()))
                                    addBluetoothName(bluetooth.name);
                            }
                            break;
                        default:
                    }
                    refreshListView(false, "");
                    return true;
                }
            }).positiveText(R.string.pref_dlg_change_selection_button).negativeText(getNegativeButtonText()).show();
        }
    });
    final Button rescanButton = layout.findViewById(R.id.bluetooth_name_pref_dlg_rescanButton);
    rescanButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (Permissions.grantBluetoothScanDialogPermissions(context, BluetoothNamePreference.this))
                refreshListView(true, "");
        }
    });
    GlobalGUIRoutines.registerOnActivityDestroyListener(this, this);
    if (state != null)
        mDialog.onRestoreInstanceState(state);
    mDialog.setOnDismissListener(this);
    mDialog.show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) Button(android.widget.Button) AppCompatImageButton(android.support.v7.widget.AppCompatImageButton) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) ImageView(android.widget.ImageView)

Example 92 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project LiveSDK-for-Android by liveservices.

the class ContactsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_contacts);
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Contact contact = (Contact) parent.getItemAtPosition(position);
            ViewContactDialog dialog = new ViewContactDialog(ContactsActivity.this, contact);
            dialog.setOwnerActivity(ContactsActivity.this);
            dialog.show();
        }
    });
    LinearLayout layout = new LinearLayout(this);
    Button newCalendarButton = new Button(this);
    newCalendarButton.setText("New Contact");
    newCalendarButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            CreateContactDialog dialog = new CreateContactDialog(ContactsActivity.this);
            dialog.setOwnerActivity(ContactsActivity.this);
            dialog.show();
        }
    });
    layout.addView(newCalendarButton);
    lv.addHeaderView(layout);
    mAdapter = new ContactsListAdapter(this);
    setListAdapter(mAdapter);
    LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    mClient = app.getConnectClient();
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) LiveSdkSampleApplication(com.microsoft.live.sample.LiveSdkSampleApplication) LinearLayout(android.widget.LinearLayout)

Example 93 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project LiveSDK-for-Android by liveservices.

the class SkyDriveActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.skydrive);
    mPrevFolderIds = new Stack<String>();
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SkyDriveObject skyDriveObj = (SkyDriveObject) parent.getItemAtPosition(position);
            skyDriveObj.accept(new Visitor() {

                @Override
                public void visit(SkyDriveAlbum album) {
                    mPrevFolderIds.push(mCurrentFolderId);
                    loadFolder(album.getId());
                }

                @Override
                public void visit(SkyDrivePhoto photo) {
                    ViewPhotoDialog dialog = new ViewPhotoDialog(SkyDriveActivity.this, photo);
                    dialog.setOwnerActivity(SkyDriveActivity.this);
                    dialog.show();
                }

                @Override
                public void visit(SkyDriveFolder folder) {
                    mPrevFolderIds.push(mCurrentFolderId);
                    loadFolder(folder.getId());
                }

                @Override
                public void visit(SkyDriveFile file) {
                    Bundle b = new Bundle();
                    b.putString(JsonKeys.ID, file.getId());
                    b.putString(JsonKeys.NAME, file.getName());
                    showDialog(DIALOG_DOWNLOAD_ID, b);
                }

                @Override
                public void visit(SkyDriveVideo video) {
                    PlayVideoDialog dialog = new PlayVideoDialog(SkyDriveActivity.this, video);
                    dialog.setOwnerActivity(SkyDriveActivity.this);
                    dialog.show();
                }

                @Override
                public void visit(SkyDriveAudio audio) {
                    PlayAudioDialog audioDialog = new PlayAudioDialog(SkyDriveActivity.this, audio);
                    audioDialog.show();
                }
            });
        }
    });
    LinearLayout layout = new LinearLayout(this);
    Button newFolderButton = new Button(this);
    newFolderButton.setText("New Folder");
    newFolderButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            NewFolderDialog dialog = new NewFolderDialog(SkyDriveActivity.this);
            dialog.setOwnerActivity(SkyDriveActivity.this);
            dialog.show();
        }
    });
    layout.addView(newFolderButton);
    Button uploadFileButton = new Button(this);
    uploadFileButton.setText("Upload File");
    uploadFileButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), FilePicker.class);
            startActivityForResult(intent, FilePicker.PICK_FILE_REQUEST);
        }
    });
    layout.addView(uploadFileButton);
    lv.addHeaderView(layout);
    mPhotoAdapter = new SkyDriveListAdapter(this);
    setListAdapter(mPhotoAdapter);
    LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    mClient = app.getConnectClient();
}
Also used : Visitor(com.microsoft.live.sample.skydrive.SkyDriveObject.Visitor) ListView(android.widget.ListView) Button(android.widget.Button) LiveSdkSampleApplication(com.microsoft.live.sample.LiveSdkSampleApplication) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) VideoView(android.widget.VideoView) OnClickListener(android.view.View.OnClickListener) LinearLayout(android.widget.LinearLayout) FilePicker(com.microsoft.live.sample.util.FilePicker)

Example 94 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project HL4A by HL4A.

the class AutoCompletePanel method initAutoCompletePanel.

private void initAutoCompletePanel() {
    _autoCompletePanel = new ListPopupWindow(_context);
    _autoCompletePanel.setAnchorView(_textField);
    _adapter = new MyAdapter(_context, android.R.layout.simple_list_item_1);
    _autoCompletePanel.setAdapter(_adapter);
    // _autoCompletePanel.setDropDownGravity(Gravity.BOTTOM | Gravity.LEFT);
    _filter = _adapter.getFilter();
    setHeight(300);
    TypedArray array = _context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.colorBackground, android.R.attr.textColorPrimary });
    int backgroundColor = array.getColor(0, 0xFF00FF);
    int textColor = array.getColor(1, 0xFF00FF);
    array.recycle();
    gd = new GradientDrawable();
    gd.setColor(backgroundColor);
    gd.setCornerRadius(4);
    gd.setStroke(1, textColor);
    setTextColor(textColor);
    _autoCompletePanel.setBackgroundDrawable(gd);
    _autoCompletePanel.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4) {
            // TODO: Implement this method
            _textField.replaceText(_textField.getCaretPosition() - _constraint.length(), _constraint.length(), ((TextView) p2).getText().toString());
            _adapter.abort();
            dismiss();
        }
    });
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) TypedArray(android.content.res.TypedArray) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 95 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project packages_apps_Contacts by AOKP.

the class GroupBrowseListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        mSelectedGroupUri = savedInstanceState.getParcelable(EXTRA_KEY_GROUP_URI);
        if (mSelectedGroupUri != null) {
            // The selection may be out of screen, if rotated from portrait to landscape,
            // so ensure it's visible.
            mSelectionToScreenRequested = true;
        }
    }
    mRootView = inflater.inflate(R.layout.group_browse_list_fragment, null);
    mEmptyView = (TextView) mRootView.findViewById(R.id.empty);
    mAdapter = new GroupBrowseListAdapter(mContext);
    mAdapter.setSelectionVisible(mSelectionVisible);
    mAdapter.setSelectedGroup(mSelectedGroupUri);
    mListView = (AutoScrollListView) mRootView.findViewById(R.id.list);
    mListView.setOnFocusChangeListener(this);
    mListView.setOnTouchListener(this);
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            GroupListItemViewCache groupListItem = (GroupListItemViewCache) view.getTag();
            if (groupListItem != null) {
                viewGroup(groupListItem.getUri());
            }
        }
    });
    mListView.setEmptyView(mEmptyView);
    configureVerticalScrollbar();
    mAddAccountsView = mRootView.findViewById(R.id.add_accounts);
    mAddAccountButton = mRootView.findViewById(R.id.add_account_button);
    mAddAccountButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] { ContactsContract.AUTHORITY });
            ImplicitIntentsUtil.startActivityOutsideApp(getActivity(), intent);
        }
    });
    setAddAccountsVisibility(!ContactsUtils.areGroupWritableAccountsAvailable(mContext));
    return mRootView;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) GroupListItemViewCache(com.android.contacts.group.GroupBrowseListAdapter.GroupListItemViewCache) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) AutoScrollListView(com.android.contacts.common.list.AutoScrollListView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)241 AdapterView (android.widget.AdapterView)238 View (android.view.View)237 ListView (android.widget.ListView)188 TextView (android.widget.TextView)135 ImageView (android.widget.ImageView)86 Intent (android.content.Intent)68 OnClickListener (android.view.View.OnClickListener)44 SuppressLint (android.annotation.SuppressLint)32 LayoutInflater (android.view.LayoutInflater)32 AlertDialog (android.app.AlertDialog)27 DialogInterface (android.content.DialogInterface)27 GridView (android.widget.GridView)26 ArrayAdapter (android.widget.ArrayAdapter)24 Bundle (android.os.Bundle)23 Dialog (android.app.Dialog)22 ArrayList (java.util.ArrayList)21 Paint (android.graphics.Paint)17 File (java.io.File)17 AbsListView (android.widget.AbsListView)16