use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class OnThisDayPagesViewHolder method showOverflowMenu.
@OnLongClick(R.id.parent)
boolean showOverflowMenu(View anchorView) {
PageTitle pageTitle = new PageTitle(selectedPage.getTitle(), wiki);
HistoryEntry entry = new HistoryEntry(pageTitle, isSingleCard ? HistoryEntry.SOURCE_ON_THIS_DAY_CARD : HistoryEntry.SOURCE_ON_THIS_DAY_ACTIVITY);
itemCallback.onActionLongClick(entry);
return true;
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class GalleryItemFragment method newInstance.
public static GalleryItemFragment newInstance(@Nullable PageTitle pageTitle, @NonNull WikiSite wiki, @NonNull GalleryItem galleryItemProto) {
GalleryItemFragment f = new GalleryItemFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_PAGETITLE, pageTitle);
args.putParcelable(ARG_MEDIATITLE, new PageTitle(galleryItemProto.getName(), wiki));
args.putString(ARG_MIMETYPE, galleryItemProto.getMimeType());
if (galleryItemProto instanceof FeaturedImageGalleryItem) {
args.putBoolean(ARG_FEED_FEATURED_IMAGE, true);
args.putInt(ARG_AGE, ((FeaturedImageGalleryItem) galleryItemProto).getAge());
}
f.setArguments(args);
return f;
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class HistoryEntryDatabaseTable method fromCursor.
@Override
public HistoryEntry fromCursor(Cursor cursor) {
WikiSite wiki = new WikiSite(Col.SITE.val(cursor), Col.LANG.val(cursor));
PageTitle title = new PageTitle(Col.NAMESPACE.val(cursor), Col.TITLE.val(cursor), wiki);
Date timestamp = Col.TIMESTAMP.val(cursor);
int source = Col.SOURCE.val(cursor);
return new HistoryEntry(title, timestamp, source);
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class NearbyFragment method initializeMap.
private void initializeMap() {
mapView.getMapAsync((@NonNull MapboxMap mapboxMap) -> {
if (!isAdded()) {
return;
}
NearbyFragment.this.mapboxMap = mapboxMap;
enableUserLocationMarker();
mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
mapboxMap.setOnScrollListener(this::fetchNearbyPages);
mapboxMap.setOnMarkerClickListener((@NonNull Marker marker) -> {
NearbyPage page = findNearbyPageFromMarker(marker);
if (page != null) {
PageTitle title = new PageTitle(page.getTitle(), lastResult.getWiki(), page.getThumbUrl());
onLoadPage(title, HistoryEntry.SOURCE_NEARBY, page.getLocation());
return true;
} else {
return false;
}
});
if (lastCameraPos != null) {
mapboxMap.setCameraPosition(lastCameraPos);
} else {
goToUserLocationOrPromptPermissions();
}
if (lastResult != null) {
showNearbyPages(lastResult);
}
});
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class ReadingListSyncAdapter method createOrUpdatePage.
private void createOrUpdatePage(@NonNull ReadingList listForPage, @NonNull RemoteReadingListEntry remotePage) {
PageTitle remoteTitle = pageTitleFromRemoteEntry(remotePage);
ReadingListPage localPage = null;
boolean updateOnly = false;
for (ReadingListPage page : listForPage.pages()) {
if (ReadingListPage.toPageTitle(page).equals(remoteTitle)) {
localPage = page;
updateOnly = true;
break;
}
}
if (localPage == null) {
localPage = new ReadingListPage(pageTitleFromRemoteEntry(remotePage));
localPage.listId(listForPage.id());
if (ReadingListDbHelper.instance().pageExistsInList(listForPage, remoteTitle)) {
updateOnly = true;
}
}
localPage.remoteId(remotePage.id());
if (remotePage.summary() != null) {
localPage.description(remotePage.summary().getDescription());
localPage.thumbUrl(remotePage.summary().getThumbnailUrl());
}
if (updateOnly) {
L.d("Updating local page " + localPage.title());
ReadingListDbHelper.instance().updatePage(localPage);
} else {
L.d("Creating local page " + localPage.title());
ReadingListDbHelper.instance().addPagesToList(listForPage, Collections.singletonList(localPage), false);
}
}
Aggregations