Search in sources :

Example 1 with ProcessRepoZip

use of com.topjohnwu.magisk.asyncs.ProcessRepoZip in project MagiskManager by topjohnwu.

the class ReposAdapter method onBindItemViewHolder.

@Override
public void onBindItemViewHolder(RepoHolder holder, int section, int position) {
    Repo repo = repoPairs.get(section).second.get(position);
    Context context = holder.itemView.getContext();
    holder.title.setText(repo.getName());
    holder.versionName.setText(repo.getVersion());
    String author = repo.getAuthor();
    holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author));
    holder.description.setText(repo.getDescription());
    holder.updateTime.setText(context.getString(R.string.updated_on, repo.getLastUpdateString()));
    holder.infoLayout.setOnClickListener(v -> new MarkDownWindow((Activity) context, null, repo.getDetailUrl()).exec());
    holder.downloadImage.setOnClickListener(v -> {
        String filename = repo.getName() + "-" + repo.getVersion() + ".zip";
        new AlertDialogBuilder((Activity) context).setTitle(context.getString(R.string.repo_install_title, repo.getName())).setMessage(context.getString(R.string.repo_install_msg, filename)).setCancelable(true).setPositiveButton(R.string.install, (d, i) -> new ProcessRepoZip((Activity) context, repo.getZipUrl(), Utils.getLegalFilename(filename), true).exec()).setNeutralButton(R.string.download, (d, i) -> new ProcessRepoZip((Activity) context, repo.getZipUrl(), Utils.getLegalFilename(filename), false).exec()).setNegativeButton(R.string.no_thanks, null).show();
    });
}
Also used : Context(android.content.Context) Context(android.content.Context) LinearLayout(android.widget.LinearLayout) ButterKnife(butterknife.ButterKnife) MarkDownWindow(com.topjohnwu.magisk.asyncs.MarkDownWindow) AlertDialogBuilder(com.topjohnwu.magisk.components.AlertDialogBuilder) Pair(android.util.Pair) ImageView(android.widget.ImageView) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) R(com.topjohnwu.magisk.R) ProcessRepoZip(com.topjohnwu.magisk.asyncs.ProcessRepoZip) Module(com.topjohnwu.magisk.container.Module) RepoDatabaseHelper(com.topjohnwu.magisk.database.RepoDatabaseHelper) Map(java.util.Map) View(android.view.View) Cursor(android.database.Cursor) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) TextView(android.widget.TextView) Utils(com.topjohnwu.magisk.utils.Utils) Activity(android.app.Activity) Repo(com.topjohnwu.magisk.container.Repo) AlertDialogBuilder(com.topjohnwu.magisk.components.AlertDialogBuilder) Repo(com.topjohnwu.magisk.container.Repo) ProcessRepoZip(com.topjohnwu.magisk.asyncs.ProcessRepoZip) Activity(android.app.Activity) MarkDownWindow(com.topjohnwu.magisk.asyncs.MarkDownWindow)

Aggregations

Activity (android.app.Activity)1 Context (android.content.Context)1 Cursor (android.database.Cursor)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TextUtils (android.text.TextUtils)1 Pair (android.util.Pair)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 ButterKnife (butterknife.ButterKnife)1 R (com.topjohnwu.magisk.R)1 MarkDownWindow (com.topjohnwu.magisk.asyncs.MarkDownWindow)1 ProcessRepoZip (com.topjohnwu.magisk.asyncs.ProcessRepoZip)1 AlertDialogBuilder (com.topjohnwu.magisk.components.AlertDialogBuilder)1 Module (com.topjohnwu.magisk.container.Module)1 Repo (com.topjohnwu.magisk.container.Repo)1