Search in sources :

Example 1 with SearchFragment

use of forpdateam.ru.forpda.ui.fragments.search.SearchFragment in project ForPDA by RadiationX.

the class ThemeDialogsHelper method showPostMenu.

public static void showPostMenu(Context context, IPostFunctions theme, IBaseForumPost post) {
    if (postMenu == null) {
        postMenu = new DynamicDialogMenu<>();
        postMenu.addItem(App.get().getString(R.string.reply), IPostFunctions::reply);
        postMenu.addItem(App.get().getString(R.string.quote_from_clipboard), (context1, data) -> {
            String text = Utils.readFromClipboard();
            if (text != null && !text.isEmpty()) {
                theme.quotePost(text, data);
            }
        });
        postMenu.addItem(App.get().getString(R.string.report), IPostFunctions::reportPost);
        postMenu.addItem(App.get().getString(R.string.edit), IPostFunctions::editPost);
        postMenu.addItem(App.get().getString(R.string.delete), IPostFunctions::deletePost);
        postMenu.addItem(App.get().getString(R.string.copy_link), (context1, data) -> {
            String url = "https://4pda.ru/forum/index.php?s=&showtopic=" + data.getTopicId() + "&view=findpost&p=" + data.getId();
            Utils.copyToClipBoard(url);
        });
        postMenu.addItem(App.get().getString(R.string.create_note), (context1, data) -> {
            String themeTitle = null;
            if (context1 instanceof SearchFragment) {
                SearchItem searchItem = (SearchItem) data;
                themeTitle = searchItem.getTitle();
            } else if (context1 instanceof ThemeFragment) {
                ThemeFragment themeFragment = (ThemeFragment) context1;
                themeTitle = themeFragment.currentPage.getTitle();
            }
            String title = String.format(App.get().getString(R.string.post_Topic_Nick_Number), themeTitle, data.getNick(), data.getId());
            String url = "https://4pda.ru/forum/index.php?s=&showtopic=" + data.getTopicId() + "&view=findpost&p=" + data.getId();
            NotesAddPopup.showAddNoteDialog(context, title, url);
        });
        postMenu.addItem(App.get().getString(R.string.share), (context12, data) -> {
            String url = "https://4pda.ru/forum/index.php?s=&showtopic=" + data.getTopicId() + "&view=findpost&p=" + data.getId();
            Utils.shareText(url);
        });
    }
    postMenu.disallowAll();
    if (ClientHelper.getAuthState() == ClientHelper.AUTH_STATE_LOGIN) {
        if (post.canQuote()) {
            postMenu.allow(0);
            postMenu.allow(1);
        }
        if (post.canReport())
            postMenu.allow(2);
        if (post.canEdit())
            postMenu.allow(3);
        if (post.canDelete())
            postMenu.allow(4);
    }
    postMenu.allow(5);
    postMenu.allow(6);
    postMenu.allow(7);
    postMenu.show(context, theme, post);
}
Also used : IPostFunctions(forpdateam.ru.forpda.common.webview.jsinterfaces.IPostFunctions) SearchFragment(forpdateam.ru.forpda.ui.fragments.search.SearchFragment) SearchItem(forpdateam.ru.forpda.api.search.models.SearchItem)

Aggregations

SearchItem (forpdateam.ru.forpda.api.search.models.SearchItem)1 IPostFunctions (forpdateam.ru.forpda.common.webview.jsinterfaces.IPostFunctions)1 SearchFragment (forpdateam.ru.forpda.ui.fragments.search.SearchFragment)1