use of org.wikipedia.WikipediaApp in project apps-android-wikipedia by wikimedia.
the class PageCacher method loadIntoCache.
static void loadIntoCache(@NonNull PageTitle title) {
L.d("Loading page into cache: " + title.getPrefixedText());
WikipediaApp app = WikipediaApp.getInstance();
PageImageUrlParser parser = new PageImageUrlParser(new ImageTagParser(), new PixelDensityDescriptorParser());
PageClient client = PageClientFactory.create(title.getWikiSite(), title.namespace());
app.getSessionFunnel().leadSectionFetchStart();
leadReq(client, title).enqueue(new LeadCallback(title.getWikiSite(), parser));
app.getSessionFunnel().restSectionsFetchStart();
remainingReq(client, title).enqueue(new RemainingCallback(title.getWikiSite(), parser));
}
use of org.wikipedia.WikipediaApp 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;
}
Aggregations