use of com.hippo.app.EditTextDialogBuilder in project EhViewer by seven332.
the class DownloadLabelsScene method onMenuItemClick.
@Override
public boolean onMenuItemClick(MenuItem item) {
Context context = getContext2();
if (null == context) {
return false;
}
int id = item.getItemId();
switch(id) {
case R.id.action_add:
{
EditTextDialogBuilder builder = new EditTextDialogBuilder(context, null, getString(R.string.download_labels));
builder.setTitle(R.string.new_label_title);
builder.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.show();
new NewLabelDialogHelper(builder, dialog);
}
}
return false;
}
use of com.hippo.app.EditTextDialogBuilder in project EhViewer by seven332.
the class GalleryListScene method showAddQuickSearchDialog.
private void showAddQuickSearchDialog(final List<QuickSearch> list, final ArrayAdapter<QuickSearch> adapter, final ListView listView, final TextView tip) {
Context context = getContext2();
final ListUrlBuilder urlBuilder = mUrlBuilder;
if (null == context || null == urlBuilder) {
return;
}
// Can't add image search as quick search
if (ListUrlBuilder.MODE_IMAGE_SEARCH == urlBuilder.getMode()) {
showTip(R.string.image_search_not_quick_search, LENGTH_LONG);
return;
}
// Check duplicate
for (QuickSearch q : list) {
if (urlBuilder.equalsQuickSearch(q)) {
showTip(getString(R.string.duplicate_quick_search, q.name), LENGTH_LONG);
return;
}
}
final EditTextDialogBuilder builder = new EditTextDialogBuilder(context, getSuitableTitleForUrlBuilder(context.getResources(), urlBuilder, false), getString(R.string.quick_search));
builder.setTitle(R.string.add_quick_search_dialog_title);
builder.setPositiveButton(android.R.string.ok, null);
final AlertDialog dialog = builder.show();
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text = builder.getText().trim();
// Check name empty
if (TextUtils.isEmpty(text)) {
builder.setError(getString(R.string.name_is_empty));
return;
}
// Check name duplicate
for (QuickSearch q : list) {
if (text.equals(q.name)) {
builder.setError(getString(R.string.duplicate_name));
return;
}
}
builder.setError(null);
dialog.dismiss();
QuickSearch quickSearch = urlBuilder.toQuickSearch();
quickSearch.name = text;
EhDB.insertQuickSearch(quickSearch);
list.add(quickSearch);
adapter.notifyDataSetChanged();
if (0 == list.size()) {
tip.setVisibility(View.VISIBLE);
listView.setVisibility(View.GONE);
} else {
tip.setVisibility(View.GONE);
listView.setVisibility(View.VISIBLE);
}
}
});
}
use of com.hippo.app.EditTextDialogBuilder in project EhViewer by seven332.
the class GalleryListScene method showGoToDialog.
private void showGoToDialog() {
Context context = getContext2();
if (null == context || null == mHelper) {
return;
}
final int page = mHelper.getPageForTop();
final int pages = mHelper.getPages();
String hint = getString(R.string.go_to_hint, page + 1, pages);
final EditTextDialogBuilder builder = new EditTextDialogBuilder(context, null, hint);
builder.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
final AlertDialog dialog = builder.setTitle(R.string.go_to).setPositiveButton(android.R.string.ok, null).show();
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null == mHelper) {
dialog.dismiss();
return;
}
String text = builder.getText().trim();
int goTo;
try {
goTo = Integer.parseInt(text) - 1;
} catch (NumberFormatException e) {
builder.setError(getString(R.string.error_invalid_number));
return;
}
if (goTo < 0 || goTo >= pages) {
builder.setError(getString(R.string.error_out_of_range));
return;
}
builder.setError(null);
mHelper.goTo(goTo);
AppHelper.hideSoftInput(dialog);
dialog.dismiss();
}
});
}
use of com.hippo.app.EditTextDialogBuilder in project EhViewer by seven332.
the class FavoritesScene method showGoToDialog.
private void showGoToDialog() {
Context context = getContext2();
if (null == context || null == mHelper) {
return;
}
final int page = mHelper.getPageForTop();
final int pages = mHelper.getPages();
String hint = getString(R.string.go_to_hint, page + 1, pages);
final EditTextDialogBuilder builder = new EditTextDialogBuilder(context, null, hint);
builder.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
final AlertDialog dialog = builder.setTitle(R.string.go_to).setPositiveButton(android.R.string.ok, null).show();
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
if (null == mHelper) {
dialog.dismiss();
return;
}
String text = builder.getText().trim();
int goTo;
try {
goTo = Integer.parseInt(text) - 1;
} catch (NumberFormatException e) {
builder.setError(getString(R.string.error_invalid_number));
return;
}
if (goTo < 0 || goTo >= pages) {
builder.setError(getString(R.string.error_out_of_range));
return;
}
builder.setError(null);
mHelper.goTo(goTo);
AppHelper.hideSoftInput(dialog);
dialog.dismiss();
});
}
Aggregations