use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.
the class PageActivity method loadMainPage.
/**
* Go directly to the Main Page of the current Wiki, optionally allowing state loss of the
* fragment manager. Useful for when this function is called from an AsyncTask result.
*/
public void loadMainPage(TabPosition position) {
PageTitle title = MainPageClient.getMainPageTitle();
HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_MAIN_PAGE);
loadPage(title, historyEntry, position);
}
use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.
the class PageFragment method handleInternalLink.
private void handleInternalLink(@NonNull PageTitle title) {
if (!isResumed()) {
return;
}
// in the app very well at this time.
if (title.isSpecial() || title.isTalkPage()) {
visitInExternalBrowser(getActivity(), Uri.parse(title.getMobileUri()));
return;
}
dismissBottomSheet();
if (title.namespace() != Namespace.MAIN || !isLinkPreviewEnabled() || (!DeviceUtil.isOnline() && OfflineManager.instance().titleExists(title.getDisplayText()))) {
HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_INTERNAL_LINK);
loadPage(title, historyEntry);
} else {
showLinkPreview(title, HistoryEntry.SOURCE_INTERNAL_LINK);
}
}
use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.
the class PageFragment method refreshPage.
public void refreshPage(int stagedScrollY) {
if (pageFragmentLoadState.isLoading()) {
refreshView.setRefreshing(false);
return;
}
errorView.setVisibility(View.GONE);
tabLayout.enableAllTabs();
errorState = false;
model.setCurEntry(new HistoryEntry(model.getTitle(), HistoryEntry.SOURCE_HISTORY));
loadPage(model.getTitle(), model.getCurEntry(), false, stagedScrollY, true);
}
use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.
the class PageFragment method addTimeSpentReading.
private void addTimeSpentReading(int timeSpentSec) {
if (model.getCurEntry() == null) {
return;
}
model.setCurEntry(new HistoryEntry(model.getCurEntry().getTitle(), new Date(), model.getCurEntry().getSource(), timeSpentSec));
new UpdateHistoryTask(model.getCurEntry(), app).execute();
}
use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.
the class BottomContentView method setup.
public void setup(PageFragment parentFragment, CommunicationBridge bridge, ObservableWebView webview) {
this.parentFragment = parentFragment;
this.webView = webview;
this.bridge = bridge;
setWebView(webview);
webview.addOnScrollChangeListener(this);
webview.addOnContentHeightChangedListener(this);
pageExternalLink.setPaintFlags(pageExternalLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
if (parentFragment.callback() != null) {
ListViewContextMenuListener contextMenuListener = new LongPressHandler(parentFragment);
new org.wikipedia.LongPressHandler(readMoreList, HistoryEntry.SOURCE_INTERNAL_LINK, contextMenuListener);
}
addOnLayoutChangeListener((View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) -> {
if (prevLayoutHeight == getHeight()) {
return;
}
prevLayoutHeight = getHeight();
padWebView();
});
readMoreList.setAdapter(readMoreAdapter);
readMoreList.setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {
PageTitle title = readMoreAdapter.getItem(position).getPageTitle();
HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_INTERNAL_LINK);
parentFragment.loadPage(title, historyEntry);
funnel.logSuggestionClicked(page.getTitle(), readMoreItems.getResults(), position);
});
// hide ourselves by default
hide();
}
Aggregations