Search in sources :

Example 16 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class ParcelableTest method testHistoryEntry.

@Test
public void testHistoryEntry() throws Throwable {
    WikiSite wiki = WikiSite.forLanguageCode("en");
    PageTitle title = new PageTitle("Talk", "India", wiki);
    HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_EXTERNAL_LINK);
    TestParcelUtil.test(historyEntry);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test)

Example 17 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class BecauseYouReadClient method request.

@Override
public void request(@NonNull Context context, @NonNull final WikiSite wiki, int age, @NonNull final FeedClient.Callback cb) {
    cancel();
    readMoreTopicTask = new MainPageReadMoreTopicTask(age) {

        @Override
        public void onFinish(@Nullable HistoryEntry entry) {
            if (entry == null) {
                cb.success(Collections.emptyList());
                return;
            }
            getCardForHistoryEntry(entry, cb);
        }

        @Override
        public void onCatch(Throwable caught) {
            L.e("Error fetching 'because you read' suggestions", caught);
            cb.error(caught);
        }
    };
    readMoreTopicTask.execute();
}
Also used : HistoryEntry(org.wikipedia.history.HistoryEntry) MainPageReadMoreTopicTask(org.wikipedia.page.bottomcontent.MainPageReadMoreTopicTask)

Example 18 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class FeaturedArticleCard method historyEntry.

@NonNull
public HistoryEntry historyEntry(int source) {
    PageTitle title = new PageTitle(articleTitle(), wikiSite());
    if (image() != null) {
        title.setThumbUrl(image().toString());
    }
    title.setDescription(articleSubtitle());
    return new HistoryEntry(title, source);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) NonNull(android.support.annotation.NonNull)

Example 19 with HistoryEntry

use of org.wikipedia.history.HistoryEntry 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 20 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class PageActivity method handleIntent.

private void handleIntent(@NonNull Intent intent) {
    if (Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getData() != null) {
        WikiSite wiki = new WikiSite(intent.getData());
        PageTitle title = wiki.titleForUri(intent.getData());
        HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_EXTERNAL_LINK);
        loadPageInForegroundTab(title, historyEntry);
    } else if (ACTION_LOAD_IN_NEW_TAB.equals(intent.getAction()) || ACTION_LOAD_IN_CURRENT_TAB.equals(intent.getAction())) {
        PageTitle title = intent.getParcelableExtra(EXTRA_PAGETITLE);
        HistoryEntry historyEntry = intent.getParcelableExtra(EXTRA_HISTORYENTRY);
        if (ACTION_LOAD_IN_NEW_TAB.equals(intent.getAction())) {
            loadPageInForegroundTab(title, historyEntry);
        } else if (ACTION_LOAD_IN_CURRENT_TAB.equals(intent.getAction())) {
            loadPage(title, historyEntry, TabPosition.CURRENT_TAB);
        }
        if (intent.hasExtra(Constants.INTENT_EXTRA_REVERT_QNUMBER)) {
            showDescriptionEditRevertDialog(intent.getStringExtra(Constants.INTENT_EXTRA_REVERT_QNUMBER));
        }
    } else if (ACTION_LOAD_FROM_EXISTING_TAB.equals(intent.getAction())) {
        PageTitle title = intent.getParcelableExtra(EXTRA_PAGETITLE);
        HistoryEntry historyEntry = intent.getParcelableExtra(EXTRA_HISTORYENTRY);
        loadPage(title, historyEntry, TabPosition.EXISTING_TAB);
    } else if (ACTION_SHOW_TAB_LIST.equals(intent.getAction()) || ACTION_RESUME_READING.equals(intent.getAction()) || intent.hasExtra(Constants.INTENT_APP_SHORTCUT_CONTINUE_READING)) {
    // do nothing, since this will be handled indirectly by PageFragment.
    } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        PageTitle title = new PageTitle(query, app.getWikiSite());
        HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_SEARCH);
        loadPageInForegroundTab(title, historyEntry);
    } else if (intent.hasExtra(Constants.INTENT_FEATURED_ARTICLE_FROM_WIDGET)) {
        new IntentFunnel(app).logFeaturedArticleWidgetTap();
        loadMainPageInForegroundTab();
    } else {
        loadMainPageInCurrentTab();
    }
}
Also used : HistoryEntry(org.wikipedia.history.HistoryEntry) WikiSite(org.wikipedia.dataclient.WikiSite) IntentFunnel(org.wikipedia.analytics.IntentFunnel)

Aggregations

HistoryEntry (org.wikipedia.history.HistoryEntry)22 PageTitle (org.wikipedia.page.PageTitle)11 WikiSite (org.wikipedia.dataclient.WikiSite)5 Date (java.util.Date)4 Test (org.junit.Test)4 PageBackStackItem (org.wikipedia.page.PageBackStackItem)3 Tab (org.wikipedia.page.tabs.Tab)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 NonNull (android.support.annotation.NonNull)2 View (android.view.View)2 WebView (android.webkit.WebView)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 OnClick (butterknife.OnClick)2 IOException (java.io.IOException)2 ObservableWebView (org.wikipedia.views.ObservableWebView)2 ProgressDialog (android.app.ProgressDialog)1 Context (android.content.Context)1 AssetManager (android.content.res.AssetManager)1