forked from organicmaps/organicmaps-tmp
[alohalytics][android] Fixed lint warnings.
This commit is contained in:
parent
8494d06d54
commit
82875ff957
6 changed files with 15 additions and 7 deletions
|
@ -22,8 +22,8 @@ dependencies {
|
|||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion '22'
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion '22.0.1'
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'org.alohalytics.demoapp'
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
|
||||
// <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class HttpTransportTest extends InstrumentationTestCase {
|
||||
|
||||
static {
|
||||
|
|
|
@ -33,10 +33,16 @@ public class Util {
|
|||
|
||||
public static String ReadFileAsUtf8String(String filePath) throws IOException {
|
||||
final File file = new File(filePath);
|
||||
final byte[] buffer = new byte[(int) file.length()];
|
||||
final long fileLength = file.length();
|
||||
if (fileLength > Integer.MAX_VALUE) {
|
||||
throw new IOException(filePath + " size is too large: " + fileLength);
|
||||
}
|
||||
final byte[] buffer = new byte[(int) fileLength];
|
||||
final FileInputStream istream = new FileInputStream(file);
|
||||
try {
|
||||
istream.read(buffer);
|
||||
if (fileLength != istream.read(buffer)) {
|
||||
throw new IOException("Error while reading contents of " + filePath);
|
||||
}
|
||||
} finally {
|
||||
istream.close();
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class MainActivity extends Activity {
|
|||
// Event with parameter (key=value)
|
||||
Statistics.logEvent("device_manufacturer", Build.MANUFACTURER);
|
||||
|
||||
final HashMap<String, String> kv = new HashMap<String, String>();
|
||||
final HashMap<String, String> kv = new HashMap<>();
|
||||
kv.put("brand", Build.BRAND);
|
||||
kv.put("device", Build.DEVICE);
|
||||
kv.put("model", Build.MODEL);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
android:hint="@string/test_event_hint"
|
||||
android:inputType="textUri"
|
||||
android:layout_toLeftOf="@+id/button"
|
||||
android:layout_toStartOf="@+id/button"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"/>
|
||||
|
|
|
@ -42,7 +42,7 @@ public class HttpTransport {
|
|||
|
||||
// TODO(AlexZ): tune for larger files
|
||||
private final static int STREAM_BUFFER_SIZE = 1024 * 64;
|
||||
private final static String TAG = "Alohalytics-HttpTransport";
|
||||
private final static String TAG = "Alohalytics-Http";
|
||||
// Globally accessible for faster unit-testing
|
||||
public static int TIMEOUT_IN_MILLISECONDS = 30000;
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class HttpTransport {
|
|||
}
|
||||
istream.close(); // IOException
|
||||
ostream.close(); // IOException
|
||||
if (ostream.getClass().equals(ByteArrayOutputStream.class)) {
|
||||
if (ostream instanceof ByteArrayOutputStream) {
|
||||
p.data = ((ByteArrayOutputStream) ostream).toByteArray();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue