Code cleanup and Lint suggestions

This commit is contained in:
Cameron Gutman
2015-02-27 01:43:24 -05:00
parent 7b12fd1ad2
commit e081ab5239
8 changed files with 19 additions and 49 deletions

View File

@@ -178,7 +178,6 @@ public class AndroidCpuDecoderRenderer extends EnhancedDecoderRenderer {
@Override
public void run() {
long nextFrameTime = System.currentTimeMillis();
DecodeUnit du;
while (!isInterrupted())
{
long diff = nextFrameTime - System.currentTimeMillis();

View File

@@ -1,9 +1,7 @@
package com.limelight.computers;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.net.InetAddress;
import java.net.InetSocketAddress;

View File

@@ -2,7 +2,6 @@ package com.limelight.grid;
import android.app.Activity;
import android.graphics.Bitmap;
import android.util.DisplayMetrics;
import android.widget.ImageView;
import android.widget.TextView;
@@ -25,6 +24,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@SuppressWarnings("unchecked")
public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
private final Activity activity;
@@ -57,7 +57,7 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
LimeLog.info("Art scaling divisor: " + scalingDivisor);
this.activity = activity;
this.loader = new CachedAppAssetLoader(computer, uniqueId, scalingDivisor,
this.loader = new CachedAppAssetLoader(computer, scalingDivisor,
new NetworkAssetLoader(context, uniqueId),
new MemoryAssetLoader(), new DiskAssetLoader(context.getCacheDir()));
}
@@ -126,7 +126,7 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
}
@Override
public void notifyLoadComplete(Object object, Bitmap bitmap) {
public void notifyLoadComplete(Object object, final Bitmap bitmap) {
final WeakReference<ImageView> viewRef = (WeakReference<ImageView>) object;
loadingTuples.remove(viewRef);
@@ -141,13 +141,12 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
return;
}
final Bitmap viewBmp = bitmap;
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
ImageView view = viewRef.get();
if (view != null) {
view.setImageBitmap(viewBmp);
view.setImageBitmap(bitmap);
fadeInImage(view);
}
}

View File

@@ -1,7 +1,6 @@
package com.limelight.grid.assets;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.limelight.nvstream.http.ComputerDetails;
import com.limelight.nvstream.http.NvApp;
@@ -13,7 +12,6 @@ import java.util.concurrent.TimeUnit;
public class CachedAppAssetLoader {
private final ComputerDetails computer;
private final String uniqueId;
private final double scalingDivider;
private final ThreadPoolExecutor foregroundExecutor = new ThreadPoolExecutor(8, 8, Long.MAX_VALUE, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>());
private final ThreadPoolExecutor backgroundExecutor = new ThreadPoolExecutor(2, 2, Long.MAX_VALUE, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>());
@@ -21,11 +19,10 @@ public class CachedAppAssetLoader {
private final MemoryAssetLoader memoryLoader;
private final DiskAssetLoader diskLoader;
public CachedAppAssetLoader(ComputerDetails computer, String uniqueId, double scalingDivider,
public CachedAppAssetLoader(ComputerDetails computer, double scalingDivider,
NetworkAssetLoader networkLoader, MemoryAssetLoader memoryLoader,
DiskAssetLoader diskLoader) {
this.computer = computer;
this.uniqueId = uniqueId;
this.scalingDivider = scalingDivider;
this.networkLoader = networkLoader;
@@ -33,15 +30,6 @@ public class CachedAppAssetLoader {
this.diskLoader = diskLoader;
}
private static Bitmap scaleBitmapAndRecyle(Bitmap bmp, double scalingDivider) {
Bitmap newBmp = Bitmap.createScaledBitmap(bmp, (int)(bmp.getWidth() / scalingDivider),
(int)(bmp.getHeight() / scalingDivider), true);
if (newBmp != bmp) {
bmp.recycle();
}
return newBmp;
}
private Runnable createLoaderRunnable(final LoaderTuple tuple, final Object context, final LoadListener listener) {
return new Runnable() {
@Override
@@ -119,15 +107,7 @@ public class CachedAppAssetLoader {
// First, try the memory cache in the current context
Bitmap bmp = memoryLoader.loadBitmapFromCache(tuple);
if (bmp != null) {
synchronized (tuple) {
if (tuple.cancelled) {
return null;
}
else {
tuple.notified = true;
}
}
// The caller never sees our tuple in this case
listener.notifyLoadComplete(context, bmp);
return null;
}

View File

@@ -1,8 +1,6 @@
package com.limelight.grid.assets;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.limelight.LimeLog;
import com.limelight.binding.PlatformBinding;
@@ -19,7 +17,7 @@ public class NetworkAssetLoader {
private final Context context;
private final String uniqueId;
public NetworkAssetLoader(Context context, String uniqueId) throws NoSuchAlgorithmException, KeyManagementException {
public NetworkAssetLoader(Context context, String uniqueId) {
this.context = context;
this.uniqueId = uniqueId;
}