File tree 3 files changed +18
-2
lines changed
src/main/java/ch/fixme/status
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -25,4 +25,5 @@ android {
25
25
}
26
26
27
27
dependencies {
28
+ implementation " androidx.annotation:annotation:1.1.0"
28
29
}
Original file line number Diff line number Diff line change 59
59
import java .util .Set ;
60
60
import java .util .regex .Pattern ;
61
61
62
+ import androidx .annotation .UiThread ;
63
+
62
64
public class Main extends Activity {
63
65
64
66
// API: https://spaceapi.io/
@@ -92,6 +94,7 @@ public class Main extends Activity {
92
94
private GetImage getImageTask ;
93
95
94
96
@ Override
97
+ @ UiThread
95
98
public void onCreate (Bundle savedInstanceState ) {
96
99
super .onCreate (savedInstanceState );
97
100
setContentView (R .layout .main );
@@ -110,12 +113,14 @@ public void onCreate(Bundle savedInstanceState) {
110
113
}
111
114
112
115
@ Override
116
+ @ UiThread
113
117
protected void onNewIntent (Intent intent ) {
114
118
Log .d (TAG , "onNewIntent()=" + intent );
115
119
showHsInfo (intent );
116
120
}
117
121
118
122
@ Override
123
+ @ UiThread
119
124
protected void onDestroy () {
120
125
if (getApiTask != null ) {
121
126
getApiTask .cancel (true );
@@ -205,6 +210,7 @@ protected Dialog onCreateDialog(int id) {
205
210
}
206
211
207
212
@ Override
213
+ @ UiThread
208
214
public void startActivity (Intent intent ) {
209
215
// http://stackoverflow.com/questions/13691241/autolink-not-working-on-htc-htclinkifydispatcher
210
216
try {
Original file line number Diff line number Diff line change 18
18
import java .net .HttpURLConnection ;
19
19
import java .net .URL ;
20
20
21
+ import androidx .annotation .NonNull ;
22
+ import androidx .annotation .WorkerThread ;
23
+
21
24
// From CommonsWare and Android Blog
22
25
// https://github.com/commonsguy/cw-android/tree/master/Internet
23
26
// http://android-developers.blogspot.ch/2010/07/multithreading-for-performance.html
@@ -31,11 +34,13 @@ public class Net {
31
34
private HttpURLConnection mUrlConnection ;
32
35
private InputStream mInputStream ;
33
36
34
- public Net (String urlStr ) throws Throwable {
37
+ @ WorkerThread
38
+ public Net (@ NonNull String urlStr ) throws Throwable {
35
39
this (urlStr , true );
36
40
}
37
41
38
- public Net (String urlStr , boolean useCache ) throws Throwable {
42
+ @ WorkerThread
43
+ public Net (@ NonNull String urlStr , boolean useCache ) throws Throwable {
39
44
// Connect to URL
40
45
URL url ;
41
46
int responseCode ;
@@ -70,6 +75,8 @@ public Net(String urlStr, boolean useCache) throws Throwable {
70
75
mInputStream = mUrlConnection .getInputStream ();
71
76
}
72
77
78
+ @ WorkerThread
79
+ @ NonNull
73
80
public String getString () throws Throwable {
74
81
try {
75
82
BufferedReader r = new BufferedReader (new InputStreamReader (mInputStream ));
@@ -87,6 +94,8 @@ public String getString() throws Throwable {
87
94
}
88
95
}
89
96
97
+ @ WorkerThread
98
+ @ NonNull
90
99
public Bitmap getBitmap () throws Throwable {
91
100
try {
92
101
return BitmapFactory .decodeStream (new FlushedInputStream (mInputStream ));
You can’t perform that action at this time.
0 commit comments