Sort module/repo by name

This commit is contained in:
topjohnwu
2016-11-13 03:07:16 +08:00
parent f69facc842
commit 3e259021d0
3 changed files with 82 additions and 28 deletions
@@ -1,11 +1,13 @@
package com.topjohnwu.magisk.module;
import android.support.annotation.NonNull;
import com.topjohnwu.magisk.utils.Logger;
import java.util.List;
public abstract class BaseModule {
public abstract class BaseModule implements Comparable<BaseModule> {
protected String mId, mName, mVersion, mAuthor, mDescription, mSupportUrl, mDonateUrl;
protected boolean mIsCacheModule = false;
@@ -98,4 +100,9 @@ public abstract class BaseModule {
Logger.dev("Cache mods are no longer supported! id: " + id);
}
}
@Override
public int compareTo(@NonNull BaseModule o) {
return this.getName().toLowerCase().compareTo(o.getName().toLowerCase());
}
}
@@ -9,20 +9,19 @@ import com.topjohnwu.magisk.utils.WebRequest;
import java.util.Date;
public class Repo extends BaseModule {
protected String repoName, mLogUrl, mManifestUrl, mZipUrl;
protected Date mLastUpdate;
private String mLogUrl, mManifestUrl, mZipUrl;
private Date mLastUpdate;
public Repo(Context context, String name, Date lastUpdate) throws CacheModException {
repoName = name;
mLastUpdate = lastUpdate;
mLogUrl = context.getString(R.string.file_url, repoName, "changelog.txt");
mManifestUrl = context.getString(R.string.file_url, repoName, "module.prop");
mZipUrl = context.getString(R.string.zip_url, repoName);
mLogUrl = context.getString(R.string.file_url, name, "changelog.txt");
mManifestUrl = context.getString(R.string.file_url, name, "module.prop");
mZipUrl = context.getString(R.string.zip_url, name);
update();
}
public void update() throws CacheModException {
Logger.dev("Repo: Re-fetch prop " + mId);
Logger.dev("Repo: Re-fetch prop");
String props = WebRequest.makeWebServiceCall(mManifestUrl, WebRequest.GET, true);
String lines[] = props.split("\\n");
parseProps(lines);