Skip to content
This repository was archived by the owner on Aug 15, 2021. It is now read-only.

Commit a7cd961

Browse files
committed
2020-01-31 Version 1.0.4: Refactored FileCopy class and updated Travis CI configuration
1 parent 0fa64ff commit a7cd961

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ before_install:
2525
script:
2626
- ./gradlew checkstyle
2727
- ./gradlew cpdCheck
28-
- ./gradlew test
2928
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
3029
- emulator -avd test -no-skin -no-audio -no-window &
3130
- android-wait-for-emulator
3231
- adb shell input keyevent 82 &
33-
- ./gradlew connectedAndroidTest
32+
- adb logcat &
33+
- ./gradlew -Pandroid.testInstrumentationRunnerArguments.class=com.smlnskgmail.jaman.ormlitedatabackup.TravisCIAndroidTestSuite connectedAndroidTest

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
minSdkVersion 21
1111
targetSdkVersion 29
1212
versionCode 1
13-
versionName "1.0.3"
13+
versionName "1.0.4"
1414

1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.smlnskgmail.jaman.ormlitedatabackup;
2+
3+
import com.smlnskgmail.jaman.ormlitedatabackup.backup.OrmLiteBackupCheckTest;
4+
import com.smlnskgmail.jaman.ormlitedatabackup.ui.CreateEventTest;
5+
6+
import org.junit.runner.RunWith;
7+
import org.junit.runners.Suite;
8+
9+
@RunWith(Suite.class)
10+
@Suite.SuiteClasses({
11+
CreateEventTest.class,
12+
OrmLiteBackupCheckTest.class
13+
})
14+
public class TravisCIAndroidTestSuite {
15+
16+
}

app/src/androidTest/java/com/smlnskgmail/jaman/ormlitedatabackup/backup/CreateOrmLiteLocalBackupTaskTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ private File localBackupFile() {
6666
return new File(ormLiteLocalBackupPath.pathAsString());
6767
}
6868

69-
}
69+
}

app/src/main/java/com/smlnskgmail/jaman/ormlitedatabackup/logic/ormlite/backup/FileCopy.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public boolean copy() {
5050
try {
5151
inputStream = fromAsStream != null
5252
? fromAsStream
53-
: context.getContentResolver().openInputStream(
54-
Uri.fromFile(new File(from))
53+
: context.getContentResolver().openInputStream(Uri.fromFile(new File(from))
5554
);
5655
File toFile = new File(to);
5756
if (toFile.exists()) {
@@ -66,7 +65,7 @@ public boolean copy() {
6665

6766
byte[] buffer = new byte[1024];
6867
int length;
69-
while ((length = Objects.requireNonNull(inputStream).read(buffer)) > 0) {
68+
while ((length = inputStream.read(buffer)) > 0) {
7069
outputStream.write(buffer, 0, length);
7170
}
7271

@@ -77,8 +76,12 @@ public boolean copy() {
7776
return false;
7877
} finally {
7978
try {
80-
Objects.requireNonNull(inputStream).close();
81-
Objects.requireNonNull(outputStream).close();
79+
if (inputStream != null) {
80+
inputStream.close();
81+
}
82+
if (outputStream != null) {
83+
outputStream.close();
84+
}
8285
} catch (IOException e) {
8386
L.e(e);
8487
}

0 commit comments

Comments
 (0)