mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-23 00:08:37 +00:00
Using Picasso for launcher icon loading
This commit is contained in:
parent
af9b9034b5
commit
b4f57853d0
5 changed files with 20 additions and 5 deletions
|
@ -140,6 +140,13 @@ Translations:
|
|||
|
||||
Please note that you agree to the license below by contributing, including the copyright.
|
||||
|
||||
Attribution
|
||||
-----------
|
||||
|
||||
NetGuard uses:
|
||||
|
||||
* [Picasso](http://square.github.io/picasso/)
|
||||
* [Android Support Library](https://developer.android.com/tools/support-library/index.html)
|
||||
|
||||
License
|
||||
-------
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="picasso-2.5.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -37,4 +37,5 @@ dependencies {
|
|||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.1.0'
|
||||
compile 'com.android.support:recyclerview-v7:23.1.0'
|
||||
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||
}
|
||||
|
|
|
@ -69,10 +69,6 @@ public class Rule implements Comparable<Rule> {
|
|||
return listRules;
|
||||
}
|
||||
|
||||
public Drawable getIcon(Context context) {
|
||||
return info.applicationInfo.loadIcon(context.getPackageManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Rule other) {
|
||||
if ((changed || unused) == (other.changed || other.unused)) {
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
@ -20,6 +22,8 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -134,7 +138,13 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
|
|||
if (rule.disabled)
|
||||
color = Color.argb(100, Color.red(color), Color.green(color), Color.blue(color));
|
||||
|
||||
holder.ivIcon.setImageDrawable(rule.getIcon(context));
|
||||
if (rule.info.applicationInfo.icon == 0)
|
||||
Picasso.with(context).load(android.R.drawable.sym_def_app_icon).into(holder.ivIcon);
|
||||
else {
|
||||
Uri uri = Uri.parse("android.resource://" + rule.info.packageName + "/" + rule.info.applicationInfo.icon);
|
||||
Picasso.with(context).load(uri).into(holder.ivIcon);
|
||||
}
|
||||
|
||||
holder.ivExpander.setImageResource(rule.attributes ? android.R.drawable.arrow_up_float : android.R.drawable.arrow_down_float);
|
||||
holder.llApplication.setOnClickListener(llListener);
|
||||
holder.tvName.setText(rule.name);
|
||||
|
|
Loading…
Reference in a new issue