Search in sources :

Example 1 with EditTextDialogBuilder

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;
}
Also used : Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) EditTextDialogBuilder(com.hippo.app.EditTextDialogBuilder)

Example 2 with EditTextDialogBuilder

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);
            }
        }
    });
}
Also used : Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) ListUrlBuilder(com.hippo.ehviewer.client.data.ListUrlBuilder) QuickSearch(com.hippo.ehviewer.dao.QuickSearch) EditTextDialogBuilder(com.hippo.app.EditTextDialogBuilder) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 3 with EditTextDialogBuilder

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();
        }
    });
}
Also used : Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) EditTextDialogBuilder(com.hippo.app.EditTextDialogBuilder) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ListView(android.widget.ListView) Point(android.graphics.Point)

Example 4 with EditTextDialogBuilder

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();
    });
}
Also used : Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) EditTextDialogBuilder(com.hippo.app.EditTextDialogBuilder) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Aggregations

Context (android.content.Context)4 AlertDialog (androidx.appcompat.app.AlertDialog)4 EditTextDialogBuilder (com.hippo.app.EditTextDialogBuilder)4 Point (android.graphics.Point)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)2 EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)2 SuppressLint (android.annotation.SuppressLint)1 ListUrlBuilder (com.hippo.ehviewer.client.data.ListUrlBuilder)1 QuickSearch (com.hippo.ehviewer.dao.QuickSearch)1