Commit 2046f416 authored by Thomas's avatar Thomas
Browse files

Change json parser + new file version on server

parent 7e8248e5
......@@ -55,8 +55,9 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.android.material:material:1.4.0'
//Don't upgrade until there is a fix with barrier in recycler view
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.preference:preference:1.1.1'
implementation 'org.jsoup:jsoup:1.13.1'
testImplementation 'junit:junit:4.13.1'
......
......@@ -30,6 +30,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.google.android.material.snackbar.Snackbar;
import java.util.ArrayList;
import java.util.List;
import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.adapters.InstanceAdapter;
......@@ -40,7 +41,7 @@ import app.fedilab.nitterizeme.viewmodels.SearchInstanceVM;
public class InstanceActivity extends AppCompatActivity {
private static final String list_for_instances = "https://framagit.org/tom79/fedilab_app/-/blob/master/content/untrackme_instances/payload_2.json";
private static final String list_for_instances = "https://framagit.org/tom79/fedilab_app/-/blob/master/content/untrackme_instances/payload_3.json";
private ActivityPopupInstanceBinding binding;
@Override
......@@ -64,67 +65,101 @@ public class InstanceActivity extends AppCompatActivity {
String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST);
String bibliogramHost = sharedpreferences.getString(MainActivity.SET_BIBLIOGRAM_HOST, MainActivity.DEFAULT_BIBLIOGRAM_HOST);
String tedditHost = sharedpreferences.getString(MainActivity.SET_TEDDIT_HOST, MainActivity.DEFAULT_TEDDIT_HOST);
String scribeHost = sharedpreferences.getString(MainActivity.SET_SCRIBERIP_HOST, MainActivity.DEFAULT_SCRIBERIP_HOST);
String wikilessHost = sharedpreferences.getString(MainActivity.SET_WIKILESS_HOST, MainActivity.DEFAULT_WIKILESS_HOST);
ArrayList<Instance> invidiousInstances = new ArrayList<>();
ArrayList<Instance> nitterInstances = new ArrayList<>();
ArrayList<Instance> bibliogramInstances = new ArrayList<>();
ArrayList<Instance> tedditInstances = new ArrayList<>();
ArrayList<Instance> scribeInstances = new ArrayList<>();
ArrayList<Instance> wikilessInstances = new ArrayList<>();
boolean customInvidiousInstance = true;
boolean customNitterInstance = true;
boolean customBibliogramInstance = true;
boolean customTedditInstance = true;
boolean customScribeInstance = true;
boolean customWikilessInstance = true;
for (Instance instance : result) {
if (instance.getType() == Instance.instanceType.INVIDIOUS) {
if (instance.getInstanceType() == Instance.instanceType.YOUTUBE) {
invidiousInstances.add(instance);
if (invidiousHost != null && invidiousHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customInvidiousInstance = false;
}
} else if (instance.getType() == Instance.instanceType.NITTER) {
} else if (instance.getInstanceType() == Instance.instanceType.TWITTER) {
nitterInstances.add(instance);
if (nitterHost != null && nitterHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customNitterInstance = false;
}
} else if (instance.getType() == Instance.instanceType.BIBLIOGRAM) {
} else if (instance.getInstanceType() == Instance.instanceType.INSTAGRAM) {
bibliogramInstances.add(instance);
if (bibliogramHost != null && bibliogramHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customBibliogramInstance = false;
}
} else if (instance.getType() == Instance.instanceType.TEDDIT) {
} else if (instance.getInstanceType() == Instance.instanceType.REDDIT) {
tedditInstances.add(instance);
if (tedditHost != null && tedditHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customTedditInstance = false;
}
} else if (instance.getInstanceType() == Instance.instanceType.MEDIUM) {
scribeInstances.add(instance);
if (scribeHost != null && scribeHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customScribeInstance = false;
}
} else if (instance.getInstanceType() == Instance.instanceType.WIKIPEDIA) {
wikilessInstances.add(instance);
if (wikilessHost != null && wikilessHost.trim().toLowerCase().compareTo(instance.getDomain()) == 0) {
customWikilessInstance = false;
}
}
}
List<String> defaultLocales = new ArrayList<>();
defaultLocales.add("--");
//Check if custom instances are also added
if (customInvidiousInstance) {
Instance instance = new Instance();
instance.setChecked(true);
instance.setDomain(invidiousHost);
instance.setLocale("--");
instance.setLocales(defaultLocales);
invidiousInstances.add(0, instance);
}
if (customNitterInstance) {
Instance instance = new Instance();
instance.setChecked(true);
instance.setDomain(nitterHost);
instance.setLocale("--");
instance.setLocales(defaultLocales);
nitterInstances.add(0, instance);
}
if (customBibliogramInstance) {
Instance instance = new Instance();
instance.setChecked(true);
instance.setDomain(bibliogramHost);
instance.setLocale("--");
instance.setLocales(defaultLocales);
bibliogramInstances.add(0, instance);
}
if (customTedditInstance) {
Instance instance = new Instance();
instance.setChecked(true);
instance.setDomain(tedditHost);
instance.setLocale("--");
instance.setLocales(defaultLocales);
tedditInstances.add(0, instance);
}
if (customScribeInstance) {
Instance instance = new Instance();
instance.setChecked(true);
instance.setDomain(scribeHost);
instance.setLocales(defaultLocales);
scribeInstances.add(0, instance);
}
if (customWikilessInstance) {
Instance instance = new Instance();
instance.setChecked(true);
instance.setDomain(wikilessHost);
instance.setLocales(defaultLocales);
wikilessInstances.add(0, instance);
}
binding.instanceContainer.setVisibility(View.VISIBLE);
binding.loader.setVisibility(View.GONE);
......@@ -155,11 +190,23 @@ public class InstanceActivity extends AppCompatActivity {
binding.tedditInstances.setNestedScrollingEnabled(false);
final LinearLayoutManager sLayoutManager = new LinearLayoutManager(this);
InstanceAdapter scribeAdapter = new InstanceAdapter(scribeInstances);
binding.scribeInstances.setAdapter(scribeAdapter);
binding.scribeInstances.setLayoutManager(sLayoutManager);
binding.scribeInstances.setNestedScrollingEnabled(false);
final LinearLayoutManager wLayoutManager = new LinearLayoutManager(this);
InstanceAdapter wikilessAdapter = new InstanceAdapter(wikilessInstances);
binding.wikilessInstances.setAdapter(wikilessAdapter);
binding.wikilessInstances.setLayoutManager(wLayoutManager);
binding.wikilessInstances.setNestedScrollingEnabled(false);
binding.latencyTest.setOnClickListener(v -> {
invidiousAdapter.evalLatency();
nitterAdapter.evalLatency();
bibliogramAdapter.evalLatency();
tedditAdapter.evalLatency();
tedditAdapter.evalLatency();
}
);
......
......@@ -39,7 +39,10 @@ import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_HOST;
public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
......@@ -90,8 +93,12 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
holder.binding.latency.setVisibility(View.VISIBLE);
holder.binding.progress.setVisibility(View.GONE);
}
holder.binding.locale.setText(instance.getLocale());
List<String> locales = instance.getLocales();
StringBuilder locale = new StringBuilder();
for (String _l : locales) {
locale.append(_l).append(" ");
}
holder.binding.locale.setText(locale.toString());
if (instance.isCloudflare()) {
holder.binding.useCloudflare.setVisibility(View.VISIBLE);
holder.binding.useCloudflare.setOnClickListener(v -> Toast.makeText(context, R.string.cloudflare, Toast.LENGTH_SHORT).show());
......@@ -109,8 +116,8 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
instance.setChecked(true);
SharedPreferences.Editor editor = sharedpreferences.edit();
switch (instance.getType()) {
case INVIDIOUS:
switch (instance.getInstanceType()) {
case YOUTUBE:
if (isChecked) {
editor.putString(SET_INVIDIOUS_HOST, instance.getDomain().trim());
} else {
......@@ -118,7 +125,7 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
editor.apply();
break;
case NITTER:
case TWITTER:
if (isChecked) {
editor.putString(SET_NITTER_HOST, instance.getDomain().trim());
} else {
......@@ -126,7 +133,7 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
editor.apply();
break;
case BIBLIOGRAM:
case INSTAGRAM:
if (isChecked) {
editor.putString(SET_BIBLIOGRAM_HOST, instance.getDomain().trim());
} else {
......@@ -134,7 +141,7 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
editor.apply();
break;
case TEDDIT:
case REDDIT:
if (isChecked) {
editor.putString(SET_TEDDIT_HOST, instance.getDomain().trim());
} else {
......@@ -142,6 +149,22 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
editor.apply();
break;
case MEDIUM:
if (isChecked) {
editor.putString(SET_SCRIBERIP_HOST, instance.getDomain().trim());
} else {
editor.putString(SET_SCRIBERIP_HOST, null);
}
editor.apply();
break;
case WIKIPEDIA:
if (isChecked) {
editor.putString(SET_WIKILESS_HOST, instance.getDomain().trim());
} else {
editor.putString(SET_WIKILESS_HOST, null);
}
editor.apply();
break;
}
instanceAdapter.notifyItemRangeChanged(0, instances.size());
......
package app.fedilab.nitterizeme.entities;
import java.util.List;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
......@@ -16,12 +18,14 @@ package app.fedilab.nitterizeme.entities;
* see <http://www.gnu.org/licenses>. */
public class Instance {
private String domain;
private long latency = -1;
private boolean checked = false;
private instanceType type;
private instanceType instanceType;
private boolean cloudflare = false;
private String locale;
private List<String> locales;
private String type;
public String getDomain() {
return domain;
......@@ -47,14 +51,6 @@ public class Instance {
this.checked = checked;
}
public instanceType getType() {
return type;
}
public void setType(instanceType type) {
this.type = type;
}
public boolean isCloudflare() {
return cloudflare;
}
......@@ -63,18 +59,37 @@ public class Instance {
this.cloudflare = cloudflare;
}
public String getLocale() {
return locale;
public List<String> getLocales() {
return locales;
}
public void setLocales(List<String> locales) {
this.locales = locales;
}
public void setLocale(String locale) {
this.locale = locale;
public Instance.instanceType getInstanceType() {
return instanceType;
}
public void setInstanceType(Instance.instanceType instanceType) {
this.instanceType = instanceType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public enum instanceType {
INVIDIOUS,
NITTER,
BIBLIOGRAM,
TEDDIT
YOUTUBE,
TWITTER,
INSTAGRAM,
REDDIT,
MEDIUM,
WIKIPEDIA
}
}
......@@ -42,11 +42,15 @@ import static app.fedilab.nitterizeme.activities.MainActivity.APP_PREFS;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.DEFAULT_WIKILESS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_SCRIBERIP_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_TEDDIT_HOST;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_WIKILESS_HOST;
public class SearchInstanceVM extends AndroidViewModel {
private MutableLiveData<List<Instance>> instancesMLD;
......@@ -81,7 +85,7 @@ public class SearchInstanceVM extends AndroidViewModel {
HttpsURLConnection httpsURLConnection;
ArrayList<Instance> instances = new ArrayList<>();
try {
String instances_url = "https://fedilab.app/untrackme_instances/payload_2.json";
String instances_url = "https://fedilab.app/untrackme_instances/payload_3.json";
URL url = new URL(instances_url);
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setConnectTimeout(10 * 1000);
......@@ -98,70 +102,173 @@ public class SearchInstanceVM extends AndroidViewModel {
}
httpsURLConnection.getInputStream().close();
SharedPreferences sharedpreferences = getApplication().getApplicationContext().getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
String defaultInvidious = sharedpreferences.getString(SET_INVIDIOUS_HOST, DEFAULT_INVIDIOUS_HOST);
String defaultNitter = sharedpreferences.getString(SET_NITTER_HOST, DEFAULT_NITTER_HOST);
String defaultTeddit = sharedpreferences.getString(SET_TEDDIT_HOST, DEFAULT_TEDDIT_HOST);
String defaultBibliogram = sharedpreferences.getString(SET_BIBLIOGRAM_HOST, DEFAULT_BIBLIOGRAM_HOST);
String defaultYoutube = sharedpreferences.getString(SET_INVIDIOUS_HOST, DEFAULT_INVIDIOUS_HOST);
String defaultTwitter = sharedpreferences.getString(SET_NITTER_HOST, DEFAULT_NITTER_HOST);
String defaultReddit = sharedpreferences.getString(SET_TEDDIT_HOST, DEFAULT_TEDDIT_HOST);
String defaultInstagram = sharedpreferences.getString(SET_BIBLIOGRAM_HOST, DEFAULT_BIBLIOGRAM_HOST);
String defaultMedium = sharedpreferences.getString(SET_SCRIBERIP_HOST, DEFAULT_SCRIBERIP_HOST);
String defaultWikipedia = sharedpreferences.getString(SET_WIKILESS_HOST, DEFAULT_WIKILESS_HOST);
if (response != null) {
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArrayInvidious = jsonObject.getJSONArray("invidious");
JSONArray jsonArrayNitter = jsonObject.getJSONArray("nitter");
JSONArray jsonArrayTeddit = jsonObject.getJSONArray("teddit");
JSONArray jsonArrayBibliogram = jsonObject.getJSONArray("bibliogram");
for (int i = 0; i < jsonArrayInvidious.length(); i++) {
JSONArray jsonArrayYoutube = jsonObject.getJSONArray("Youtube");
JSONArray jsonArrayTwitter = jsonObject.getJSONArray("Twitter");
JSONArray jsonArrayInstagram = jsonObject.getJSONArray("Instagram");
JSONArray jsonArrayReddit = jsonObject.getJSONArray("Reddit");
JSONArray jsonArrayMedium = jsonObject.getJSONArray("Medium");
JSONArray jsonArrayWikipedia = jsonObject.getJSONArray("Wikipedia");
for (int i = 0; i < jsonArrayYoutube.length(); i++) {
Instance instance = new Instance();
String domain = jsonArrayInvidious.getJSONObject(i).getString("domain");
boolean cloudFlare = jsonArrayInvidious.getJSONObject(i).getBoolean("cloudflare");
String locale = jsonArrayInvidious.getJSONObject(i).getString("locale");
String domain = jsonArrayYoutube.getJSONObject(i).getString("domain");
String type = jsonArrayYoutube.getJSONObject(i).getString("type");
boolean cloudFlare = jsonArrayYoutube.getJSONObject(i).getBoolean("cloudflare");
List<String> localesList = new ArrayList<>();
if (jsonArrayYoutube.getJSONObject(i).has("country")) {
JSONArray locales = jsonArrayYoutube.getJSONObject(i).getJSONArray("country");
for (int j = 0; j < locales.length(); j++) {
localesList.add(locales.getString(j));
}
} else {
localesList.add("--");
}
instance.setLocales(localesList);
instance.setDomain(domain);
instance.setType(type);
instance.setCloudflare(cloudFlare);
instance.setInstanceType(Instance.instanceType.YOUTUBE);
if (defaultYoutube != null && domain.compareTo(defaultYoutube) == 0) {
instance.setChecked(true);
}
instances.add(instance);
}
for (int i = 0; i < jsonArrayTwitter.length(); i++) {
Instance instance = new Instance();
String domain = jsonArrayTwitter.getJSONObject(i).getString("domain");
String type = jsonArrayTwitter.getJSONObject(i).getString("type");
boolean cloudFlare = jsonArrayTwitter.getJSONObject(i).getBoolean("cloudflare");
List<String> localesList = new ArrayList<>();
if (jsonArrayTwitter.getJSONObject(i).has("country")) {
JSONArray locales = jsonArrayTwitter.getJSONObject(i).getJSONArray("country");
for (int j = 0; j < locales.length(); j++) {
localesList.add(locales.getString(j));
}
} else {
localesList.add("--");
}
instance.setLocales(localesList);
instance.setDomain(domain);
instance.setType(type);
instance.setCloudflare(cloudFlare);
instance.setInstanceType(Instance.instanceType.TWITTER);
if (defaultTwitter != null && domain.compareTo(defaultTwitter) == 0) {
instance.setChecked(true);
}
instances.add(instance);
}
for (int i = 0; i < jsonArrayInstagram.length(); i++) {
Instance instance = new Instance();
String domain = jsonArrayInstagram.getJSONObject(i).getString("domain");
String type = jsonArrayInstagram.getJSONObject(i).getString("type");
boolean cloudFlare = jsonArrayInstagram.getJSONObject(i).getBoolean("cloudflare");
List<String> localesList = new ArrayList<>();
if (jsonArrayInstagram.getJSONObject(i).has("country")) {
JSONArray locales = jsonArrayInstagram.getJSONObject(i).getJSONArray("country");
for (int j = 0; j < locales.length(); j++) {
localesList.add(locales.getString(j));
}
} else {
localesList.add("--");
}
instance.setLocales(localesList);
instance.setDomain(domain);
instance.setType(type);
instance.setCloudflare(cloudFlare);
instance.setLocale(locale);
instance.setType(Instance.instanceType.INVIDIOUS);
if (defaultInvidious != null && domain.compareTo(defaultInvidious) == 0) {
instance.setInstanceType(Instance.instanceType.INSTAGRAM);
if (defaultInstagram != null && domain.compareTo(defaultInstagram) == 0) {
instance.setChecked(true);
}
instances.add(instance);
}
for (int i = 0; i < jsonArrayNitter.length(); i++) {
for (int i = 0; i < jsonArrayReddit.length(); i++) {
Instance instance = new Instance();
String domain = jsonArrayNitter.getJSONObject(i).getString("domain");
boolean cloudFlare = jsonArrayNitter.getJSONObject(i).getBoolean("cloudflare");
String locale = jsonArrayNitter.getJSONObject(i).getString("locale");
String domain = jsonArrayReddit.getJSONObject(i).getString("domain");
String type = jsonArrayReddit.getJSONObject(i).getString("type");
boolean cloudFlare = jsonArrayReddit.getJSONObject(i).getBoolean("cloudflare");
List<String> localesList = new ArrayList<>();
if (jsonArrayReddit.getJSONObject(i).has("country")) {
JSONArray locales = jsonArrayReddit.getJSONObject(i).getJSONArray("country");
for (int j = 0; j < locales.length(); j++) {
localesList.add(locales.getString(j));
}
} else {
localesList.add("--");
}
instance.setLocales(localesList);
instance.setDomain(domain);
instance.setType(type);
instance.setCloudflare(cloudFlare);
instance.setLocale(locale);
instance.setType(Instance.instanceType.NITTER);
if (defaultNitter != null && domain.compareTo(defaultNitter) == 0) {
instance.setInstanceType(Instance.instanceType.REDDIT);
if (defaultReddit != null && domain.compareTo(defaultReddit) == 0) {
instance.setChecked(true);
}
instances.add(instance);
}
for (int i = 0; i < jsonArrayBibliogram.length(); i++) {
for (int i = 0; i < jsonArrayMedium.length(); i++) {
Instance instance = new Instance();
String domain = jsonArrayBibliogram.getJSONObject(i).getString("domain");
boolean cloudFlare = jsonArrayBibliogram.getJSONObject(i).getBoolean("cloudflare");
String locale = jsonArrayBibliogram.getJSONObject(i).getString("locale");
String domain = jsonArrayMedium.getJSONObject(i).getString("domain");
String type = jsonArrayMedium.getJSONObject(i).getString("type");
boolean cloudFlare = jsonArrayMedium.getJSONObject(i).getBoolean("cloudflare");
List<String> localesList = new ArrayList<>();
if (jsonArrayMedium.getJSONObject(i).has("country")) {
JSONArray locales = jsonArrayMedium.getJSONObject(i).getJSONArray("country");
for (int j = 0; j < locales.length(); j++) {
localesList.add(locales.getString(j));
}
} else {
localesList.add("--");
}
instance.setLocales(localesList);
instance.setDomain(domain);
instance.setType(type);
instance.setCloudflare(cloudFlare);
instance.setLocale(locale);
instance.setType(Instance.instanceType.BIBLIOGRAM);
if (defaultBibliogram != null && domain.compareTo(defaultBibliogram) == 0) {
instance.setInstanceType(Instance.instanceType.MEDIUM);
if (defaultMedium != null && domain.compareTo(defaultMedium) == 0) {
instance.setChecked(true);
}
instances.add(instance);
}
for (int i = 0; i < jsonArrayTeddit.length(); i++) {
for (int i = 0; i < jsonArrayWikipedia.length(); i++) {
Instance instance = new Instance();
String domain = jsonArrayTeddit.getJSONObject(i).getString("domain");
boolean cloudFlare = jsonArrayTeddit.getJSONObject(i).getBoolean("cloudflare");
String locale = jsonArrayTeddit.getJSONObject(i).getString("locale");
String domain = jsonArrayWikipedia.getJSONObject(i).getString("domain");
String type = jsonArrayWikipedia.getJSONObject(i).getString("type");
boolean cloudFlare = jsonArrayWikipedia.getJSONObject(i).getBoolean("cloudflare");
List<String> localesList = new ArrayList<>();
if (jsonArrayWikipedia.getJSONObject(i).has("country")) {
JSONArray locales = jsonArrayWikipedia.getJSONObject(i).getJSONArray("country");
for (int j = 0; j < locales.length(); j++) {
localesList.add(locales.getString(j));
}
} else {
localesList.add("--");
}
instance.setLocales(localesList);
instance.setDomain(domain);
instance.setType(type);
instance.setCloudflare(cloudFlare);
instance.setLocale(locale);
instance.setType(Instance.instanceType.TEDDIT);
if (defaultTeddit != null && domain.compareTo(defaultTeddit) == 0) {
instance.setInstanceType(Instance.instanceType.WIKIPEDIA);