use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class ReadingListDbHelperTest method testFindPageForRetrievingPages.
@Test
public void testFindPageForRetrievingPages() {
ReadingList list = readingListDbHelper.createList("Test8", "TestDesc");
PageTitle page = new PageTitle("1", WikipediaApp.getInstance().getWikiSite());
PageTitle page2 = new PageTitle("2", WikipediaApp.getInstance().getWikiSite());
PageTitle page3 = new PageTitle("3", WikipediaApp.getInstance().getWikiSite());
readingListDbHelper.addPageToList(list, page, false);
readingListDbHelper.addPageToList(list, page2, false);
readingListDbHelper.addPageToList(list, page3, false);
boolean exists = readingListDbHelper.pageExistsInList(list, page);
readingListDbHelper.deleteList(list);
List<ReadingListPage> pages = new ArrayList<>();
pages.add(new ReadingListPage(page));
pages.add(new ReadingListPage(page2));
pages.add(new ReadingListPage(page3));
readingListDbHelper.markPagesForDeletion(list, pages);
Assert.assertTrue(exists);
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class ReadingListDbHelperTest method testGetAllPagesToBeDeletedForRetrievingPages.
@Test
public void testGetAllPagesToBeDeletedForRetrievingPages() {
PageTitle page = new PageTitle("2", WikipediaApp.getInstance().getWikiSite());
ReadingListPage readingListPage = new ReadingListPage(page);
readingListPage.status(ReadingListPage.STATUS_QUEUE_FOR_DELETE);
List<ReadingListPage> pagesListToBeAdded = new ArrayList<>();
pagesListToBeAdded.add(readingListPage);
ReadingList list = readingListDbHelper.createList("Test7", "TestDesc");
readingListDbHelper.addPagesToList(list, pagesListToBeAdded, false);
List<ReadingListPage> pagesList = readingListDbHelper.getAllPagesToBeDeleted();
readingListDbHelper.deleteList(list);
readingListDbHelper.markPagesForDeletion(list, pagesListToBeAdded);
Assert.assertTrue(pagesList.size() != 0);
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class ParcelableTest method testPageImage.
@Test
public void testPageImage() throws Throwable {
WikiSite wiki = WikiSite.forLanguageCode("en");
PageTitle title = new PageTitle("Talk", "India", wiki);
PageImage pageImage = new PageImage(title, "Testing image");
TestParcelUtil.test(pageImage);
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class LangLinksActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = WikipediaApp.getInstance();
setStatusBarColor(ResourceUtil.getThemedAttributeId(this, R.attr.page_status_bar_color));
setContentView(R.layout.activity_langlinks);
if (!getIntent().getAction().equals(ACTION_LANGLINKS_FOR_TITLE)) {
throw new RuntimeException("Only ACTION_LANGLINKS_FOR_TITLE is supported");
}
langLinksList = findViewById(R.id.langlinks_list);
langLinksProgress = findViewById(R.id.langlinks_load_progress);
langLinksContainer = findViewById(R.id.langlinks_list_container);
langLinksEmpty = findViewById(R.id.langlinks_empty);
langLinksNoMatch = findViewById(R.id.langlinks_no_match);
langLinksError = findViewById(R.id.langlinks_error);
EditText langLinksFilter = findViewById(R.id.langlinks_filter);
title = getIntent().getParcelableExtra(EXTRA_PAGETITLE);
if (savedInstanceState != null && savedInstanceState.containsKey(LANGUAGE_ENTRIES_BUNDLE_KEY)) {
languageEntries = savedInstanceState.getParcelableArrayList(LANGUAGE_ENTRIES_BUNDLE_KEY);
}
client = new LangLinksClient();
fetchLangLinks();
langLinksError.setRetryClickListener((v) -> {
ViewAnimations.crossFade(langLinksError, langLinksProgress);
fetchLangLinks();
});
langLinksList.setOnItemClickListener((parent, view, position, id) -> {
PageTitle langLink = (PageTitle) parent.getAdapter().getItem(position);
app.setMruLanguageCode(langLink.getWikiSite().languageCode());
HistoryEntry historyEntry = new HistoryEntry(langLink, HistoryEntry.SOURCE_LANGUAGE_LINK);
Intent intent = PageActivity.newIntentForCurrentTab(LangLinksActivity.this, historyEntry, langLink);
setResult(ACTIVITY_RESULT_LANGLINK_SELECT, intent);
hideSoftKeyboard(LangLinksActivity.this);
finish();
});
langLinksFilter.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
// the languages might not be loaded yet...
if (langLinksList.getAdapter() == null) {
return;
}
((LangLinksAdapter) langLinksList.getAdapter()).setFilterText(s.toString());
// Check if there are no languages that match the filter
if (langLinksList.getAdapter().getCount() == 0) {
langLinksNoMatch.setVisibility(View.VISIBLE);
} else {
langLinksNoMatch.setVisibility(View.GONE);
}
}
});
}
use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.
the class LoginActivity method onForgotPasswordClick.
@OnClick(R.id.forgot_password_link)
void onForgotPasswordClick() {
PageTitle title = new PageTitle("Special:PasswordReset", WikipediaApp.getInstance().getWikiSite());
visitInExternalBrowser(this, Uri.parse(title.getMobileUri()));
}
Aggregations