Search in sources :

Example 51 with PageTitle

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;
}
Also used : PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) OnLongClick(butterknife.OnLongClick)

Example 52 with PageTitle

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;
}
Also used : Bundle(android.os.Bundle) PageTitle(org.wikipedia.page.PageTitle)

Example 53 with PageTitle

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);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) WikiSite(org.wikipedia.dataclient.WikiSite) Date(java.util.Date)

Example 54 with PageTitle

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);
        }
    });
}
Also used : NonNull(android.support.annotation.NonNull) PageTitle(org.wikipedia.page.PageTitle) Marker(com.mapbox.mapboxsdk.annotations.Marker) MapboxMap(com.mapbox.mapboxsdk.maps.MapboxMap)

Example 55 with PageTitle

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);
    }
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage)

Aggregations

PageTitle (org.wikipedia.page.PageTitle)60 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)15 WikiSite (org.wikipedia.dataclient.WikiSite)11 HistoryEntry (org.wikipedia.history.HistoryEntry)11 NonNull (android.support.annotation.NonNull)6 OnClick (butterknife.OnClick)5 ReadingListPage (org.wikipedia.readinglist.database.ReadingListPage)5 IOException (java.io.IOException)4 Date (java.util.Date)4 WikipediaApp (org.wikipedia.WikipediaApp)3 PageBackStackItem (org.wikipedia.page.PageBackStackItem)3 Tab (org.wikipedia.page.tabs.Tab)3 ProgressDialog (android.app.ProgressDialog)2 Intent (android.content.Intent)2 AssetManager (android.content.res.AssetManager)2 Configuration (android.content.res.Configuration)2 Resources (android.content.res.Resources)2 Bundle (android.os.Bundle)2 DisplayMetrics (android.util.DisplayMetrics)2