Skip to content
This repository was archived by the owner on Dec 17, 2020. It is now read-only.

Commit 23d5be6

Browse files
committed
Update to Android Studio 3.0, Gradle Android Tools 3, Gradle 4.1 and Support library to 26.1
Also updated the
1 parent b994ef6 commit 23d5be6

File tree

12 files changed

+146
-34
lines changed

12 files changed

+146
-34
lines changed

annotations-processor/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ group = GROUP
1111
version = VERSION_NAME
1212

1313
dependencies {
14-
compile fileTree(include: ['*.jar'], dir: 'libs')
15-
compile project(':annotations')
14+
implementation fileTree(include: ['*.jar'], dir: 'libs')
15+
implementation project(':annotations')
1616

1717
// Java Poet to create Java source files
18-
compile 'com.squareup:javapoet:1.9.0'
18+
implementation 'com.squareup:javapoet:1.9.0'
1919

2020
// For NotNull, Nullable etc. annotations
21-
compile 'com.google.code.findbugs:jsr305:3.0.2'
21+
implementation 'com.google.code.findbugs:jsr305:3.0.2'
2222

2323
// Fix for warning: "bootstrap class path not set in conjunction with -source 1.7"
2424
compileOnly files(Jvm.current().getToolsJar())

annotations/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ group = GROUP
1111
version = VERSION_NAME
1212

1313
dependencies {
14-
compile fileTree(dir: 'libs', include: ['*.jar'])
14+
implementation fileTree(dir: 'libs', include: ['*.jar'])
1515

1616
// Fix for warning: "bootstrap class path not set in conjunction with -source 1.7"
1717
compileOnly files(Jvm.current().getToolsJar())

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.3'
9+
classpath 'com.android.tools.build:gradle:3.0.0'
910

1011
// Bintray
1112
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
@@ -20,7 +21,7 @@ buildscript {
2021
allprojects {
2122
repositories {
2223
jcenter()
23-
maven { url 'https://maven.google.com' }
24+
google()
2425
}
2526
}
2627

demo/build.gradle

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 26
5-
buildToolsVersion '25.0.3'
5+
buildToolsVersion '26.0.2'
66

77
defaultConfig {
88
applicationId "org.neotech.app.retainabletasksdemo"
@@ -20,19 +20,18 @@ android {
2020
}
2121

2222
dependencies {
23-
compile project(':library')
24-
compile project(":annotations")
23+
implementation project(':library')
24+
implementation project(":annotations")
2525
annotationProcessor project(":annotations-processor")
26-
//compile 'org.neotech.library:android-retainable-tasks:1.0.0-rc-2'
2726

28-
compile 'com.android.support:appcompat-v7:26.0.2'
29-
compile 'com.android.support:design:26.0.2'
27+
implementation 'com.android.support:appcompat-v7:26.1.0'
28+
implementation 'com.android.support:design:26.1.0'
3029

3130
//LeakCanary is used to detect memory leaks in debug builds.
32-
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
33-
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
34-
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
31+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
32+
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
33+
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
3534

3635
//Unit-testing
37-
testCompile 'junit:junit:4.12'
36+
testImplementation 'junit:junit:4.12'
3837
}

demo/src/main/AndroidManifest.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434
android:value=".activity.Main" />
3535
</activity>
3636

37+
<activity
38+
android:name=".activity.DemoActivityLifeCycleLibrary"
39+
android:label="@string/app_name"
40+
android:parentActivityName=".activity.Main"
41+
tools:targetApi="jelly_bean">
42+
<!-- Parent activity meta-data to support 4.0 and lower -->
43+
<meta-data
44+
android:name="android.support.PARENT_ACTIVITY"
45+
android:value=".activity.Main" />
46+
</activity>
47+
3748
<activity
3849
android:name=".activity.DemoActivityAnnotations"
3950
android:label="@string/app_name"
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package org.neotech.app.retainabletasksdemo.activity;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.NonNull;
5+
import android.support.annotation.Nullable;
6+
import android.support.design.widget.Snackbar;
7+
import android.support.v4.app.DialogFragment;
8+
import android.support.v7.app.AppCompatActivity;
9+
import android.view.View;
10+
11+
import org.neotech.app.retainabletasksdemo.OnAlertDialogClickListener;
12+
import org.neotech.app.retainabletasksdemo.ProgressDialog;
13+
import org.neotech.app.retainabletasksdemo.R;
14+
import org.neotech.app.retainabletasksdemo.tasks.SimpleTask;
15+
import org.neotech.library.retainabletasks.*;
16+
import org.neotech.library.retainabletasks.providers.TaskActivityCompat;
17+
18+
/**
19+
* This demo activity shows how the lifecycle library from the Google Architecture Library can be
20+
* used to hook the activity lifecycle calls to the TaskManagerLifeCycleProxy. This example also
21+
* uses the annotations just like the DemoActivityAnnotations.
22+
* <p>
23+
* Created by Rolf Smit on 8-Nov-17.
24+
*/
25+
public final class DemoActivityLifeCycleLibrary extends AppCompatActivity implements View.OnClickListener, OnAlertDialogClickListener, TaskManagerOwner {
26+
27+
private static final String TASK_PROGRESS = "progress-dialog";
28+
private static final String DIALOG_PROGRESS = "progress-dialog";
29+
30+
private ProgressDialog progressDialog;
31+
32+
private final TaskManagerLifeCycleProxy taskManagerLifeCycleProxy = new TaskManagerLifeCycleProxy(this);
33+
34+
public DemoActivityLifeCycleLibrary() {
35+
getLifecycle().addObserver(taskManagerLifeCycleProxy);
36+
}
37+
38+
@Override
39+
protected void onCreate(@Nullable Bundle savedInstanceState) {
40+
super.onCreate(savedInstanceState);
41+
setContentView(R.layout.activity_demo_annotations);
42+
findViewById(R.id.button_progress_task).setOnClickListener(this);
43+
44+
if (savedInstanceState == null) {
45+
// After starting this activity directly start the task.
46+
execute();
47+
}
48+
}
49+
50+
@Override
51+
public void onClick(View v) {
52+
// On click execute the task
53+
execute();
54+
}
55+
56+
@Override
57+
public void onDialogFragmentClick(DialogFragment fragment, int which) {
58+
getTaskManager().cancel(TASK_PROGRESS);
59+
}
60+
61+
@Override
62+
public TaskManager getTaskManager() {
63+
return taskManagerLifeCycleProxy.getTaskManager();
64+
}
65+
66+
@Override
67+
public Task.Callback onPreAttach(@NonNull Task<?, ?> task) {
68+
return null;
69+
}
70+
71+
public void execute(){
72+
if(!getTaskManager().isActive(TASK_PROGRESS)) {
73+
getTaskManager().execute(new SimpleTask(TASK_PROGRESS));
74+
}
75+
}
76+
77+
@TaskAttach(TASK_PROGRESS)
78+
public void onAttach(SimpleTask task){
79+
// Task attaches, make sure to show the progress dialog and update the progress if needed.
80+
progressDialog = ProgressDialog.showIfNotShowing(getSupportFragmentManager(), DIALOG_PROGRESS);
81+
if(task.getLastKnownProgress() != null) {
82+
progressDialog.setProgress(task.getLastKnownProgress());
83+
}
84+
}
85+
86+
@TaskProgress(TASK_PROGRESS)
87+
public void onProgress(SimpleTask task){
88+
progressDialog.setProgress(task.getLastKnownProgress());
89+
}
90+
91+
// Now this is cool, we can have a single method handle both the normal onPostExecute and the
92+
// onCancelled call.
93+
@TaskPostExecute(TASK_PROGRESS)
94+
@TaskCancel(TASK_PROGRESS)
95+
public void onFinish(SimpleTask task){
96+
progressDialog.dismiss();
97+
if(task.isCancelled()) {
98+
Snackbar.make(findViewById(android.R.id.content), getString(R.string.toast_task_canceled, getString(R.string.task_progress_dialog)), Snackbar.LENGTH_LONG).show();
99+
}
100+
}
101+
}

demo/src/main/java/org/neotech/app/retainabletasksdemo/activity/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ protected ArrayList<Demo> doInBackground() {
104104
ArrayList<Demo> demos = new ArrayList<>(4);
105105
demos.add(new Demo(context, R.string.demo_examples_title, R.string.demo_examples_description, "org/neotech/app/retainabletasksdemo/activity/DemoActivityBasic.java", new Intent(context, DemoActivityBasic.class)));
106106
demos.add(new Demo(context, R.string.demo_annotations_title, R.string.demo_annotations_description, "org/neotech/app/retainabletasksdemo/activity/DemoActivityAnnotations.java", new Intent(context, DemoActivityAnnotations.class)));
107+
demos.add(new Demo(context, R.string.demo_lifecycle_library_title, R.string.demo_lifecycle_library_description, "org/neotech/app/retainabletasksdemo/activity/DemoActivityLifeCycleLibrary.java", new Intent(context, DemoActivityLifeCycleLibrary.class)));
107108

108109
demos.add(new Demo(context, R.string.demo_serial_title, R.string.demo_serial_description, "org/neotech/app/retainabletasksdemo/activity/DemoActivitySerial.java", new Intent(context, DemoActivitySerial.class)));
109110
demos.add(new Demo(context, R.string.demo_fragments_title, R.string.demo_fragments_description, "org/neotech/app/retainabletasksdemo/activity/DemoActivityFragments.java", new Intent(context, DemoActivityFragments.class)));

demo/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
<string name="demo_annotations_title">Annotations example</string>
4747
<string name="demo_annotations_description">"<![CDATA[This demonstration shows an Activity which extends <code>TaskActivityCompat</code> and uses Annotations to receive <code>Task</code> lifecycle events like <code>onPostExecute</code>.]]>"</string>
4848

49+
<string name="demo_lifecycle_library_title">Google Architecture Lifecycle example</string>
50+
<string name="demo_lifecycle_library_description">"<![CDATA[This demonstration shows an Activity which extends a normal <code>AppCompatActivity</code> and uses the <code>Lifecycle</code> class from Google's Architecture library to hook the Activity lifecycle to the <code>TaskManagerLifeCycleProxy</code>. This basically shows how the library can be used without extending from the <code>TaskActivityCompat</code> class.]]>"</string>
51+
4952
<string name="demo_serial_title">Serial execution</string>
5053
<string name="demo_serial_description">"<![CDATA[By default <code>Tasks</code> are executed using a parallel Executor. This demonstration shows how <code>Tasks</code> can be executed in serial using the <code>TaskManager.execute(Task, Callback, Executor)</code> method.]]>"</string>
5154

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# org.gradle.parallel=true
1919

2020
GROUP=org.neotech.library
21-
VERSION_NAME=1.0.0-rc-2
21+
VERSION_NAME=1.0.0
2222

2323
BINTRAY_REPO=maven
2424
BINTRAY_LICENCE=Apache-2.0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Apr 10 12:06:51 CEST 2017
1+
#Wed Nov 08 15:14:25 CET 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 commit comments

Comments
 (0)