Skip to content

Commit 07d7a98

Browse files
committed
Ran some standard Androidstudio checks and resolved some warning
1 parent f133b00 commit 07d7a98

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

src/main/java/io/yippie/iupb/app/MainActivity.java

+8-20
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import android.content.res.*;
66
import android.net.*;
77
import android.os.*;
8-
import android.support.v4.app.FragmentTransaction;
8+
import android.support.v4.app.*;
99
import android.util.*;
1010
import android.view.*;
1111
import android.webkit.*;
1212
import android.widget.*;
1313

1414
import com.actionbarsherlock.app.*;
15-
import com.actionbarsherlock.app.ActionBar;
1615
import com.actionbarsherlock.app.ActionBar.*;
1716
import com.actionbarsherlock.view.Menu;
1817
import com.actionbarsherlock.view.MenuItem;
@@ -29,13 +28,13 @@
2928
* TODO doc
3029
*/
3130
@EActivity(R.layout.activity_main)
32-
@SuppressLint("SetJavaScriptEnabled")
31+
@SuppressLint({"Registered"})
3332
public class MainActivity extends SherlockActivity implements
3433
TabListener, OnNavigationListener, IUpbWebViewCallback {
3534

3635
private static final String ASSETS_LOADING_HTML = "file:///android_asset/loading.html";
3736
private static final String ASSETS_OFFLINE_HTML = "file:///android_asset/offline.html";
38-
public final static int FILECHOOSER_REQUEST_CODE = 1;
37+
public final static int FILE_CHOOSER_REQUEST_CODE = 1;
3938
private final String TAG = getClass().getSimpleName();
4039

4140
/**
@@ -78,10 +77,12 @@ public void onCreate(Bundle savedInstanceState) {
7877
void afterViews() {
7978
mCurrentUrl = generateURL(getString(R.string.actionbar_restaurants_url));
8079
mMainWebView.setCallback(this);
81-
// ASSETS_LOADING_HTML is loaded to show that something's happening
80+
// ASSETS_LOADING_HTML is loaded to show that something is happening
8281
mMainWebView.loadUrl(ASSETS_LOADING_HTML);
8382
mMainWebView.loadUrl(mCurrentUrl);
8483

84+
setSupportProgressBarVisibility(true);
85+
setSupportProgressBarIndeterminateVisibility(true);
8586
initActionBar();
8687
initNavigation();
8788
}
@@ -91,8 +92,6 @@ private void initActionBar() {
9192
actionBar.setHomeButtonEnabled(true);
9293
actionBar.setDisplayShowHomeEnabled(true);
9394
actionBar.setDisplayShowTitleEnabled(false);
94-
setSupportProgressBarVisibility(true);
95-
setSupportProgressBarIndeterminateVisibility(true);
9695
}
9796

9897
private void initNavigation() {
@@ -122,7 +121,7 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
122121
@Override
123122
protected void onActivityResult(int requestCode, int resultCode,
124123
Intent intent) {
125-
if (requestCode == FILECHOOSER_REQUEST_CODE) {
124+
if (requestCode == FILE_CHOOSER_REQUEST_CODE) {
126125
if (null == mUploadMessage)
127126
return;
128127
Uri result = intent == null || resultCode != RESULT_OK ? null
@@ -148,17 +147,6 @@ public void onConfigurationChanged(Configuration newConfig) {
148147
invalidateOptionsMenu();
149148
}
150149

151-
protected synchronized void removeOfflineNotice() {
152-
if (offlineMode) {
153-
offlineMode = false;
154-
if (mMainWebView.canGoBack())
155-
mMainWebView.goBack();
156-
else
157-
loadWebView(generateURL(getString(R.string.actionbar_restaurants_url)));
158-
mMainWebView.clearHistory();
159-
}
160-
}
161-
162150
@Override
163151
public synchronized void displayOfflineNotice() {
164152
if (!offlineMode) {
@@ -214,7 +202,7 @@ private void loadHomeScreen() {
214202
}
215203

216204
/**
217-
* loads a specific view for the current webview
205+
* loads a specific view for the current web view
218206
*/
219207
private void loadWebView(String url) {
220208
mCurrentUrl = url;

src/main/java/io/yippie/iupb/app/webview/IUpbWebChromeClient.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/**
1414
* TODO doc
15+
* TODO why are there methods like openFileChooser? they are not used
1516
*/
1617
@EBean
1718
public class IUpbWebChromeClient extends WebChromeClient {
@@ -34,7 +35,7 @@ public void onProgressChanged(WebView view, int progress) {
3435
}
3536

3637
// For Android 3.0 - 4.0 (enables file upload)
37-
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
38+
void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
3839
Log.i(TAG, "Upload started");
3940
triggerUploadIntent(uploadMsg);
4041
}
@@ -45,7 +46,7 @@ private void triggerUploadIntent(
4546
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
4647
i.addCategory(Intent.CATEGORY_OPENABLE);
4748
i.setType("image/*");
48-
mActivity.startActivityForResult(Intent.createChooser(i, "Image Browser"), MainActivity.FILECHOOSER_REQUEST_CODE);
49+
mActivity.startActivityForResult(Intent.createChooser(i, "Image Browser"), MainActivity.FILE_CHOOSER_REQUEST_CODE);
4950
}
5051

5152
// For Android 4.1+ (enables file upload)
@@ -59,7 +60,7 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg) {
5960
openFileChooser(uploadMsg, "");
6061
}
6162

62-
public static final IUpbWebChromeClientCallback sDUMMY_CALLBACK = new IUpbWebChromeClientCallback() {
63+
private static final IUpbWebChromeClientCallback sDUMMY_CALLBACK = new IUpbWebChromeClientCallback() {
6364
@Override
6465
public void setProgressValue(int progress) {
6566
// dummy

src/main/java/io/yippie/iupb/app/webview/IUpbWebView.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.yippie.iupb.app.webview;
22

3+
import android.annotation.*;
34
import android.content.*;
45
import android.net.*;
56
import android.util.*;
@@ -16,12 +17,13 @@ public class IUpbWebView extends WebView implements IUpbWebChromeClientCallback,
1617
IUpbWebViewClient webViewClient;
1718
@Bean
1819
IUpbWebChromeClient webChromeClient;
19-
IUpbWebViewCallback mCallback = sDUMMY_CALLBACK;
20+
private IUpbWebViewCallback mCallback = sDUMMY_CALLBACK;
2021

2122
public IUpbWebView(Context context, AttributeSet attrs) {
2223
super(context, attrs);
2324
}
2425

26+
@SuppressLint("SetJavaScriptEnabled")
2527
@AfterInject
2628
void init() {
2729
webViewClient.setIUpbWebClientCallback(this);
@@ -57,7 +59,7 @@ public void setCallback(IUpbWebViewCallback callback) {
5759
this.mCallback = callback;
5860
}
5961

60-
public static final IUpbWebViewCallback sDUMMY_CALLBACK = new IUpbWebViewCallback() {
62+
private static final IUpbWebViewCallback sDUMMY_CALLBACK = new IUpbWebViewCallback() {
6163
@Override
6264
public void setProgressValue(int progress) {
6365
// dummy

src/main/java/io/yippie/iupb/app/webview/IUpbWebViewClient.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import io.yippie.iupb.app.*;
1111

1212
/**
13-
* TODO doc
14-
*/
13+
* TODO doc
14+
*/
1515
@EBean
1616
public class IUpbWebViewClient extends WebViewClient {
1717
@RootContext
@@ -54,7 +54,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
5454
}
5555
}
5656

57-
public static final IUpbWebClientCallback sDUMMY_CALLBACK = new IUpbWebClientCallback() {
57+
private static final IUpbWebClientCallback sDUMMY_CALLBACK = new IUpbWebClientCallback() {
5858
@Override
5959
public void displayOfflineNotice() {
6060
// dummy

0 commit comments

Comments
 (0)