use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.
the class WikiSiteTypeAdapterTest method testReadLegacyUri.
@Test
public void testReadLegacyUri() {
String json = "{\"domain\": \"test.wikipedia.org\", \"languageCode\": \"test\"}";
WikiSite expected = WikiSite.forLanguageCode("test");
assertThat(unmarshal(WikiSite.class, json), is(expected));
}
use of org.wikipedia.dataclient.WikiSite 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.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.
the class NewsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.fragment_news, container, false);
unbinder = ButterKnife.bind(this, view);
gradientView.setBackground(GradientUtil.getPowerGradient(R.color.black54, Gravity.TOP));
getAppCompatActivity().setSupportActionBar(toolbar);
getAppCompatActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getAppCompatActivity().getSupportActionBar().setTitle("");
NewsItem item = GsonUnmarshaller.unmarshal(NewsItem.class, requireActivity().getIntent().getStringExtra(EXTRA_NEWS_ITEM));
WikiSite wiki = GsonUnmarshaller.unmarshal(WikiSite.class, requireActivity().getIntent().getStringExtra(EXTRA_WIKI));
Uri imageUri = item.featureImage();
if (imageUri == null) {
appBarLayout.setExpanded(false, false);
}
DeviceUtil.updateStatusBarTheme(requireActivity(), toolbar, true);
appBarLayout.addOnOffsetChangedListener((layout, offset) -> DeviceUtil.updateStatusBarTheme(requireActivity(), toolbar, (layout.getTotalScrollRange() + offset) > layout.getTotalScrollRange() / 2));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
toolBarLayout.setStatusBarScrimColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_status_bar_color));
}
image.loadImage(imageUri);
text.setText(stripHtml(item.story()));
initRecycler();
links.setAdapter(new RecyclerAdapter(item.linkCards(wiki), new Callback()));
return view;
}
use of org.wikipedia.dataclient.WikiSite 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();
disposables.add(Observable.fromCallable(new MainPageReadMoreTopicTask(age)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(entry -> getCardForHistoryEntry(entry, cb), throwable -> cb.success(Collections.emptyList())));
}
use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.
the class WikipediaApp method getWikiSite.
/**
* Default wiki for the app
* You should use PageTitle.getWikiSite() to get the article wiki
*/
@NonNull
public synchronized WikiSite getWikiSite() {
// TODO: why don't we ensure that the app language hasn't changed here instead of the client?
if (wiki == null) {
String lang = Prefs.getMediaWikiBaseUriSupportsLangCode() ? getAppOrSystemLanguageCode() : "";
WikiSite newWiki = WikiSite.forLanguageCode(lang);
// Kick off a task to retrieve the site info for the current wiki
SiteInfoClient.updateFor(newWiki);
wiki = newWiki;
return newWiki;
}
return wiki;
}
Aggregations