From 68c503414ffa16026cba27c319bdc8249f3de307 Mon Sep 17 00:00:00 2001 From: Faisal Hameed Date: Fri, 24 Jun 2016 01:21:45 +0500 Subject: [PATCH] Fixing squid:S1213 - The members of an interface declaration or class should appear in a pre-defined order. --- .../com/vincestyling/netroid/NetroidLog.java | 7 +-- .../vincestyling/netroid/NetworkResponse.java | 30 +++++++------ .../com/vincestyling/netroid/Request.java | 15 ++++--- .../com/vincestyling/netroid/Response.java | 43 ++++++++++--------- .../vincestyling/netroid/cache/DiskCache.java | 15 ++++--- .../netroid/toolbox/ByteArrayPool.java | 9 ++-- .../netroid/sample/FileDownloadActivity.java | 9 ++-- .../netroid/sample/GridViewActivity.java | 4 +- 8 files changed, 71 insertions(+), 61 deletions(-) diff --git a/library/src/main/java/com/vincestyling/netroid/NetroidLog.java b/library/src/main/java/com/vincestyling/netroid/NetroidLog.java index 798d274..f70f93f 100755 --- a/library/src/main/java/com/vincestyling/netroid/NetroidLog.java +++ b/library/src/main/java/com/vincestyling/netroid/NetroidLog.java @@ -27,14 +27,15 @@ */ public class NetroidLog { - private NetroidLog() { - /* cannot be instantiated */ - } public static String TAG = "Netroid"; public static boolean DEBUG = Log.isLoggable(TAG, Log.VERBOSE); + private NetroidLog() { + /* cannot be instantiated */ + } + /** * Customize the log tag for your application, so that other apps * using Netroid don't mix their logs with yours. diff --git a/library/src/main/java/com/vincestyling/netroid/NetworkResponse.java b/library/src/main/java/com/vincestyling/netroid/NetworkResponse.java index e6d91cb..3eb9854 100755 --- a/library/src/main/java/com/vincestyling/netroid/NetworkResponse.java +++ b/library/src/main/java/com/vincestyling/netroid/NetworkResponse.java @@ -21,6 +21,22 @@ * Data and headers returned from {@link Network#performRequest(Request)}. */ public class NetworkResponse { + + /** + * The HTTP status code. + */ + public final int statusCode; + + /** + * Raw data from this response. + */ + public final byte[] data; + + /** + * Charset from this response. + */ + public final String charset; + /** * Creates a new network response. * @@ -42,18 +58,4 @@ public NetworkResponse(byte[] data, String charset) { this(HttpStatus.SC_OK, data, charset); } - /** - * The HTTP status code. - */ - public final int statusCode; - - /** - * Raw data from this response. - */ - public final byte[] data; - - /** - * Charset from this response. - */ - public final String charset; } \ No newline at end of file diff --git a/library/src/main/java/com/vincestyling/netroid/Request.java b/library/src/main/java/com/vincestyling/netroid/Request.java index 4d817ac..f317bc1 100755 --- a/library/src/main/java/com/vincestyling/netroid/Request.java +++ b/library/src/main/java/com/vincestyling/netroid/Request.java @@ -132,6 +132,14 @@ public interface Method { */ private Object mTag; + + /** + * Indicates DeliverPreExecute operation is done or not, + * because the {@link CacheDispatcher} and {@link NetworkDispatcher} + * both will call this deliver, and we must ensure just invoke once. + */ + private boolean mIsDeliverPreExecute; + /** * Creates a new request with the given method (one of the values from {@link Method}), * URL, and error listener. Note that the normal response listener is not provided here as @@ -598,13 +606,6 @@ public void deliverCancel() { } } - /** - * Indicates DeliverPreExecute operation is done or not, - * because the {@link CacheDispatcher} and {@link NetworkDispatcher} - * both will call this deliver, and we must ensure just invoke once. - */ - private boolean mIsDeliverPreExecute; - /** * Delivers request is handling to the Listener. */ diff --git a/library/src/main/java/com/vincestyling/netroid/Response.java b/library/src/main/java/com/vincestyling/netroid/Response.java index ec75010..ed8558c 100755 --- a/library/src/main/java/com/vincestyling/netroid/Response.java +++ b/library/src/main/java/com/vincestyling/netroid/Response.java @@ -24,20 +24,6 @@ */ public class Response { - /** - * Returns a successful response containing the parsed result. - */ - public static Response success(T result, NetworkResponse response) { - return new Response<>(result, response); - } - - /** - * Returns a failed response containing the given error code and an optional - * localized message displayed to the user. - */ - public static Response error(NetroidError error) { - return new Response<>(error); - } /** * Parsed response, or null in the case of error. @@ -59,12 +45,6 @@ public static Response error(NetroidError error) { */ public boolean intermediate = false; - /** - * Returns whether this response is considered successful. - */ - public boolean isSuccess() { - return errorDetail == null; - } private Response(T result, NetworkResponse response) { this.result = result; @@ -77,4 +57,27 @@ private Response(NetroidError error) { this.cacheEntry = null; this.errorDetail = error; } + + /** + * Returns a successful response containing the parsed result. + */ + public static Response success(T result, NetworkResponse response) { + return new Response<>(result, response); + } + + /** + * Returns a failed response containing the given error code and an optional + * localized message displayed to the user. + */ + public static Response error(NetroidError error) { + return new Response<>(error); + } + + /** + * Returns whether this response is considered successful. + */ + public boolean isSuccess() { + return errorDetail == null; + } + } diff --git a/library/src/main/java/com/vincestyling/netroid/cache/DiskCache.java b/library/src/main/java/com/vincestyling/netroid/cache/DiskCache.java index bbc9272..7072b5b 100755 --- a/library/src/main/java/com/vincestyling/netroid/cache/DiskCache.java +++ b/library/src/main/java/com/vincestyling/netroid/cache/DiskCache.java @@ -452,13 +452,6 @@ public void setCharset(String charset) { * Data and metadata for an entry returned by the cache. */ public static class Entry { - public Entry() { - } - - public Entry(byte[] data, String charset) { - this.data = data; - this.charset = charset; - } /** * The data returned from cache. @@ -475,6 +468,14 @@ public Entry(byte[] data, String charset) { */ private String charset; + public Entry() { + } + + public Entry(byte[] data, String charset) { + this.data = data; + this.charset = charset; + } + /** * True if the entry is expired. */ diff --git a/library/src/main/java/com/vincestyling/netroid/toolbox/ByteArrayPool.java b/library/src/main/java/com/vincestyling/netroid/toolbox/ByteArrayPool.java index 1b96111..a734619 100755 --- a/library/src/main/java/com/vincestyling/netroid/toolbox/ByteArrayPool.java +++ b/library/src/main/java/com/vincestyling/netroid/toolbox/ByteArrayPool.java @@ -64,6 +64,11 @@ public class ByteArrayPool { */ private final int mSizeLimit; + /** + * Singleton for this class. + */ + private static ByteArrayPool mPool; + /** * Compares buffers by size */ @@ -81,10 +86,6 @@ private ByteArrayPool(int sizeLimit) { mSizeLimit = sizeLimit; } - /** - * Singleton for this class. - */ - private static ByteArrayPool mPool; /** * Get the singleton instance. diff --git a/sample/src/main/java/com/vincestyling/netroid/sample/FileDownloadActivity.java b/sample/src/main/java/com/vincestyling/netroid/sample/FileDownloadActivity.java index c68588a..77956a8 100644 --- a/sample/src/main/java/com/vincestyling/netroid/sample/FileDownloadActivity.java +++ b/sample/src/main/java/com/vincestyling/netroid/sample/FileDownloadActivity.java @@ -243,6 +243,11 @@ private class DownloadTask { long fileSize; long downloadedSize; + private DownloadTask(String storeFileName, String url) { + this.storeFileName = storeFileName; + this.url = url; + } + private void onProgressChange(long fileSize, long downloadedSize) { this.fileSize = fileSize; this.downloadedSize = downloadedSize; @@ -276,9 +281,5 @@ private void invalidate() { txvFileSize.setText(Formatter.formatFileSize(FileDownloadActivity.this, fileSize)); } - private DownloadTask(String storeFileName, String url) { - this.storeFileName = storeFileName; - this.url = url; - } } } diff --git a/sample/src/main/java/com/vincestyling/netroid/sample/GridViewActivity.java b/sample/src/main/java/com/vincestyling/netroid/sample/GridViewActivity.java index e1b36ff..98b3827 100644 --- a/sample/src/main/java/com/vincestyling/netroid/sample/GridViewActivity.java +++ b/sample/src/main/java/com/vincestyling/netroid/sample/GridViewActivity.java @@ -23,6 +23,8 @@ public class GridViewActivity extends BaseActivity { private BaseAdapter mAdapter; private List bookList; + private Toast mToast; + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gridview_p0); @@ -134,8 +136,6 @@ public void onItemClick(AdapterView parent, View view, int position, long id) }); } - private Toast mToast; - private void showToast(CharSequence msg) { if (mToast != null) mToast.cancel(); mToast = Toast.makeText(this, msg, Toast.LENGTH_SHORT);