Fix small icon mode

This commit is contained in:
Cameron Gutman
2015-01-30 19:17:00 -05:00
parent 4d01e1afe6
commit ebd93a55a0
11 changed files with 119 additions and 29 deletions

View File

@@ -96,8 +96,9 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
startComputerUpdates();
try {
appGridAdapter = new AppGridAdapter(AppView.this, 1.0,
appGridAdapter = new AppGridAdapter(AppView.this,
PreferenceConfiguration.readPreferences(AppView.this).listMode,
PreferenceConfiguration.readPreferences(AppView.this).smallIconMode,
computer, managerBinder.getUniqueId());
} catch (Exception e) {
e.printStackTrace();
@@ -467,7 +468,8 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
@Override
public int getAdapterFragmentLayoutId() {
return PreferenceConfiguration.readPreferences(this).listMode ?
R.layout.list_view : R.layout.app_grid_view;
R.layout.list_view : (PreferenceConfiguration.readPreferences(AppView.this).smallIconMode ?
R.layout.app_grid_view_small : R.layout.app_grid_view);
}
@Override

View File

@@ -156,8 +156,9 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
bindService(new Intent(PcView.this, ComputerManagerService.class), serviceConnection,
Service.BIND_AUTO_CREATE);
pcGridAdapter = new PcGridAdapter(this, 1.0,
PreferenceConfiguration.readPreferences(this).listMode);
pcGridAdapter = new PcGridAdapter(this,
PreferenceConfiguration.readPreferences(this).listMode,
PreferenceConfiguration.readPreferences(this).smallIconMode);
initializeViews();
}
@@ -558,7 +559,8 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
@Override
public int getAdapterFragmentLayoutId() {
return PreferenceConfiguration.readPreferences(this).listMode ?
R.layout.list_view : R.layout.pc_grid_view;
R.layout.list_view : (PreferenceConfiguration.readPreferences(this).smallIconMode ?
R.layout.pc_grid_view_small : R.layout.pc_grid_view);
}
@Override

View File

@@ -54,8 +54,8 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
private SSLContext sslContext;
private final HashMap<ImageView, Future> pendingRequests = new HashMap<ImageView, Future>();
public AppGridAdapter(Context context, double gridScaleFactor, boolean listMode, ComputerDetails computer, String uniqueId) throws NoSuchAlgorithmException, KeyManagementException {
super(context, listMode ? R.layout.simple_row : R.layout.app_grid_item, R.drawable.image_loading, gridScaleFactor);
public AppGridAdapter(Context context, boolean listMode, boolean small, ComputerDetails computer, String uniqueId) throws NoSuchAlgorithmException, KeyManagementException {
super(context, listMode ? R.layout.simple_row : (small ? R.layout.app_grid_item_small : R.layout.app_grid_item), R.drawable.image_loading);
this.computer = computer;
this.uniqueId = uniqueId;

View File

@@ -18,13 +18,11 @@ public abstract class GenericGridAdapter<T> extends BaseAdapter {
protected int layoutId;
protected ArrayList<T> itemList = new ArrayList<T>();
protected LayoutInflater inflater;
protected double gridSizeFactor;
public GenericGridAdapter(Context context, int layoutId, int defaultImageRes, double gridSizeFactor) {
public GenericGridAdapter(Context context, int layoutId, int defaultImageRes) {
this.context = context;
this.layoutId = layoutId;
this.defaultImageRes = defaultImageRes;
this.gridSizeFactor = gridSizeFactor;
this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@@ -66,26 +64,11 @@ public abstract class GenericGridAdapter<T> extends BaseAdapter {
if (!populateImageView(imgView, itemList.get(i))) {
imgView.setImageResource(defaultImageRes);
}
ViewGroup.LayoutParams params = imgView.getLayoutParams();
params.width *= gridSizeFactor;
params.height *= gridSizeFactor;
imgView.setLayoutParams(params);
}
if (!populateTextView(txtView, itemList.get(i))) {
txtView.setText(itemList.get(i).toString());
ViewGroup.LayoutParams params = txtView.getLayoutParams();
params.width *= gridSizeFactor;
params.height *= gridSizeFactor;
txtView.setLayoutParams(params);
}
if (overlayView != null) {
ViewGroup.LayoutParams params = overlayView.getLayoutParams();
params.width *= gridSizeFactor;
params.height *= gridSizeFactor;
overlayView.setLayoutParams(params);
if (!populateOverlayView(overlayView, itemList.get(i))) {
overlayView.setVisibility(View.INVISIBLE);
}

View File

@@ -13,8 +13,8 @@ import java.util.Comparator;
public class PcGridAdapter extends GenericGridAdapter<PcView.ComputerObject> {
public PcGridAdapter(Context context, double gridScaleFactor, boolean listMode) {
super(context, listMode ? R.layout.simple_row : R.layout.pc_grid_item, R.drawable.computer, gridScaleFactor);
public PcGridAdapter(Context context, boolean listMode, boolean small) {
super(context, listMode ? R.layout.simple_row : (small ? R.layout.pc_grid_item_small : R.layout.pc_grid_item), R.drawable.computer);
}
public void addComputer(PcView.ComputerObject computer) {