mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 11:33:06 +00:00
Encapsulate the cache IO streams in buffered streams
This commit is contained in:
parent
98638186b5
commit
010e03252e
@ -2,6 +2,7 @@ package com.limelight.computers;
|
|||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -627,7 +628,7 @@ public class ComputerManagerService extends Service {
|
|||||||
List<NvApp> list = NvHTTP.getAppListByReader(new StringReader(appList));
|
List<NvApp> list = NvHTTP.getAppListByReader(new StringReader(appList));
|
||||||
if (appList != null && !appList.isEmpty() && !list.isEmpty()) {
|
if (appList != null && !appList.isEmpty() && !list.isEmpty()) {
|
||||||
// Open the cache file
|
// Open the cache file
|
||||||
FileOutputStream cacheOut = null;
|
OutputStream cacheOut = null;
|
||||||
try {
|
try {
|
||||||
cacheOut = CacheHelper.openCacheFileForOutput(getCacheDir(), "applist", computer.uuid.toString());
|
cacheOut = CacheHelper.openCacheFileForOutput(getCacheDir(), "applist", computer.uuid.toString());
|
||||||
CacheHelper.writeStringToOutputStream(cacheOut, appList);
|
CacheHelper.writeStringToOutputStream(cacheOut, appList);
|
||||||
|
@ -7,9 +7,9 @@ import com.limelight.LimeLog;
|
|||||||
import com.limelight.utils.CacheHelper;
|
import com.limelight.utils.CacheHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
public class DiskAssetLoader implements CachedAppAssetLoader.CachedLoader {
|
public class DiskAssetLoader implements CachedAppAssetLoader.CachedLoader {
|
||||||
private final File cacheDir;
|
private final File cacheDir;
|
||||||
@ -44,7 +44,7 @@ public class DiskAssetLoader implements CachedAppAssetLoader.CachedLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populateCache(CachedAppAssetLoader.LoaderTuple tuple, Bitmap bitmap) {
|
public void populateCache(CachedAppAssetLoader.LoaderTuple tuple, Bitmap bitmap) {
|
||||||
FileOutputStream out = null;
|
OutputStream out = null;
|
||||||
try {
|
try {
|
||||||
// PNG ignores quality setting
|
// PNG ignores quality setting
|
||||||
out = CacheHelper.openCacheFileForOutput(cacheDir, "boxart", tuple.computer.uuid.toString(), tuple.app.getAppId() + ".png");
|
out = CacheHelper.openCacheFileForOutput(cacheDir, "boxart", tuple.computer.uuid.toString(), tuple.app.getAppId() + ".png");
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.limelight.utils;
|
package com.limelight.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -28,12 +30,12 @@ public class CacheHelper {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileInputStream openCacheFileForInput(File root, String... path) throws FileNotFoundException {
|
public static InputStream openCacheFileForInput(File root, String... path) throws FileNotFoundException {
|
||||||
return new FileInputStream(openPath(false, root, path));
|
return new BufferedInputStream(new FileInputStream(openPath(false, root, path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileOutputStream openCacheFileForOutput(File root, String... path) throws FileNotFoundException {
|
public static OutputStream openCacheFileForOutput(File root, String... path) throws FileNotFoundException {
|
||||||
return new FileOutputStream(openPath(true, root, path));
|
return new BufferedOutputStream(new FileOutputStream(openPath(true, root, path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String readInputStreamToString(InputStream in) throws IOException {
|
public static String readInputStreamToString(InputStream in) throws IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user