diff --git a/app/src/main/java/net/typeblog/shelter/services/FileShuttleService.java b/app/src/main/java/net/typeblog/shelter/services/FileShuttleService.java index a9753b6..5350e7a 100644 --- a/app/src/main/java/net/typeblog/shelter/services/FileShuttleService.java +++ b/app/src/main/java/net/typeblog/shelter/services/FileShuttleService.java @@ -26,6 +26,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -46,9 +47,9 @@ public class FileShuttleService extends Service { } @Override - public List loadFiles(String path) { + public List> loadFiles(String path) { resetSuicideTask(); - ArrayList ret = new ArrayList<>(); + ArrayList> ret = new ArrayList<>(); File f = new File(resolvePath(path)); if (f.listFiles() != null) { for (File child : f.listFiles()) { @@ -59,10 +60,10 @@ public class FileShuttleService extends Service { } @Override - public Map loadFileMeta(String path) { + public Map loadFileMeta(String path) { resetSuicideTask(); File f = new File(resolvePath(path)); - HashMap map = new HashMap<>(); + HashMap map = new HashMap<>(); map.put(DocumentsContract.Document.COLUMN_DOCUMENT_ID, f.getAbsolutePath()); map.put(DocumentsContract.Document.COLUMN_DISPLAY_NAME, f.getName()); map.put(DocumentsContract.Document.COLUMN_SIZE, f.length()); diff --git a/app/src/main/java/net/typeblog/shelter/services/FreezeService.java b/app/src/main/java/net/typeblog/shelter/services/FreezeService.java index ced1c44..5d7502e 100644 --- a/app/src/main/java/net/typeblog/shelter/services/FreezeService.java +++ b/app/src/main/java/net/typeblog/shelter/services/FreezeService.java @@ -50,10 +50,10 @@ public class FreezeService extends Service { } // An app being inactive for this amount of time will be frozen - private static long APP_INACTIVE_TIMEOUT = 1000; + private static final long APP_INACTIVE_TIMEOUT = 1000; // Notification ID - private static int NOTIFICATION_ID = 0xe49c0; + private static final int NOTIFICATION_ID = 0xe49c0; // The actual receiver of the screen-off event private BroadcastReceiver mLockReceiver = new BroadcastReceiver() { diff --git a/app/src/main/java/net/typeblog/shelter/ui/AppListAdapter.java b/app/src/main/java/net/typeblog/shelter/ui/AppListAdapter.java index a4a514b..096aad0 100644 --- a/app/src/main/java/net/typeblog/shelter/ui/AppListAdapter.java +++ b/app/src/main/java/net/typeblog/shelter/ui/AppListAdapter.java @@ -29,16 +29,14 @@ import java.util.stream.Collectors; public class AppListAdapter extends RecyclerView.Adapter { class ViewHolder extends RecyclerView.ViewHolder { - private ViewGroup mView; private ImageView mIcon; private TextView mTitle; private TextView mPackage; // This text view shows the order of all selected items private TextView mSelectOrder; int mIndex = -1; - ViewHolder(ViewGroup view) { + ViewHolder(View view) { super(view); - mView = view; mIcon = view.findViewById(R.id.list_app_icon); mTitle = view.findViewById(R.id.list_app_title); mPackage = view.findViewById(R.id.list_app_package); @@ -57,7 +55,7 @@ public class AppListAdapter extends RecyclerView.Adapter fileInfo = null; + Map fileInfo; try { fileInfo = mService.loadFileMeta(documentId); } catch (RemoteException e) { @@ -150,7 +151,7 @@ public class CrossProfileDocumentsProvider extends DocumentsProvider { @Override public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) { ensureServiceBound(); - List> files = null; + List> files; try { files = mService.loadFiles(parentDocumentId); } catch (RemoteException e) { @@ -161,7 +162,7 @@ public class CrossProfileDocumentsProvider extends DocumentsProvider { result.setNotificationUri(getContext().getContentResolver(), DocumentsContract.buildDocumentUri(AUTHORITY, parentDocumentId)); - for (Map file : files) { + for (Map file : files) { includeFile(result, file); } return result; @@ -223,7 +224,7 @@ public class CrossProfileDocumentsProvider extends DocumentsProvider { } } - private void includeFile(MatrixCursor cursor, Map fileInfo) { + private void includeFile(MatrixCursor cursor, Map fileInfo) { final MatrixCursor.RowBuilder row = cursor.newRow(); for (String col : DEFAULT_DOCUMENT_PROJECTION) { row.add(col, fileInfo.get(col)); diff --git a/app/src/main/java/net/typeblog/shelter/util/Utility.java b/app/src/main/java/net/typeblog/shelter/util/Utility.java index b36585b..3d3cf7a 100644 --- a/app/src/main/java/net/typeblog/shelter/util/Utility.java +++ b/app/src/main/java/net/typeblog/shelter/util/Utility.java @@ -353,7 +353,7 @@ public class Utility { public static String getFileExtension(String filePath) { int index = filePath.lastIndexOf("."); if (index > 0) { - return filePath.substring(index + 1, filePath.length()); + return filePath.substring(index + 1); } else { return null; }