Skip to content

Commit

Permalink
Handle lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ispedals committed Sep 11, 2017
1 parent a5791ff commit ce8581e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion floatingJapaneseDictionary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
applicationId "pedals.is.floatingjapanesedictionary"
minSdkVersion 11
minSdkVersion 14
targetSdkVersion 21

testApplicationId "pedals.is.floatingjapanesedictionary.test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class FloatingJapaneseDictionaryLauncherActivity extends Activity {

private static final String TAG = "FloatingJapaneseDictionaryLauncherActivity";
private static final String TAG = "FJDLauncherActivity";

@Override
protected void onStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public class FloatingJapaneseDictionaryService extends StandOutWindow {

private static final String APP_NAME = "Floating Japanese Dictionary";
private static final int APP_ICON = android.R.drawable.ic_menu_add;
private static File saveLocation = new File(
private static final File saveLocation = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
"Words.txt");

private static final String TAG = "FloatingJapaneseDictionaryService";
private static final String TAG = "FJDService";

private static final int CLOSED = 0, OPENED = 1;

Expand Down Expand Up @@ -168,7 +168,7 @@ public void onClick(final View searchView) {
}
});

adapter = new ArrayAdapter<DictionaryEntry>(this,
adapter = new ArrayAdapter<>(this,
R.layout.dictionaryentry, entries);
ListView listView = (ListView) view.findViewById(R.id.results);
listView.setAdapter(adapter);
Expand All @@ -183,7 +183,7 @@ public void onItemClick(AdapterView<?> parent, View view,
Log.d(TAG, "item clicked " + entry.toString());
try {
FileWriter filewriter = new FileWriter(saveLocation, true);
filewriter.append("\r\n" + entry.toString());
filewriter.append("\r\n").append(entry.toString());
filewriter.close();
Log.d(TAG,
"item saved to " + saveLocation.getAbsolutePath());
Expand Down Expand Up @@ -221,10 +221,10 @@ private void synchronizePositions(int id, StandOutLayoutParams... params) {
StandOutLayoutParams currentParam = getParams(id);
Log.d(TAG, "Synchronizing position: x, y " + currentParam.x + " "
+ currentParam.y);
for (int i = 0; i < params.length; i++) {
if (params[i] != null) {
params[i].x = currentParam.x;
params[i].y = currentParam.y;
for (StandOutLayoutParams param : params) {
if (param != null) {
param.x = currentParam.x;
param.y = currentParam.y;
}
}
}
Expand Down Expand Up @@ -345,7 +345,7 @@ private void displaySearch(Window window, String text) {
@Override
public List<DropDownListItem> getDropDownItems(int id) {

List<DropDownListItem> items = new ArrayList<DropDownListItem>();
List<DropDownListItem> items = new ArrayList<>();
items.add(new DropDownListItem(0, "About", new Runnable() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

public class DeInflector {

private static final ArrayList<String> reasons = new ArrayList<String>();
private static final ArrayList<DeInflectorRuleGroup> rules = new ArrayList<DeInflectorRuleGroup>();
private static final ArrayList<String> reasons = new ArrayList<>();
private static final ArrayList<DeInflectorRuleGroup> rules = new ArrayList<>();

static {
reasons.add("polite past negative");
Expand Down Expand Up @@ -199,10 +199,10 @@ public class DeInflector {
public static ArrayList<DeinflectorTerm> deInflect(
final String inflectedWord) {

final HashMap<String, Integer> have = new HashMap<String, Integer>();
final HashMap<String, Integer> have = new HashMap<>();
have.put(inflectedWord, 0);

final ArrayList<DeinflectorTerm> r = new ArrayList<DeinflectorTerm>();
final ArrayList<DeinflectorTerm> r = new ArrayList<>();
r.add(new DeinflectorTerm(inflectedWord, 0xFF, ""));

int i = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static DictionaryEntries fromParcelable(

public ArrayList<ContentValues> toParcelableContentValues() {

ArrayList<ContentValues> ret = new ArrayList<ContentValues>();
ArrayList<ContentValues> ret = new ArrayList<>();
for (DictionaryEntry entry : this) {
ContentValues value = entry.toContentValues();
ret.add(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@

public class DictionarySearcher {

@SuppressWarnings("unused")

private static final int USING_LOCAL = 1, USING_EXTERNAL = 2,
USING_BUILT_IN = 3;
public static final int DICTIONARY_TYPE = USING_LOCAL;
private static final int DICTIONARY_TYPE = USING_LOCAL;
public static final String DICTIONARY_NAME = "dict.sqlite";

// TABLE dict (kanji TEXT, kana TEXT, entry TEXT)

@SuppressWarnings("unused")
private static SQLiteDatabase getDatabase(Context context) {

if (DICTIONARY_TYPE == USING_EXTERNAL) {
Expand All @@ -83,13 +82,16 @@ else if (DICTIONARY_TYPE == USING_LOCAL) {
return SQLiteDatabase.openDatabase(dictionaryPath, null,
SQLiteDatabase.OPEN_READONLY);
}
else {
else if (DICTIONARY_TYPE == USING_BUILT_IN){
DictionaryOpenHelper dictOpener = new DictionaryOpenHelper(context);
return dictOpener.getReadableDatabase();
}
else {
throw new IllegalStateException(
"Unhandled Dictionary Type");
}
}

@SuppressWarnings("unused")
public static boolean dictionaryExists(Context context) {

File dictionaryFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ else if (message.obj.equals("reset")) {
deleteFiles();
RUNNING = false;
stopSelf(message.arg1);
return;
}
else if (message.obj.equals("download")) {
// no pending download
Expand All @@ -87,13 +86,13 @@ else if (message.obj.equals("download")) {
private Looper looper;
private ServiceHandler handler;

public static String DOWNLOAD_URL = "https://addons.mozilla.org/firefox/downloads/latest/398350/addon-398350-latest.xpi?src=ss";
private static String DOWNLOAD_URL = "https://addons.mozilla.org/firefox/downloads/latest/398350/addon-398350-latest.xpi?src=ss";
private static final String DOWNLOAD_FILE_NAME = "dict.xpi";

private static long enqueuedID = -1;

public static boolean RUNNING = false;
private static final String TAG = "DictionaryManagerService";
private static final String TAG = "FJDManagerService";

// callback for when download is complete
// it handles extracting the sqlite database out of the xpi file
Expand Down Expand Up @@ -228,7 +227,11 @@ private void downloadDictionary() {

private void deleteFiles() {

for (File file : this.getExternalFilesDir(null).listFiles()) {
File[] files = this.getExternalFilesDir(null).listFiles();
if(files == null){
return;
}
for (File file : files) {
Log.d(TAG, "Deleting file: " + file.getAbsolutePath());
file.delete();
}
Expand All @@ -238,7 +241,7 @@ private void deleteFiles() {
private File extractFile(Uri uri, String desiredFile) {

Log.d(TAG, "Trying to extract " + desiredFile);
File unzippedFile = null;
File unzippedFile;
try {
File zippedFile = new File(uri.getPath());
ZipFile zipFile = new ZipFile(zippedFile, ZipFile.OPEN_READ);
Expand Down

0 comments on commit ce8581e

Please sign in to comment.