use of org.wikipedia.gallery.ImageLicense in project apps-android-wikipedia by wikimedia.
the class ShareHandler method shareSnippet.
private void shareSnippet(@NonNull CharSequence input) {
final String selectedText = StringUtil.sanitizeText(input.toString());
final PageTitle title = fragment.getTitle();
final String leadImageNameText = fragment.getPage().getPageProperties().getLeadImageName() != null ? fragment.getPage().getPageProperties().getLeadImageName() : "";
new ImageLicenseFetchClient().request(title.getWikiSite(), new PageTitle(Namespace.FILE.toLegacyString(), leadImageNameText, title.getWikiSite()), new ImageLicenseFetchClient.Callback() {
@Override
public void success(@NonNull Call<MwQueryResponse> call, @NonNull ImageLicense result) {
final Bitmap snippetBitmap = SnippetImage.getSnippetImage(fragment.getContext(), fragment.getLeadImageBitmap(), title.getDisplayText(), fragment.getPage().isMainPage() ? "" : StringUtils.capitalize(title.getDescription()), selectedText, result);
fragment.showBottomSheet(new PreviewDialog(fragment.getContext(), snippetBitmap, title, selectedText, funnel));
}
@Override
public void failure(@NonNull Call<MwQueryResponse> call, @NonNull Throwable caught) {
// If we failed to get license info for the lead image, just share the text
PreviewDialog.shareAsText(fragment.getContext(), title, selectedText, funnel);
L.e("Error fetching image license info for " + title.getDisplayText(), caught);
}
});
}
Aggregations