use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.
the class WikipediaZeroHandler method identifyZeroCarrier.
private void identifyZeroCarrier(@NonNull final String xCarrierFromHeader, @NonNull final String xCarrierMetaFromHeader) {
Handler wikipediaZeroHandler = new Handler((Message msg) -> {
new ZeroConfigClient().request(new WikiSite(app.getWikiSite().mobileAuthority()), app.getUserAgent(), new ZeroConfigClient.Callback() {
@Override
public void success(@NonNull Call<ZeroConfig> call, @NonNull ZeroConfig config) {
L.i("New Wikipedia Zero config: " + config);
if (!config.isEligible()) {
acquiringCarrierMessage = false;
return;
}
// ex. "123-45"
xCarrier = xCarrierFromHeader;
zeroCarrierString = xCarrierFromHeader;
// ex. "wap"; default ""
zeroCarrierMetaString = xCarrierMetaFromHeader;
zeroConfig = config;
zeroEnabled = true;
app.getBus().post(new WikipediaZeroEnterEvent());
if (zeroConfig.hashCode() != Prefs.zeroConfigHashCode()) {
notifyEnterZeroNetwork(app, zeroConfig);
}
Prefs.zeroConfigHashCode(zeroConfig.hashCode());
acquiringCarrierMessage = false;
}
@Override
public void failure(@NonNull Call<ZeroConfig> call, @NonNull Throwable caught) {
L.w("Wikipedia Zero eligibility check failed", caught);
acquiringCarrierMessage = false;
}
});
acquiringCarrierMessage = true;
return true;
});
wikipediaZeroHandler.removeMessages(MESSAGE_ZERO_CS);
Message zeroMessage = Message.obtain();
zeroMessage.what = MESSAGE_ZERO_CS;
zeroMessage.obj = "zero_eligible_check";
wikipediaZeroHandler.sendMessage(zeroMessage);
}
use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.
the class WikiSiteTypeAdapterTest method testReadLegacyUriLang.
@Test
public void testReadLegacyUriLang() {
String json = "{\"domain\": \"test.wikipedia.org\"}";
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 WikiSiteTypeAdapterTest method testReadLegacyLang.
@Test
public void testReadLegacyLang() {
String json = "{\"domain\": \"https://test.wikipedia.org\"}";
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 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 PageTitleTest method testIsMainPageProps.
@Test
public void testIsMainPageProps() throws Throwable {
String text = "text";
WikiSite wiki = WikiSite.forLanguageCode("test");
final String thumbUrl = null;
final String desc = null;
PageProperties props = mock(PageProperties.class);
when(props.isMainPage()).thenReturn(true);
PageTitle subject = new PageTitle(text, wiki, thumbUrl, desc, props);
assertThat(subject.isMainPage(), is(true));
}
Aggregations