mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-28 04:47:38 +00:00
parent
017fbf267b
commit
2c0436216f
@ -45,9 +45,9 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
|
|||||||
String noInfo = context.getString(R.string.no_info_provided);
|
String noInfo = context.getString(R.string.no_info_provided);
|
||||||
|
|
||||||
holder.title.setText(module.getName());
|
holder.title.setText(module.getName());
|
||||||
holder.versionName.setText( TextUtils.isEmpty(version) ? noInfo : version);
|
holder.versionName.setText(TextUtils.isEmpty(version) ? noInfo : version);
|
||||||
holder.author.setText( TextUtils.isEmpty(author) ? noInfo : context.getString(R.string.author, author));
|
holder.author.setText(TextUtils.isEmpty(author) ? noInfo : context.getString(R.string.author, author));
|
||||||
holder.description.setText( TextUtils.isEmpty(description) ? noInfo : description);
|
holder.description.setText(TextUtils.isEmpty(description) ? noInfo : description);
|
||||||
|
|
||||||
holder.checkBox.setOnCheckedChangeListener(null);
|
holder.checkBox.setOnCheckedChangeListener(null);
|
||||||
holder.checkBox.setChecked(module.isEnabled());
|
holder.checkBox.setChecked(module.isEnabled());
|
||||||
|
@ -88,11 +88,16 @@ public class ReposAdapter extends SectionedAdapter<ReposAdapter.SectionHolder, R
|
|||||||
Repo repo = repoPairs.get(section).second.get(position);
|
Repo repo = repoPairs.get(section).second.get(position);
|
||||||
Context context = holder.itemView.getContext();
|
Context context = holder.itemView.getContext();
|
||||||
|
|
||||||
holder.title.setText(repo.getName());
|
String name = repo.getName();
|
||||||
holder.versionName.setText(repo.getVersion());
|
String version = repo.getVersion();
|
||||||
String author = repo.getAuthor();
|
String author = repo.getAuthor();
|
||||||
holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author));
|
String description = repo.getDescription();
|
||||||
holder.description.setText(repo.getDescription());
|
String noInfo = context.getString(R.string.no_info_provided);
|
||||||
|
|
||||||
|
holder.title.setText(TextUtils.isEmpty(name) ? noInfo : name);
|
||||||
|
holder.versionName.setText(TextUtils.isEmpty(version) ? noInfo : version);
|
||||||
|
holder.author.setText(TextUtils.isEmpty(author) ? noInfo : context.getString(R.string.author, author));
|
||||||
|
holder.description.setText(TextUtils.isEmpty(description) ? noInfo : description);
|
||||||
holder.updateTime.setText(context.getString(R.string.updated_on, repo.getLastUpdateString()));
|
holder.updateTime.setText(context.getString(R.string.updated_on, repo.getLastUpdateString()));
|
||||||
|
|
||||||
holder.infoLayout.setOnClickListener(v ->
|
holder.infoLayout.setOnClickListener(v ->
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.topjohnwu.magisk.container;
|
package com.topjohnwu.magisk.container;
|
||||||
|
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -10,21 +10,27 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
public abstract class BaseModule implements Comparable<BaseModule> {
|
public abstract class BaseModule implements Comparable<BaseModule> {
|
||||||
|
|
||||||
private String mId = null, mName, mVersion, mAuthor, mDescription;
|
private String mId, mName, mVersion, mAuthor, mDescription;
|
||||||
private int mVersionCode = -1, minMagiskVersion = -1;
|
private int mVersionCode = -1, minMagiskVersion = -1;
|
||||||
|
|
||||||
protected BaseModule() {}
|
protected BaseModule() {
|
||||||
|
mId = mName = mVersion = mAuthor = mDescription = "";
|
||||||
|
}
|
||||||
|
|
||||||
protected BaseModule(Cursor c) {
|
protected BaseModule(Cursor c) {
|
||||||
mId = c.getString(c.getColumnIndex("id"));
|
mId = nonNull(c.getString(c.getColumnIndex("id")));
|
||||||
mName = c.getString(c.getColumnIndex("name"));
|
mName = nonNull(c.getString(c.getColumnIndex("name")));
|
||||||
mVersion = c.getString(c.getColumnIndex("version"));
|
mVersion = nonNull(c.getString(c.getColumnIndex("version")));
|
||||||
mVersionCode = c.getInt(c.getColumnIndex("versionCode"));
|
mVersionCode = c.getInt(c.getColumnIndex("versionCode"));
|
||||||
mAuthor = c.getString(c.getColumnIndex("author"));
|
mAuthor = nonNull(c.getString(c.getColumnIndex("author")));
|
||||||
mDescription = c.getString(c.getColumnIndex("description"));
|
mDescription = nonNull(c.getString(c.getColumnIndex("description")));
|
||||||
minMagiskVersion = c.getInt(c.getColumnIndex("minMagisk"));
|
minMagiskVersion = c.getInt(c.getColumnIndex("minMagisk"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String nonNull(String s) {
|
||||||
|
return s == null ? "" : s;
|
||||||
|
}
|
||||||
|
|
||||||
public ContentValues getContentValues() {
|
public ContentValues getContentValues() {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("id", mId);
|
values.put("id", mId);
|
||||||
|
@ -2,6 +2,7 @@ package com.topjohnwu.magisk.container;
|
|||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
import com.topjohnwu.magisk.utils.Download;
|
import com.topjohnwu.magisk.utils.Download;
|
||||||
@ -35,7 +36,7 @@ public class Repo extends BaseModule {
|
|||||||
throw new IllegalRepoException("Repo [" + repoName + "] parse error: " + e.getMessage());
|
throw new IllegalRepoException("Repo [" + repoName + "] parse error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getId() == null) {
|
if (TextUtils.isEmpty(getId())) {
|
||||||
throw new IllegalRepoException("Repo [" + repoName + "] does not contain id");
|
throw new IllegalRepoException("Repo [" + repoName + "] does not contain id");
|
||||||
}
|
}
|
||||||
if (getVersionCode() < 0) {
|
if (getVersionCode() < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user