mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-21 05:51:13 +00:00
Removed unnecessary assets
This commit is contained in:
@@ -1,103 +0,0 @@
|
||||
package com.topjohnwu.magisk.model.adapters;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public abstract class StringListAdapter<VH extends StringListAdapter.ViewHolder>
|
||||
extends RecyclerView.Adapter<VH> {
|
||||
|
||||
private RecyclerView rv;
|
||||
private boolean dynamic;
|
||||
private int screenWidth;
|
||||
private int txtWidth = -1;
|
||||
private int padding;
|
||||
|
||||
protected List<String> mList;
|
||||
|
||||
public StringListAdapter(List<String> list) {
|
||||
this(list, false);
|
||||
}
|
||||
|
||||
public StringListAdapter(List<String> list, boolean isDynamic) {
|
||||
mList = list;
|
||||
dynamic = isDynamic;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public final VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(itemLayoutRes(), parent, false);
|
||||
VH vh = createViewHolder(v);
|
||||
if (txtWidth < 0)
|
||||
onUpdateTextWidth(vh);
|
||||
return vh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull VH holder, int position) {
|
||||
holder.txt.setText(mList.get(position));
|
||||
holder.txt.getLayoutParams().width = txtWidth;
|
||||
if (dynamic)
|
||||
onUpdateTextWidth(holder);
|
||||
}
|
||||
|
||||
protected void onUpdateTextWidth(VH vh) {
|
||||
if (txtWidth < 0) {
|
||||
txtWidth = screenWidth - padding;
|
||||
} else {
|
||||
vh.txt.measure(0, 0);
|
||||
int width = vh.txt.getMeasuredWidth();
|
||||
if (width > txtWidth) {
|
||||
txtWidth = width;
|
||||
vh.txt.getLayoutParams().width = txtWidth;
|
||||
}
|
||||
}
|
||||
if (rv.getWidth() != txtWidth + padding)
|
||||
rv.requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView rv) {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
((Activity) rv.getContext()).getWindowManager()
|
||||
.getDefaultDisplay().getMetrics(displayMetrics);
|
||||
screenWidth = displayMetrics.widthPixels;
|
||||
padding = rv.getPaddingStart() + rv.getPaddingEnd();
|
||||
this.rv = rv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
protected abstract int itemLayoutRes();
|
||||
|
||||
@NonNull
|
||||
public abstract VH createViewHolder(@NonNull View v);
|
||||
|
||||
public static abstract class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView txt;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
txt = itemView.findViewById(textViewResId());
|
||||
}
|
||||
|
||||
@IdRes
|
||||
protected abstract int textViewResId();
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package com.topjohnwu.magisk.view;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
|
||||
public class ArrowExpandable extends Expandable {
|
||||
protected Expandable mBase;
|
||||
private View arrow;
|
||||
|
||||
public ArrowExpandable(Expandable base, View arrow) {
|
||||
mBase = base;
|
||||
this.arrow = arrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExpand() {
|
||||
mBase.onExpand();
|
||||
setRotate(new RotateAnimation(0, 180,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCollapse() {
|
||||
mBase.onCollapse();
|
||||
setRotate(new RotateAnimation(180, 0,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetExpanded(boolean expanded) {
|
||||
mBase.onSetExpanded(expanded);
|
||||
if (arrow != null)
|
||||
arrow.setRotation(expanded ? 180 : 0);
|
||||
}
|
||||
|
||||
private void setRotate(RotateAnimation rotate) {
|
||||
rotate.setDuration(300);
|
||||
rotate.setFillAfter(true);
|
||||
arrow.startAnimation(rotate);
|
||||
}
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
package com.topjohnwu.magisk.view;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.Unbinder;
|
||||
|
||||
public class UpdateCardHolder {
|
||||
|
||||
@BindView(R.id.status_icon) public ImageView statusIcon;
|
||||
@BindView(R.id.progress) public ProgressBar progress;
|
||||
@BindView(R.id.status) public TextView status;
|
||||
@BindView(R.id.current_version) public TextView currentVersion;
|
||||
@BindView(R.id.latest_version) public TextView latestVersion;
|
||||
@BindView(R.id.additional) public TextView additional;
|
||||
@BindView(R.id.install) public Button install;
|
||||
|
||||
public View itemView;
|
||||
public Unbinder unbinder;
|
||||
|
||||
public UpdateCardHolder(LayoutInflater inflater, ViewGroup root) {
|
||||
itemView = inflater.inflate(R.layout.update_card, root, false);
|
||||
unbinder = new UpdateCardHolder_ViewBinding(this, itemView);
|
||||
}
|
||||
|
||||
public void setClickable(View.OnClickListener listener) {
|
||||
itemView.setClickable(true);
|
||||
itemView.setFocusable(true);
|
||||
itemView.setOnClickListener(listener);
|
||||
}
|
||||
|
||||
public void setValid(boolean valid) {
|
||||
progress.setVisibility(View.GONE);
|
||||
statusIcon.setVisibility(View.VISIBLE);
|
||||
if (valid) {
|
||||
install.setVisibility(View.VISIBLE);
|
||||
latestVersion.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
install.setVisibility(View.GONE);
|
||||
latestVersion.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
statusIcon.setVisibility(View.INVISIBLE);
|
||||
latestVersion.setVisibility(View.GONE);
|
||||
install.setVisibility(View.GONE);
|
||||
status.setText(R.string.checking_for_updates);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user