mirror of
https://github.com/Dark98/SliceBeam.git
synced 2026-07-03 00:38:53 +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,10 +494,22 @@ 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
|
||||||
|
public List<ProfilesRepo> get(@Nullable Object key) {
|
||||||
|
List<ProfilesRepo> list = super.get(key);
|
||||||
|
if (list == null) put((String) key, list = new ArrayList<>());
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (String repo : REPOS_URLS) {
|
||||||
|
client.get(repo, new AsyncHttpResponseHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
|
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
|
||||||
isLoading = false;
|
finishedIndexes.add(repo);
|
||||||
try {
|
try {
|
||||||
JSONArray arr = new JSONArray(new String(responseBody));
|
JSONArray arr = new JSONArray(new String(responseBody));
|
||||||
for (int i = 0; i < arr.length(); i++) {
|
for (int i = 0; i < arr.length(); i++) {
|
||||||
@@ -502,17 +520,25 @@ public class SetupActivity extends AppCompatActivity {
|
|||||||
r.name = obj.getString("name");
|
r.name = obj.getString("name");
|
||||||
r.description = obj.getString("description");
|
r.description = obj.getString("description");
|
||||||
r.indexUrl = obj.getString("index_url");
|
r.indexUrl = obj.getString("index_url");
|
||||||
repos.add(r);
|
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(() -> {
|
ViewUtils.postOnMainThread(() -> {
|
||||||
|
isLoading = false;
|
||||||
if (fromPage) {
|
if (fromPage) {
|
||||||
reposItem.onReposLoaded();
|
reposItem.onReposLoaded();
|
||||||
}
|
}
|
||||||
pager.setUserInputEnabled(true);
|
pager.setUserInputEnabled(true);
|
||||||
isReposLoaded = true;
|
isReposLoaded = true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -532,6 +558,7 @@ public class SetupActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
|||||||
@@ -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