use of android.support.v7.app.AlertDialog in project Camera-Roll-Android-App by kollerlukas.
the class FileExplorerActivity method fabClicked.
public void fabClicked(View v) {
if (showAnimations()) {
animateFab(false);
}
View dialogLayout = LayoutInflater.from(this).inflate(R.layout.input_dialog_layout, (ViewGroup) findViewById(R.id.root_view), false);
final EditText editText = dialogLayout.findViewById(R.id.edit_text);
AlertDialog dialog = new AlertDialog.Builder(this, theme.getDialogThemeRes()).setTitle(R.string.new_folder).setView(dialogLayout).setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
String filename = editText.getText().toString();
File_POJO newFolder = new File_POJO(currentDir.getPath() + "/" + filename, false);
File_POJO[] files = new File_POJO[] { newFolder };
Intent intent = FileOperation.getDefaultIntent(FileExplorerActivity.this, FileOperation.NEW_DIR, files);
startService(intent);
}
}).setNegativeButton(getString(R.string.cancel), null).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
animateFab(true);
}
}).create();
// noinspection ConstantConditions
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
dialog.show();
}
use of android.support.v7.app.AlertDialog in project FaceRecognitionApp by Lauszus.
the class FaceRecognitionAppActivity method showLabelsDialog.
private void showLabelsDialog() {
// Get all unique labels
Set<String> uniqueLabelsSet = new HashSet<>(imagesLabels);
if (!uniqueLabelsSet.isEmpty()) {
// Make sure that there are any labels
// Inspired by: http://stackoverflow.com/questions/15762905/how-can-i-display-a-list-view-in-an-android-alert-dialog
AlertDialog.Builder builder = new AlertDialog.Builder(FaceRecognitionAppActivity.this);
builder.setTitle("Select label:");
builder.setPositiveButton("New face", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
showEnterLabelDialog();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
// Remove last image
images.remove(images.size() - 1);
}
});
// Prevent the user from closing the dialog
builder.setCancelable(false);
// Convert to String array for ArrayAdapter
String[] uniqueLabels = uniqueLabelsSet.toArray(new String[uniqueLabelsSet.size()]);
// Sort labels alphabetically
Arrays.sort(uniqueLabels);
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(FaceRecognitionAppActivity.this, android.R.layout.simple_list_item_1, uniqueLabels) {
@Override
@NonNull
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
if (getResources().getBoolean(R.bool.isTablet))
// Make text slightly bigger on tablets compared to phones
textView.setTextSize(20);
else
// Increase text size a little bit
textView.setTextSize(18);
return textView;
}
};
ListView mListView = new ListView(FaceRecognitionAppActivity.this);
// Set adapter, so the items actually show up
mListView.setAdapter(arrayAdapter);
// Set the ListView
builder.setView(mListView);
// Show dialog and store in final variable, so it can be dismissed by the ListView
final AlertDialog dialog = builder.show();
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
dialog.dismiss();
addLabel(arrayAdapter.getItem(position));
}
});
} else
// If there is no existing labels, then ask the user for a new label
showEnterLabelDialog();
}
use of android.support.v7.app.AlertDialog in project remusic by aa112901.
the class AddNetPlaylistDialog method onCreateView.
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
// 设置无标题
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
if (getArguments() != null) {
musics = getArguments().getParcelableArrayList("songs");
author = getArguments().getString("author");
}
playlistInfo = PlaylistInfo.getInstance(mContext);
playlistsManager = PlaylistsManager.getInstance(mContext);
View view = inflater.inflate(R.layout.fragment_add_playlist, container);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.create_new_playlist);
recyclerView = (RecyclerView) view.findViewById(R.id.add_playlist_recyclerview);
linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
alertDialog.setView((mContext.getLayoutInflater().inflate(R.layout.dialog, null)));
alertDialog.show();
Window window = alertDialog.getWindow();
window.setContentView(R.layout.dialog);
final EditText editText = (EditText) (window.findViewById(R.id.message));
editText.requestFocus();
(window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
(window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
new Thread(new Runnable() {
@Override
public void run() {
Log.e("addplay", "here");
String albumart = null;
for (MusicInfo info : musics) {
albumart = info.albumData;
if (info.islocal) {
if (albumart.equals(MusicUtils.getAlbumdata(MainApplication.context, info.songId)))
break;
} else if (!TextUtils.isEmpty(albumart)) {
break;
}
}
long playlistid = editText.getText().hashCode();
playlistInfo.addPlaylist(playlistid, editText.getText().toString(), musics.size(), albumart, author);
playlistsManager.insertLists(mContext, playlistid, musics);
Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
MainApplication.context.sendBroadcast(intent);
}
}).start();
alertDialog.dismiss();
}
});
}
});
ArrayList<Playlist> playlists = playlistInfo.getPlaylist();
recyclerView.setLayoutManager(layoutManager);
AddPlaylistAdapter adapter = new AddPlaylistAdapter(playlists);
recyclerView.setAdapter(adapter);
// setItemDecoration();
return view;
}
use of android.support.v7.app.AlertDialog in project open-event-android by fossasia.
the class ScheduleFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_sort:
final AlertDialog.Builder dialogSort = new AlertDialog.Builder(context).setTitle(R.string.dialog_sort_title).setSingleChoiceItems(R.array.session_sort, sortType, (dialog, which) -> {
sortType = which;
SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_SCHEDULE, which);
notifyUpdate(-1, selectedTracks);
}).setPositiveButton(R.string.ascending, (dialog, which) -> {
sortOrder = SortOrder.SORT_ORDER_ASCENDING;
SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_ORDER, sortOrder);
notifyUpdate(-1, selectedTracks);
dialog.dismiss();
}).setNegativeButton(R.string.descending, (dialog, which) -> {
sortOrder = SortOrder.SORT_ORDER_DESCENDING;
SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_ORDER, sortOrder);
notifyUpdate(-1, selectedTracks);
dialog.dismiss();
});
AlertDialog dialog = dialogSort.show();
dialog.getButton(sortOrder == SortOrder.SORT_ORDER_ASCENDING ? AlertDialog.BUTTON_NEGATIVE : AlertDialog.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(context, android.R.color.darker_gray));
dialog.getButton(sortOrder == SortOrder.SORT_ORDER_ASCENDING ? AlertDialog.BUTTON_POSITIVE : AlertDialog.BUTTON_NEGATIVE);
dialog.show();
break;
default:
}
return super.onOptionsItemSelected(item);
}
use of android.support.v7.app.AlertDialog in project RespawnIRC-Android by FranckRJ.
the class ChoosePageNumberDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog alertToShow;
Window currentWindow;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
@SuppressLint("InflateParams") View mainView = getActivity().getLayoutInflater().inflate(R.layout.dialog_choosepagenumber, null);
pageNumberEdit = mainView.findViewById(R.id.pagenumber_edit_choosepagenumber);
pageNumberEdit.setOnEditorActionListener(actionInEditTextListener);
builder.setTitle(R.string.choosePageNumber).setView(mainView).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
}).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
pageNumberChoosed();
}
});
alertToShow = builder.create();
currentWindow = alertToShow.getWindow();
if (currentWindow != null) {
currentWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
return alertToShow;
}
Aggregations