use of android.widget.AdapterView in project PocketHub by pockethub.
the class RefDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
Activity activity = getActivity();
Bundle arguments = getArguments();
final MaterialDialog.Builder dialogBuilder = createDialogBuilder().negativeText(R.string.cancel).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
RefDialogFragment.this.onClick(dialog, BUTTON_NEGATIVE);
}
});
LayoutInflater inflater = activity.getLayoutInflater();
ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null);
view.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onClick(getDialog(), position);
}
});
ArrayList<GitReference> choices = getChoices();
int selected = arguments.getInt(ARG_SELECTED_CHOICE);
RefListAdapter adapter = new RefListAdapter(inflater, choices.toArray(new GitReference[choices.size()]), selected);
view.setAdapter(adapter);
if (selected >= 0) {
view.setSelection(selected);
}
dialogBuilder.customView(view, false);
return dialogBuilder.build();
}
use of android.widget.AdapterView in project PocketHub by pockethub.
the class MilestoneDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
Activity activity = getActivity();
Bundle arguments = getArguments();
final MaterialDialog.Builder dialogBuilder = createDialogBuilder().negativeText(R.string.cancel).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
MilestoneDialogFragment.this.onClick(dialog, BUTTON_NEGATIVE);
}
}).neutralText(R.string.clear).onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
MilestoneDialogFragment.this.onClick(dialog, BUTTON_NEUTRAL);
}
});
LayoutInflater inflater = activity.getLayoutInflater();
ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null);
view.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onClick(getDialog(), position);
}
});
ArrayList<Milestone> choices = getChoices();
int selected = arguments.getInt(ARG_SELECTED_CHOICE);
MilestoneListAdapter adapter = new MilestoneListAdapter(inflater, choices.toArray(new Milestone[choices.size()]), selected);
view.setAdapter(adapter);
if (selected >= 0) {
view.setSelection(selected);
}
dialogBuilder.customView(view, false);
return dialogBuilder.build();
}
use of android.widget.AdapterView in project androidquery by androidquery.
the class AbstractAQuery method adapter.
/**
* Set the adapter of an AdapterView.
*
* @param adapter adapter
* @return self
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public T adapter(Adapter adapter) {
if (view instanceof AdapterView) {
AdapterView av = (AdapterView) view;
av.setAdapter(adapter);
}
return self();
}
use of android.widget.AdapterView in project androidquery by androidquery.
the class AbstractAQuery method dataChanged.
/**
* Notify a ListView that the data of it's adapter is changed.
*
* @return self
*/
public T dataChanged() {
if (view instanceof AdapterView) {
AdapterView<?> av = (AdapterView<?>) view;
Adapter a = av.getAdapter();
if (a instanceof BaseAdapter) {
BaseAdapter ba = (BaseAdapter) a;
ba.notifyDataSetChanged();
}
}
return self();
}
use of android.widget.AdapterView in project platform_frameworks_base by android.
the class GlobalActions method createDialog.
/**
* Create the global actions dialog.
* @return A new dialog.
*/
private GlobalActionsDialog createDialog() {
// Simple toggle style if there's no vibrator, otherwise use a tri-state
if (!mHasVibrator) {
mSilentModeAction = new SilentModeToggleAction();
} else {
mSilentModeAction = new SilentModeTriStateAction(mContext, mAudioManager, mHandler);
}
mAirplaneModeOn = new ToggleAction(R.drawable.ic_lock_airplane_mode, R.drawable.ic_lock_airplane_mode_off, R.string.global_actions_toggle_airplane_mode, R.string.global_actions_airplane_mode_on_status, R.string.global_actions_airplane_mode_off_status) {
void onToggle(boolean on) {
if (mHasTelephony && Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
mIsWaitingForEcmExit = true;
// Launch ECM exit dialog
Intent ecmDialogIntent = new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null);
ecmDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(ecmDialogIntent);
} else {
changeAirplaneModeSystemSetting(on);
}
}
@Override
protected void changeStateFromPress(boolean buttonOn) {
if (!mHasTelephony)
return;
// In ECM mode airplane state cannot be changed
if (!(Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)))) {
mState = buttonOn ? State.TurningOn : State.TurningOff;
mAirplaneState = mState;
}
}
public boolean showDuringKeyguard() {
return true;
}
public boolean showBeforeProvisioning() {
return false;
}
};
onAirplaneModeChanged();
mItems = new ArrayList<Action>();
String[] defaultActions = mContext.getResources().getStringArray(com.android.internal.R.array.config_globalActionsList);
ArraySet<String> addedKeys = new ArraySet<String>();
for (int i = 0; i < defaultActions.length; i++) {
String actionKey = defaultActions[i];
if (addedKeys.contains(actionKey)) {
// If we already have added this, don't add it again.
continue;
}
if (GLOBAL_ACTION_KEY_POWER.equals(actionKey)) {
mItems.add(new PowerAction());
} else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) {
mItems.add(mAirplaneModeOn);
} else if (GLOBAL_ACTION_KEY_BUGREPORT.equals(actionKey)) {
if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0 && isCurrentUserOwner()) {
mItems.add(new BugReportAction());
}
} else if (GLOBAL_ACTION_KEY_SILENT.equals(actionKey)) {
if (mShowSilentToggle) {
mItems.add(mSilentModeAction);
}
} else if (GLOBAL_ACTION_KEY_USERS.equals(actionKey)) {
if (SystemProperties.getBoolean("fw.power_user_switcher", false)) {
addUsersToMenu(mItems);
}
} else if (GLOBAL_ACTION_KEY_SETTINGS.equals(actionKey)) {
mItems.add(getSettingsAction());
} else if (GLOBAL_ACTION_KEY_LOCKDOWN.equals(actionKey)) {
mItems.add(getLockdownAction());
} else if (GLOBAL_ACTION_KEY_VOICEASSIST.equals(actionKey)) {
mItems.add(getVoiceAssistAction());
} else if (GLOBAL_ACTION_KEY_ASSIST.equals(actionKey)) {
mItems.add(getAssistAction());
} else if (GLOBAL_ACTION_KEY_RESTART.equals(actionKey)) {
mItems.add(new RestartAction());
} else {
Log.e(TAG, "Invalid global action key " + actionKey);
}
// Add here so we don't add more than one.
addedKeys.add(actionKey);
}
if (mEmergencyAffordanceManager.needsEmergencyAffordance()) {
mItems.add(getEmergencyAction());
}
mAdapter = new MyAdapter();
AlertParams params = new AlertParams(mContext);
params.mAdapter = mAdapter;
params.mOnClickListener = this;
params.mForceInverseBackground = true;
GlobalActionsDialog dialog = new GlobalActionsDialog(mContext, params);
// Handled by the custom class.
dialog.setCanceledOnTouchOutside(false);
dialog.getListView().setItemsCanFocus(true);
dialog.getListView().setLongClickable(true);
dialog.getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
final Action action = mAdapter.getItem(position);
if (action instanceof LongPressAction) {
return ((LongPressAction) action).onLongPress();
}
return false;
}
});
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
dialog.setOnDismissListener(this);
return dialog;
}
Aggregations