use of org.wikipedia.crash.RemoteLogException in project apps-android-wikipedia by wikimedia.
the class DeveloperSettingsPreferenceLoader method loadPreferences.
@Override
public void loadPreferences() {
loadPreferences(R.xml.developer_preferences);
setUpRestBaseCheckboxes();
setUpMediaWikiSettings();
setUpCookies((PreferenceCategory) findPreference(R.string.preferences_developer_cookies_key));
findPreference(context.getString(R.string.preferences_developer_crash_key)).setOnPreferenceClickListener(preference -> {
throw new TestException("User tested crash functionality.");
});
findPreference(R.string.preference_key_remote_log).setOnPreferenceChangeListener((preference, newValue) -> {
L.logRemoteError(new RemoteLogException(newValue.toString()));
WikipediaApp.getInstance().checkCrashes(getActivity());
return true;
});
findPreference(R.string.preference_key_add_articles).setOnPreferenceChangeListener((preference, newValue) -> {
if (newValue.toString().trim().equals("") || newValue.toString().trim().equals("0")) {
return true;
}
int numberOfArticles = Integer.valueOf(newValue.toString().trim());
createTestReadingList(TEXT_OF_TEST_READING_LIST, 1, numberOfArticles);
return true;
});
findPreference(R.string.preference_key_add_reading_lists).setOnPreferenceChangeListener((preference, newValue) -> {
if (newValue.toString().trim().equals("") || newValue.toString().trim().equals("0")) {
return true;
}
int numOfLists = Integer.valueOf(newValue.toString().trim());
createTestReadingList(TEXT_OF_READING_LIST, numOfLists, 10);
return true;
});
findPreference(R.string.preference_key_delete_reading_lists).setOnPreferenceChangeListener((preference, newValue) -> {
if (newValue.toString().trim().equals("") || newValue.toString().trim().equals("0")) {
return true;
}
int numOfLists = Integer.valueOf(newValue.toString().trim());
deleteTestReadingList(TEXT_OF_READING_LIST, numOfLists);
return true;
});
findPreference(R.string.preference_key_delete_test_reading_lists).setOnPreferenceChangeListener((preference, newValue) -> {
if (newValue.toString().trim().equals("") || newValue.toString().trim().equals("0")) {
return true;
}
int numOfLists = Integer.valueOf(newValue.toString().trim());
deleteTestReadingList(TEXT_OF_TEST_READING_LIST, numOfLists);
return true;
});
}
use of org.wikipedia.crash.RemoteLogException in project apps-android-wikipedia by wikimedia.
the class TabUnmarshaller method unmarshal.
@NonNull
public static List<Tab> unmarshal(@Nullable String json) {
List<Tab> object = null;
try {
object = GsonUnmarshaller.unmarshal(TYPE_TOKEN, json);
} catch (Exception e) {
// Catch all. Any Exception can be thrown when unmarshalling.
L.logRemoteErrorIfProd(new RemoteLogException(e).put("json", json));
}
if (object == null) {
object = Collections.emptyList();
}
// T152980
// When upgrading from much older versions (namely, 2.1.141 or earlier), the serialized
// tab list may be in a format that causes WikiSite objects to have null Uri components.
// If we encounter one of these occurrences, just clear out the entire tab list.
// to be on the safe side.
// TODO: Remove when the incidence of this is sufficiently diminished (April 2017?)
boolean bad = false;
for (Tab tab : object) {
for (PageBackStackItem item : tab.getBackStack()) {
if (TextUtils.isEmpty(item.getTitle().getWikiSite().authority()) || TextUtils.isEmpty(item.getHistoryEntry().getTitle().getWikiSite().authority())) {
L.logRemoteErrorIfProd(new IllegalArgumentException("Format error in serialized tab list."));
bad = true;
break;
}
}
}
if (bad) {
object.clear();
}
return object;
}
Aggregations