Skip to content

Commit 2288100

Browse files
committed
- Update org.redwid.android.youtube.dl:python to 0.6.5 version;
- Bump app version to 1.0.2
1 parent cde1215 commit 2288100

File tree

4 files changed

+66
-36
lines changed

4 files changed

+66
-36
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ before_deploy:
3434
- git tag $TRAVIS_TAG
3535

3636
deploy:
37-
dry_run: true
37+
#dry_run: true
3838
provider: releases
3939
api_key: $GITHUB_OAUTH_TOKEN
4040
file: app/build/outputs/apk/debug/app-debug.apk
4141
skip_cleanup: true
42-
name: '1.0.1'
42+
name: '1.0.2'

lib/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
minSdkVersion 14
1414
targetSdkVersion 28
1515
versionCode 1
16-
versionName "1.0"
16+
versionName "1.0.2"
1717

1818
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1919

@@ -26,18 +26,18 @@ android {
2626
}
2727

2828
dependencies {
29-
implementation 'androidx.appcompat:appcompat:1.0.0'
29+
implementation 'androidx.appcompat:appcompat:1.0.2'
3030
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
3131
implementation 'androidx.recyclerview:recyclerview:1.0.0'
3232

3333
implementation 'com.jakewharton.timber:timber:4.7.0'
3434

35-
implementation 'org.redwid.android.youtube.dl:python:0.6.3:arm64-v8a@aar'
36-
implementation 'org.redwid.android.youtube.dl:python:0.6.3:armeabi-v7a@aar'
35+
implementation 'org.redwid.android.youtube.dl:python:0.6.5:arm64-v8a@aar'
36+
implementation 'org.redwid.android.youtube.dl:python:0.6.5:armeabi-v7a@aar'
3737

3838
testImplementation 'junit:junit:4.12'
39-
androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
40-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-beta02'
39+
androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
40+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
4141
}
4242

4343
uploadArchives {

lib/src/main/java/org/redwid/android/youtube/dl/TaskWorkerThread.java

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public interface TaskWorkerThreadListener {
2323
private UnpackTask unpackTask;
2424

2525
private boolean active = true;
26+
private Object taskInProgress = new Object();
2627

2728
public TaskWorkerThread(final Context context) {
2829
this.context = context;
@@ -32,12 +33,20 @@ public TaskWorkerThread(final Context context) {
3233
public void run() {
3334
while (active) {
3435
if (!list.isEmpty()) {
35-
try {
36-
performTask();
37-
}
38-
catch (Exception e) {
39-
Timber.e(e, "ERROR in run()");
40-
}
36+
37+
final String stringUrl = list.get(0);
38+
Timber.i("performTask(), stringUrl: %s", stringUrl);
39+
40+
final Thread thread = new Thread(new Runnable() {
41+
@Override
42+
public void run() {
43+
performTask(stringUrl);
44+
wakeUpTaskInProgress();
45+
}
46+
});
47+
thread.start();
48+
49+
sleepTaskInProgress();
4150
}
4251
else {
4352
Timber.i("run() sleep");
@@ -46,6 +55,25 @@ public void run() {
4655
}
4756
}
4857

58+
private void sleepTaskInProgress() {
59+
Timber.i("sleepTaskInProgress() begin");
60+
synchronized (taskInProgress) {
61+
try {
62+
taskInProgress.wait(10000);
63+
} catch (InterruptedException e) {
64+
Timber.e(e, "EROR in sleepTaskInProgress() interrupted");
65+
}
66+
}
67+
Timber.i("sleepTaskInProgress() done");
68+
}
69+
70+
private void wakeUpTaskInProgress() {
71+
Timber.i("wakeUpTaskInProgress()");
72+
synchronized (taskInProgress) {
73+
taskInProgress.notify();
74+
}
75+
}
76+
4977
public void cancel() {
5078
active = false;
5179
}
@@ -67,35 +95,37 @@ private synchronized void sleep() {
6795
try {
6896
Timber.i("sleep() begin ...");
6997
wait();
98+
Timber.i("sleep() done ...");
7099
} catch (InterruptedException e) {
71-
Timber.i("sleep() end ...");
100+
Timber.e(e,"ERROR in sleep()");
72101
}
73102
}
74103

75-
private void performTask() {
104+
private void performTask(final String stringUrl) {
76105
Timber.i("performTask()");
77-
78-
if(unpackTask == null) {
79-
unpackTask = new UnpackTask();
80-
if(!unpackTask.unpack(context.getApplicationContext())) {
81-
unpackTask = null;
106+
try {
107+
if (unpackTask == null) {
108+
unpackTask = new UnpackTask();
109+
if (!unpackTask.unpack(context.getApplicationContext())) {
110+
unpackTask = null;
111+
}
82112
}
83-
}
84113

85-
final String stringUrl = list.get(0);
86-
Timber.i("performTask(), stringUrl: %s", stringUrl);
87-
88-
final YoutubeDlWorker youtubeDlWorker = new YoutubeDlWorker();
89-
if(youtubeDlWorker.process(context.getApplicationContext(), stringUrl)) {
90-
Timber.i("performTask(), success");
91-
}
92-
list.remove(0);
93-
if(list.isEmpty()) {
94-
Timber.i("performTask(), list.isEmpty()");
95-
if(context instanceof TaskWorkerThreadListener) {
96-
Timber.i("performTask(), context instanceof TaskWorkerThreadListener");
97-
((TaskWorkerThreadListener)context).onCompleteAllItems();
114+
final YoutubeDlWorker youtubeDlWorker = new YoutubeDlWorker();
115+
if (youtubeDlWorker.process(context.getApplicationContext(), stringUrl)) {
116+
Timber.i("performTask(), success");
98117
}
118+
list.remove(stringUrl);
119+
if (list.isEmpty()) {
120+
Timber.i("performTask(), list.isEmpty()");
121+
if (context instanceof TaskWorkerThreadListener) {
122+
Timber.i("performTask(), context instanceof TaskWorkerThreadListener");
123+
((TaskWorkerThreadListener) context).onCompleteAllItems();
124+
}
125+
}
126+
}
127+
catch (Exception e) {
128+
Timber.e(e, "ERROR in performTask(%s)", stringUrl);
99129
}
100130
}
101131
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<resources>
22
<string name="app_name">lib</string>
3-
<string name="private_version">24_04_2019</string>
3+
<string name="private_version">25_06_2019</string>
44
<string name="notification_channel_name">Youtube-Dl Service</string>
55
</resources>

0 commit comments

Comments
 (0)