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();
}
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();
}
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();
}
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();
}
});
}
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;
}
Aggregations