Various speedups in the app views. Compact layout still needs restarting.
This commit is contained in:
parent
b05e38d761
commit
4d0c4babe6
@ -19,6 +19,7 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
private List<DB.App> items = new ArrayList<DB.App>();
|
private List<DB.App> items = new ArrayList<DB.App>();
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
boolean pref_compactlayout;
|
||||||
|
|
||||||
public AppListAdapter(Context context) {
|
public AppListAdapter(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@ -53,65 +54,31 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View v = convertView;
|
boolean init = false;
|
||||||
if (v == null) {
|
|
||||||
LayoutInflater vi = (LayoutInflater) mContext
|
if (convertView == null) {
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
convertView = ((LayoutInflater) mContext.getSystemService(
|
||||||
v = vi.inflate(R.layout.applistitem, null);
|
Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.applistitem, null);
|
||||||
|
init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageView iconUpdates = (ImageView) convertView.findViewById(R.id.icon_status_has_updates);
|
||||||
|
ImageView iconInstalled = (ImageView) convertView.findViewById(R.id.icon_status_installed);
|
||||||
|
|
||||||
|
TextView name = (TextView) convertView.findViewById(R.id.name);
|
||||||
|
TextView summary = (TextView) convertView.findViewById(R.id.summary);
|
||||||
|
TextView status = (TextView) convertView.findViewById(R.id.status);
|
||||||
|
TextView license = (TextView) convertView.findViewById(R.id.license);
|
||||||
|
|
||||||
DB.App app = items.get(position);
|
DB.App app = items.get(position);
|
||||||
|
|
||||||
TextView name = (TextView) v.findViewById(R.id.name);
|
|
||||||
name.setText(app.name);
|
|
||||||
|
|
||||||
TextView summary = (TextView) v.findViewById(R.id.summary);
|
|
||||||
summary.setText(app.summary);
|
|
||||||
|
|
||||||
TextView status = (TextView) v.findViewById(R.id.status);
|
|
||||||
TextView license = (TextView) v.findViewById(R.id.license);
|
|
||||||
|
|
||||||
ImageView iconUpdates = (ImageView)v.findViewById(R.id.icon_status_has_updates);
|
|
||||||
ImageView iconInstalled = (ImageView)v.findViewById(R.id.icon_status_installed);
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
|
||||||
|
|
||||||
if (prefs.getBoolean("compactlayout", false)) {
|
|
||||||
|
|
||||||
status.setVisibility(View.GONE);
|
|
||||||
license.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
RelativeLayout.LayoutParams summaryLayout =
|
|
||||||
new RelativeLayout.LayoutParams(
|
|
||||||
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
|
||||||
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
summaryLayout.addRule(RelativeLayout.BELOW, R.id.name);
|
|
||||||
summaryLayout.addRule(RelativeLayout.RIGHT_OF, R.id.icon);
|
|
||||||
summary.setLayoutParams(summaryLayout);
|
|
||||||
|
|
||||||
if (app.hasUpdates && showStatusUpdate()) {
|
|
||||||
iconUpdates.setImageResource(R.drawable.ic_menu_refresh);
|
|
||||||
iconUpdates.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
iconUpdates.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app.installedVerCode > 0 && showStatusInstalled()) {
|
|
||||||
iconInstalled.setImageResource(R.drawable.ic_cab_done_holo_dark);
|
|
||||||
iconInstalled.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
iconInstalled.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
status.setText(getVersionInfo(app));
|
status.setText(getVersionInfo(app));
|
||||||
license.setText(app.license);
|
license.setText(app.license);
|
||||||
|
|
||||||
iconUpdates.setVisibility(View.GONE);
|
name.setText(app.name);
|
||||||
iconInstalled.setVisibility(View.GONE);
|
summary.setText(app.summary);
|
||||||
}
|
|
||||||
|
|
||||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
|
||||||
File icn = new File(DB.getIconsPath(), app.icon);
|
File icn = new File(DB.getIconsPath(), app.icon);
|
||||||
if (icn.exists() && icn.length() > 0) {
|
if (icn.exists() && icn.length() > 0) {
|
||||||
new Uri.Builder().build();
|
new Uri.Builder().build();
|
||||||
@ -120,13 +87,45 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
icon.setImageResource(android.R.drawable.sym_def_app_icon);
|
icon.setImageResource(android.R.drawable.sym_def_app_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iconUpdates.setVisibility(View.GONE);
|
||||||
|
iconInstalled.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (init) {
|
||||||
|
iconInstalled.setImageResource(R.drawable.ic_cab_done_holo_dark);
|
||||||
|
iconUpdates.setImageResource(R.drawable.ic_menu_refresh);
|
||||||
|
SharedPreferences prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(mContext);
|
||||||
|
pref_compactlayout = prefs.getBoolean("compactlayout", false);
|
||||||
|
|
||||||
|
if (pref_compactlayout == true) {
|
||||||
|
status.setVisibility(View.GONE);
|
||||||
|
license.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
RelativeLayout.LayoutParams summaryLayout =
|
||||||
|
new RelativeLayout.LayoutParams(
|
||||||
|
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
||||||
|
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
summaryLayout.addRule(RelativeLayout.BELOW, R.id.name);
|
||||||
|
summaryLayout.addRule(RelativeLayout.END_OF, R.id.icon);
|
||||||
|
summary.setLayoutParams(summaryLayout);
|
||||||
|
|
||||||
|
if (app.hasUpdates && showStatusUpdate()) {
|
||||||
|
iconUpdates.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.installedVerCode > 0 && showStatusInstalled()) {
|
||||||
|
iconInstalled.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Disable it all if it isn't compatible...
|
// Disable it all if it isn't compatible...
|
||||||
View[] views = { v, status, summary, license, name };
|
View[] views = { convertView, status, summary, license, name };
|
||||||
for (View view : views) {
|
for (View view : views) {
|
||||||
view.setEnabled(app.compatible);
|
view.setEnabled(app.compatible);
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getVersionInfo(DB.App app) {
|
private String getVersionInfo(DB.App app) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user