You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
Java
45 lines
1.3 KiB
Java
package com.fox2code.mmm.repo;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import com.fox2code.mmm.utils.Http;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
public final class CustomRepoData extends RepoData {
|
|
boolean loadedExternal;
|
|
String override;
|
|
|
|
CustomRepoData(String url, File cacheRoot, SharedPreferences cachedPreferences) {
|
|
super(url, cacheRoot, cachedPreferences);
|
|
}
|
|
|
|
@Override
|
|
public boolean isEnabledByDefault() {
|
|
return this.override != null || this.loadedExternal;
|
|
}
|
|
|
|
@Override
|
|
public String getPreferenceId() {
|
|
return this.override == null ?
|
|
this.id : this.override;
|
|
}
|
|
|
|
public void quickPrePopulate() throws IOException, JSONException, NoSuchAlgorithmException {
|
|
JSONObject jsonObject = new JSONObject(
|
|
new String(Http.doHttpGet(this.getUrl(),
|
|
false), StandardCharsets.UTF_8));
|
|
this.name = jsonObject.getString("name").trim();
|
|
this.website = jsonObject.optString("website");
|
|
this.support = jsonObject.optString("support");
|
|
this.donate = jsonObject.optString("donate");
|
|
this.submitModule = jsonObject.optString("submitModule");
|
|
}
|
|
}
|