mirror of
https://github.com/Dark98/SliceBeam.git
synced 2026-07-02 16:49:02 +00:00
Support vendor dumps repo
This commit is contained in:
@@ -100,7 +100,13 @@ public class SetupActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private final static String TAG = "SetupActivity";
|
private final static String TAG = "SetupActivity";
|
||||||
|
|
||||||
private final static String PRUSA_REPOS_URL = "https://preset-repo-api.prusa3d.com/v1/repos";
|
private final static List<String> REPOS_URLS = Arrays.asList(
|
||||||
|
"https://preset-repo-api.prusa3d.com/v1/repos",
|
||||||
|
// QIDI's manifest should be adapted, they haven't put their idx file
|
||||||
|
// "https://raw.githubusercontent.com/QIDITECH/QIDISlicer/refs/heads/master/resources/profiles/ArchiveRepositoryManifest.json",
|
||||||
|
"https://raw.githubusercontent.com/utkabobr/SliceBeam/refs/heads/master/.profiledumpsrepo/manifest.json"
|
||||||
|
);
|
||||||
|
|
||||||
private final static int REPOS_INDEX = 1;
|
private final static int REPOS_INDEX = 1;
|
||||||
private final static int PROFILES_INDEX = 2;
|
private final static int PROFILES_INDEX = 2;
|
||||||
private static int BOOSTY_INDEX = 3;
|
private static int BOOSTY_INDEX = 3;
|
||||||
@@ -488,49 +494,70 @@ public class SetupActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void loadRepos(boolean fromPage) {
|
private void loadRepos(boolean fromPage) {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
client.get(PRUSA_REPOS_URL, new AsyncHttpResponseHandler() {
|
repos.clear();
|
||||||
|
List<String> finishedIndexes = new ArrayList<>();
|
||||||
|
Map<String, List<ProfilesRepo>> reposMap = new HashMap<String, List<ProfilesRepo>>() {
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
|
public List<ProfilesRepo> get(@Nullable Object key) {
|
||||||
isLoading = false;
|
List<ProfilesRepo> list = super.get(key);
|
||||||
try {
|
if (list == null) put((String) key, list = new ArrayList<>());
|
||||||
JSONArray arr = new JSONArray(new String(responseBody));
|
return list;
|
||||||
for (int i = 0; i < arr.length(); i++) {
|
}
|
||||||
JSONObject obj = arr.getJSONObject(i);
|
};
|
||||||
if (obj.getString("id").endsWith("-fff")) {
|
for (String repo : REPOS_URLS) {
|
||||||
ProfilesRepo r = new ProfilesRepo();
|
client.get(repo, new AsyncHttpResponseHandler() {
|
||||||
r.url = obj.getString("url");
|
@Override
|
||||||
r.name = obj.getString("name");
|
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
|
||||||
r.description = obj.getString("description");
|
finishedIndexes.add(repo);
|
||||||
r.indexUrl = obj.getString("index_url");
|
try {
|
||||||
repos.add(r);
|
JSONArray arr = new JSONArray(new String(responseBody));
|
||||||
|
for (int i = 0; i < arr.length(); i++) {
|
||||||
|
JSONObject obj = arr.getJSONObject(i);
|
||||||
|
if (obj.getString("id").endsWith("-fff")) {
|
||||||
|
ProfilesRepo r = new ProfilesRepo();
|
||||||
|
r.url = obj.getString("url");
|
||||||
|
r.name = obj.getString("name");
|
||||||
|
r.description = obj.getString("description");
|
||||||
|
r.indexUrl = obj.getString("index_url");
|
||||||
|
reposMap.get(repo).add(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (finishedIndexes.size() == REPOS_URLS.size()) {
|
||||||
|
// Filter in the right way
|
||||||
|
for (String repo : REPOS_URLS) {
|
||||||
|
repos.addAll(reposMap.get(repo));
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewUtils.postOnMainThread(() -> {
|
||||||
|
isLoading = false;
|
||||||
|
if (fromPage) {
|
||||||
|
reposItem.onReposLoaded();
|
||||||
|
}
|
||||||
|
pager.setUserInputEnabled(true);
|
||||||
|
isReposLoaded = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewUtils.postOnMainThread(() -> {
|
|
||||||
if (fromPage) {
|
|
||||||
reposItem.onReposLoaded();
|
|
||||||
}
|
|
||||||
pager.setUserInputEnabled(true);
|
|
||||||
isReposLoaded = true;
|
|
||||||
});
|
|
||||||
} catch (JSONException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
|
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
Log.e(TAG, "Failed to load repos", error);
|
Log.e(TAG, "Failed to load repos", error);
|
||||||
if (fromPage) {
|
if (fromPage) {
|
||||||
ViewUtils.postOnMainThread(() -> {
|
ViewUtils.postOnMainThread(() -> {
|
||||||
Toast.makeText(SliceBeam.INSTANCE, R.string.IntroFailedToLoadRepos, Toast.LENGTH_SHORT).show();
|
Toast.makeText(SliceBeam.INSTANCE, R.string.IntroFailedToLoadRepos, Toast.LENGTH_SHORT).show();
|
||||||
fakeScroll(-1);
|
fakeScroll(-1);
|
||||||
pager.setUserInputEnabled(true);
|
pager.setUserInputEnabled(true);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -100,7 +100,9 @@ public class IOUtils {
|
|||||||
vendor = "BBL";
|
vendor = "BBL";
|
||||||
} else if (type.equals("process")) {
|
} else if (type.equals("process")) {
|
||||||
int i = inherit.indexOf('@') + 1;
|
int i = inherit.indexOf('@') + 1;
|
||||||
vendor = inherit.substring(i, inherit.indexOf(' ', i));
|
int j = inherit.indexOf(' ', i);
|
||||||
|
if (j == -1) j = inherit.length();
|
||||||
|
vendor = inherit.substring(i, j);
|
||||||
} else {
|
} else {
|
||||||
vendor = inherit.substring(0, inherit.indexOf(' '));
|
vendor = inherit.substring(0, inherit.indexOf(' '));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user