23
23
import android .support .design .widget .FloatingActionButton ;
24
24
import android .support .design .widget .Snackbar ;
25
25
import android .support .v4 .app .Fragment ;
26
+ import android .support .v4 .app .FragmentActivity ;
26
27
import android .text .Html ;
27
28
import android .text .method .LinkMovementMethod ;
28
29
import android .util .Log ;
@@ -109,7 +110,7 @@ public void onViewCreated (View v, Bundle savedInstanceState) {
109
110
startActivity (browserIntent );
110
111
}
111
112
});
112
- fab .setVisibility ( View . GONE );
113
+ fab .hide ( );
113
114
114
115
((DetailsActivity ) getActivity ()).addListener (this );
115
116
@@ -146,7 +147,7 @@ public void displayHtml (String html) {
146
147
public void loadingFinished () {
147
148
txtPolicy .setVisibility (View .VISIBLE );
148
149
pbPolicy .setVisibility (View .GONE );
149
- fab .setVisibility ( View . VISIBLE );
150
+ fab .show ( );
150
151
}
151
152
152
153
@ Override
@@ -156,16 +157,17 @@ public void appInfoLoaded () {
156
157
157
158
private class PolicyLoader implements Runnable {
158
159
private void onError (final String url ) {
159
- getActivity (). runOnUiThread ( new Runnable () {
160
- public void run () {
161
- if ( url != null ) {
162
- html = getString ( R . string . parse_error , Html . escapeHtml ( url ));
163
- displayHtml ( html );
164
- } else {
165
- txtPolicy . setText ( getString ( R . string . policy_loading_error ) );
166
- }
167
- loadingFinished ( );
160
+ FragmentActivity a = getActivity ();
161
+ if ( a == null ) return ;
162
+
163
+ a . runOnUiThread (() -> {
164
+ if ( url != null ) {
165
+ html = getString ( R . string . parse_error , Html . escapeHtml ( url ));
166
+ displayHtml ( html );
167
+ } else {
168
+ txtPolicy . setText ( getString ( R . string . policy_loading_error ) );
168
169
}
170
+ loadingFinished ();
169
171
});
170
172
}
171
173
@@ -201,11 +203,11 @@ public void run () {
201
203
html = "<h1>" + Html .escapeHtml (title ) + "</h1>" + content ;
202
204
203
205
// Display in UI
204
- getActivity (). runOnUiThread ( new Runnable () {
205
- public void run () {
206
- displayHtml ( html );
207
- loadingFinished ( );
208
- }
206
+ FragmentActivity a = getActivity ();
207
+ if ( a == null ) return ;
208
+ a . runOnUiThread (() -> {
209
+ displayHtml ( html );
210
+ loadingFinished ();
209
211
});
210
212
}
211
213
}
0 commit comments