Search in sources :

Example 1 with ImageInfo

use of org.wikipedia.gallery.ImageInfo in project apps-android-wikipedia by wikimedia.

the class LinkPreviewDialog method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    WikipediaApp app = WikipediaApp.getInstance();
    pageTitle = getArguments().getParcelable("title");
    entrySource = getArguments().getInt("entrySource");
    location = getArguments().getParcelable("location");
    View rootView = inflater.inflate(R.layout.dialog_link_preview, container);
    dialogContainer = rootView.findViewById(R.id.dialog_link_preview_container);
    contentContainer = rootView.findViewById(R.id.dialog_link_preview_content_container);
    errorContainer = rootView.findViewById(R.id.dialog_link_preview_error_container);
    progressBar = rootView.findViewById(R.id.link_preview_progress);
    toolbarView = rootView.findViewById(R.id.link_preview_toolbar);
    toolbarView.setOnClickListener(goToPageListener);
    titleText = rootView.findViewById(R.id.link_preview_title);
    setConditionalLayoutDirection(rootView, pageTitle.getWikiSite().languageCode());
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        // for <5.0, give the title a bit more bottom padding, since these versions
        // incorrectly cut off the bottom of the text when line spacing is <1.
        final int bottomPadding = 8;
        ViewUtil.setBottomPaddingDp(titleText, bottomPadding);
    }
    extractText = rootView.findViewById(R.id.link_preview_extract);
    thumbnailView = rootView.findViewById(R.id.link_preview_thumbnail);
    thumbnailGallery = rootView.findViewById(R.id.link_preview_thumbnail_gallery);
    if (isImageDownloadEnabled()) {
        CallbackTask.execute(() -> client.request(pageTitle.getWikiSite(), pageTitle, true), new CallbackTask.Callback<Map<String, ImageInfo>>() {

            @Override
            public void success(@Nullable Map<String, ImageInfo> result) {
                setThumbGallery(result);
                thumbnailGallery.setGalleryViewListener(galleryViewListener);
            }

            @Override
            public void failure(Throwable caught) {
                L.w("Failed to fetch gallery collection.", caught);
            }
        });
    }
    overflowButton = rootView.findViewById(R.id.link_preview_overflow_button);
    overflowButton.setOnClickListener((View v) -> {
        PopupMenu popupMenu = new PopupMenu(getActivity(), overflowButton);
        popupMenu.inflate(R.menu.menu_link_preview);
        popupMenu.setOnMenuItemClickListener(menuListener);
        popupMenu.show();
    });
    // show the progress bar while we load content...
    progressBar.setVisibility(View.VISIBLE);
    // and kick off the task to load all the things...
    loadContent();
    funnel = new LinkPreviewFunnel(app, entrySource);
    funnel.logLinkClick();
    return rootView;
}
Also used : LinkPreviewFunnel(org.wikipedia.analytics.LinkPreviewFunnel) CallbackTask(org.wikipedia.concurrency.CallbackTask) WikipediaApp(org.wikipedia.WikipediaApp) GalleryThumbnailScrollView(org.wikipedia.gallery.GalleryThumbnailScrollView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) TextView(android.widget.TextView) ImageInfo(org.wikipedia.gallery.ImageInfo) Map(java.util.Map) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

PopupMenu (android.support.v7.widget.PopupMenu)1 View (android.view.View)1 TextView (android.widget.TextView)1 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)1 Map (java.util.Map)1 WikipediaApp (org.wikipedia.WikipediaApp)1 LinkPreviewFunnel (org.wikipedia.analytics.LinkPreviewFunnel)1 CallbackTask (org.wikipedia.concurrency.CallbackTask)1 GalleryThumbnailScrollView (org.wikipedia.gallery.GalleryThumbnailScrollView)1 ImageInfo (org.wikipedia.gallery.ImageInfo)1