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

Commit

Permalink
2020-01-31 Version 1.0.4: Refactored FileCopy class and updated Travi…
Browse files Browse the repository at this point in the history
…s CI configuration
  • Loading branch information
fartem committed Jan 31, 2020
1 parent 0fa64ff commit a7cd961
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ before_install:
script:
- ./gradlew checkstyle
- ./gradlew cpdCheck
- ./gradlew test
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
- ./gradlew connectedAndroidTest
- adb logcat &
- ./gradlew -Pandroid.testInstrumentationRunnerArguments.class=com.smlnskgmail.jaman.ormlitedatabackup.TravisCIAndroidTestSuite connectedAndroidTest
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0.3"
versionName "1.0.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.smlnskgmail.jaman.ormlitedatabackup;

import com.smlnskgmail.jaman.ormlitedatabackup.backup.OrmLiteBackupCheckTest;
import com.smlnskgmail.jaman.ormlitedatabackup.ui.CreateEventTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({
CreateEventTest.class,
OrmLiteBackupCheckTest.class
})
public class TravisCIAndroidTestSuite {

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ private File localBackupFile() {
return new File(ormLiteLocalBackupPath.pathAsString());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public boolean copy() {
try {
inputStream = fromAsStream != null
? fromAsStream
: context.getContentResolver().openInputStream(
Uri.fromFile(new File(from))
: context.getContentResolver().openInputStream(Uri.fromFile(new File(from))
);
File toFile = new File(to);
if (toFile.exists()) {
Expand All @@ -66,7 +65,7 @@ public boolean copy() {

byte[] buffer = new byte[1024];
int length;
while ((length = Objects.requireNonNull(inputStream).read(buffer)) > 0) {
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}

Expand All @@ -77,8 +76,12 @@ public boolean copy() {
return false;
} finally {
try {
Objects.requireNonNull(inputStream).close();
Objects.requireNonNull(outputStream).close();
if (inputStream != null) {
inputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
} catch (IOException e) {
L.e(e);
}
Expand Down

0 comments on commit a7cd961

Please sign in to comment.