Skip to content

Commit

Permalink
Fix some code inspection warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdoeffinger committed Aug 20, 2018
1 parent a016216 commit 3ce0dd1
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Util
2 changes: 1 addition & 1 deletion src/com/hughes/android/dictionary/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void onCreate(final Bundle savedInstanceState) {
PackageInfo p = pm.getPackageInfo(getPackageName(), 0);
ver = p.versionName + " (ID " + p.versionCode + ")";
}
} catch (Exception e) {
} catch (Exception ignored) {
}
TextView titleView = findViewById(R.id.titleText);
titleView.setText("QuickDic " + ver);
Expand Down
4 changes: 2 additions & 2 deletions src/com/hughes/android/dictionary/DictionaryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ public boolean onKeyDown(final int keyCode, final KeyEvent event) {
Log.d(LOG, "Trying to hide soft keyboard.");
final InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
View focus = getCurrentFocus();
if (focus != null) {
if (inputManager != null && focus != null) {
inputManager.hideSoftInputFromWindow(focus.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
Expand Down Expand Up @@ -1501,7 +1501,7 @@ private void getMetrics() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
scale = dm.density;
} catch (NullPointerException e)
} catch (NullPointerException ignored)
{}
// Convert the dps to pixels, based on density scale
mPaddingDefault = (int) (PADDING_DEFAULT_DP * scale + 0.5f);
Expand Down
6 changes: 3 additions & 3 deletions src/com/hughes/android/dictionary/DictionaryApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static synchronized void staticInit(final Context context) {
}
try {
reader.close();
} catch (IOException e) {}
} catch (IOException ignored) {}
}

public synchronized void init(Context c) {
Expand Down Expand Up @@ -256,7 +256,7 @@ private String selectDefaultDir() {
File efd = null;
try {
efd = appContext.getExternalFilesDir(null);
} catch (Exception e) {
} catch (Exception ignored) {
}
if (efd != null) {
efd.mkdirs();
Expand Down Expand Up @@ -295,7 +295,7 @@ static public boolean checkFileCreate(File dir) {
try {
testfile.delete();
res = testfile.createNewFile() & testfile.delete();
} catch (Exception e) {
} catch (Exception ignored) {
}
return res;
}
Expand Down
19 changes: 14 additions & 5 deletions src/com/hughes/android/dictionary/DictionaryManagerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private boolean unzipInstall(Context context, Uri zipUri, String dest, boolean d
}
}
zipFile = new ZipInputStream(new BufferedInputStream(zipFileStream));
ZipEntry zipEntry = null;
ZipEntry zipEntry;
while ((zipEntry = zipFile.getNextEntry()) != null) {
// Note: this check prevents security issues like accidental path
// traversal, which unfortunately ZipInputStream has no protection against.
Expand Down Expand Up @@ -258,14 +258,15 @@ private boolean unzipInstall(Context context, Uri zipUri, String dest, boolean d
} finally {
try {
if (zipOut != null) zipOut.close();
} catch (IOException e) {}
} catch (IOException ignored) {}
try {
if (zipFile != null) zipFile.close();
} catch (IOException e) {}
} catch (IOException ignored) {}
try {
if (zipFileStream != null) zipFileStream.close();
} catch (IOException e) {}
if (localZipFile != null && delete) localZipFile.delete();
} catch (IOException ignored) {}
if (localZipFile != null && delete) //noinspection ResultOfMethodCallIgnored
localZipFile.delete();
}
return result;
}
Expand Down Expand Up @@ -839,6 +840,14 @@ private synchronized void downloadDictionary(final String downloadUrl, long byte

DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);

if (downloadManager == null) {
String msg = getString(R.string.downloadManagerQueryFailed);
new AlertDialog.Builder(DictionaryManagerActivity.this).setTitle(getString(R.string.error))
.setMessage(getString(R.string.downloadFailed, msg))
.setNeutralButton("Close", null).show();
return;
}

try {
downloadManager.enqueue(request);
} catch (SecurityException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/hughes/android/dictionary/HtmlDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onCreate(final Bundle savedInstanceState) {
html = StringUtil.readToString(res);
try {
res.close();
} catch (IOException e) {
} catch (IOException ignored) {
}
} else {
html = getIntent().getStringExtra(HTML);
Expand Down
2 changes: 1 addition & 1 deletion src/com/hughes/android/dictionary/PreferenceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void onSharedPreferenceChanged(SharedPreferences p, String v) {
File efd = null;
try {
efd = getApplicationContext().getExternalFilesDir(null);
} catch (Exception e) {
} catch (Exception ignored) {
}
if (efd != null) {
String externalFilesDir = efd.getAbsolutePath();
Expand Down
4 changes: 3 additions & 1 deletion src/com/hughes/android/dictionary/engine/HtmlEntry.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

package com.hughes.android.dictionary.engine;

import android.support.annotation.NonNull;

import com.hughes.util.StringUtil;
import com.hughes.util.raf.RAFListSerializer;
import com.hughes.util.raf.RAFListSerializerSkippable;
Expand Down Expand Up @@ -137,7 +139,7 @@ private String getRawText(final boolean compact) {
}

@Override
public int compareTo(HtmlEntry another) {
public int compareTo(@NonNull HtmlEntry another) {
if (title.compareTo(another.title) != 0) {
return title.compareTo(another.title);
}
Expand Down
4 changes: 3 additions & 1 deletion src/com/hughes/android/dictionary/engine/PairEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.hughes.android.dictionary.engine;

import android.support.annotation.NonNull;

import com.hughes.util.StringUtil;
import com.hughes.util.raf.RAFListSerializerSkippable;
import com.hughes.util.raf.RAFSerializable;
Expand Down Expand Up @@ -219,7 +221,7 @@ private String getRawText(final boolean compact) {
}

@Override
public int compareTo(final PairEntry that) {
public int compareTo(@NonNull final PairEntry that) {
return this.getRawText(false).compareTo(that.getRawText(false));
}

Expand Down
4 changes: 2 additions & 2 deletions src/com/hughes/android/util/PersistentObjectCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public synchronized <T extends Serializable> T read(final String filename, final
Log.e(getClass().getSimpleName(), "Deserialization failed: " + src, e);
try {
if (in != null) in.close();
} catch (IOException e2) {}
} catch (IOException ignored) {}
return null;
}
objects.put(filename, object);
Expand All @@ -108,7 +108,7 @@ public synchronized void write(final String filename, final Serializable object)
}
try {
if (out != null) out.close();
} catch (IOException e) {}
} catch (IOException ignored) {}
}

private PersistentObjectCache(final Context context) {
Expand Down

0 comments on commit 3ce0dd1

Please sign in to comment.