Skip to content

Commit

Permalink
fixed codacy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Mar 27, 2017
1 parent 35b8800 commit 6599367
Show file tree
Hide file tree
Showing 28 changed files with 103 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private void saveSettings(Context context) {
}

public boolean isGeoPick() {
return mStatSuffix == PICK_GEO_SUFFIX;
return (mStatSuffix != null) && mStatSuffix.equals(PICK_GEO_SUFFIX);
}

// load from settings/instanceState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,12 @@ public void onClick(View v) {
}

protected void showVisibility(int visibility) {
if (visibility == VISIBILITY_DEFAULT) {
visibility = (FotoLibGlobal.visibilityShowPrivateByDefault) ? VISIBILITY_PRIVATE_PUBLIC : VISIBILITY_PUBLIC;
int actualVisibility = visibility;
if (actualVisibility == VISIBILITY_DEFAULT) {
actualVisibility = (FotoLibGlobal.visibilityShowPrivateByDefault) ? VISIBILITY_PRIVATE_PUBLIC : VISIBILITY_PUBLIC;
}

switch (visibility) {
switch (actualVisibility) {
case VISIBILITY_PRIVATE:
mPrivate.setChecked(true);
mPublic.setChecked(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2015-2016 by k3b.
* Copyright (c) 2015-2017 by k3b.
*
* This file is part of AndroFotoFinder.
* This file is part of AndroFotoFinder / #APhotoManager.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -189,6 +189,8 @@ public static Spanned getDirectoryDisplayText(String prefix, IDirectory director
formatSuffix = "</b>";
}
break;
default:
throw new IllegalStateException();
}

if (prefix != null) result.append(prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,6 @@ private void zoomToBoundingBox(String why, BoundingBox boundingBox, int zoomLeve
/** all marker clicks will be delegated to LocationMapFragment#onFotoMarkerClicked() */
private class FotoMarker extends ClickableIconOverlay<Object> {

public FotoMarker() {
super();
}

/**
* @return true if click was handeled.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ protected void onActivityResult(final int requestCode,
mBookmarkController.loadState(intent, null);
onFilterChanged(GalleryFilterActivity.getFilter(intent));
break;
default:
throw new IllegalStateException();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ protected void definteOverlays(MapView mapView) {
}

/** get all important parameters for displaying the map */
public void defineNavigation(GalleryFilterParameter rootFilter, IGeoPointInfo currentSelection,
public void defineNavigation(GalleryFilterParameter rootFilter, IGeoPointInfo selectedItem,
GeoRectangle rectangle, int zoomlevel,
SelectedItems selectedItems, Uri additionalPointsContentUri) {
IGeoPointInfo currentSelection = selectedItem;
if ((currentSelection == null) && (getCurrentSelectionPosition() == null)) {
// first call with no geo: take last use from config
// save as value if picker is called again with no geo-coordinate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private class TaskLoadMediaDB extends AsyncTask<Uri,String,String> {
private int mItemCount = 0;
private int mUpdateCount = 0;
private int mProgressCountDown = 0;
MediaCsvLoader mLoader = null;
protected MediaCsvLoader mLoader = null;

/**
* Override this method to perform a computation on a background thread. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION_1_TransactionLog = 1;

public static final int DATABASE_VERSION = DatabaseHelper.DATABASE_VERSION_1_TransactionLog;
private final Context createContext;

public DatabaseHelper(final Context context, final String databaseName) {
super(context, databaseName, null, DatabaseHelper.DATABASE_VERSION);
this.createContext = context;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,8 @@ public static String[] getFileNames(Context context, SelectedItems items) {

}

protected static String getFilterExpressionVisibility(int visibility) {
protected static String getFilterExpressionVisibility(int _visibility) {
int visibility = _visibility;
// add visibility column only if not included yet
if (visibility == IGalleryFilter.VISIBILITY_DEFAULT) {
visibility = (FotoLibGlobal.visibilityShowPrivateByDefault)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,13 @@ public void includeTagParents(List<String> addNames, List<String> removeNames) {
while (tag != null) {
String tagName = tag.getName();

if (addNames != null) {
if (!addNames.contains(tagName)) {
addNames.add(tagName);
modifyCount++;
}
if ((addNames != null) && (!addNames.contains(tagName))) {
addNames.add(tagName);
modifyCount++;
}
if (removeNames != null) {
if (removeNames.contains(tagName)) {
removeNames.remove(tagName);
modifyCount++;
}
if ((removeNames != null) && removeNames.contains(tagName)) {
removeNames.remove(tagName);
modifyCount++;
}
tag = tag.getParent();
}
Expand All @@ -136,8 +132,9 @@ public void reloadList() {
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
public View getView(int position, View _convertView, ViewGroup parent) {
final Holder holder;
View convertView = _convertView;
// Check if an existing view is being reused, otherwise inflate the view
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_tag_search, parent, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,18 +758,21 @@ private boolean onPaste(Tag currentMenuSelection) {
private final Handler delayProcessor = new Handler() {
@Override
public void handleMessage(final Message msg) {
TagsPickerFragment.this.clearDelayProcessor();
switch (msg.what) {
case TagsPickerFragment.HANDLER_FILTER_TEXT_CHANGED:
TagsPickerFragment.this.refershResultList();
TagsPickerFragment.this.sendDelayed(
TagsPickerFragment.HANDLER_FILTER_COUNT_UPDATE,
TagsPickerFragment.HANDLER_FILTER_COUNT_DELAY);
break;
case TagsPickerFragment.HANDLER_FILTER_COUNT_UPDATE:
TagsPickerFragment.this.refreshCounter();
break;
}
TagsPickerFragment.this.clearDelayProcessor();
switch (msg.what) {
case TagsPickerFragment.HANDLER_FILTER_TEXT_CHANGED:
TagsPickerFragment.this.refershResultList();
TagsPickerFragment.this.sendDelayed(
TagsPickerFragment.HANDLER_FILTER_COUNT_UPDATE,
TagsPickerFragment.HANDLER_FILTER_COUNT_DELAY);
break;
case TagsPickerFragment.HANDLER_FILTER_COUNT_UPDATE:
TagsPickerFragment.this.refreshCounter();
break;
default:
// not implemented
throw new IllegalStateException();
}
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ public class TransactionLogSql {
+ COL_commandData + " TEXT"
+ ")";

public static ContentValues set(ContentValues values, long currentMediaID, String fileFullPath,
public static ContentValues set(ContentValues valuesOrNull, long currentMediaID, String fileFullPath,
long modificationDate,
MediaTransactionLogEntryType mediaTransactionLogEntryType,
String commandData) {
ContentValues values = valuesOrNull;
if (values == null) {
values = new ContentValues();
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/de/k3b/android/util/IterableCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
inspired by http://stackoverflow.com/questions/10723770/whats-the-best-way-to-iterate-an-android-cursor/28765773#28765773
*/
public class IterableCursor<T extends Cursor> implements Iterable<T>, Iterator<T> {
T cursor;
int toVisit;
protected T cursor;
protected int toVisit;
public IterableCursor(T cursor) {
this.cursor = cursor;
toVisit = cursor.getCount();
Expand Down
8 changes: 4 additions & 4 deletions fotolib2/src/main/java/de/k3b/csv2db/csv/CsvItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2015 by k3b.
* Copyright (c) 2015-2017 by k3b.
*
* This file is part of AndroFotoFinder.
* This file is part of AndroFotoFinder / #APhotoManager
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -136,15 +136,15 @@ public String toString() {
}

/** places quote around fieldValue if necessary */
String quouteIfNecessary(String fieldValue) {
protected String quouteIfNecessary(String fieldValue) {
if (mustQuote(fieldValue)) {
return CHAR_FIELD_SURROUNDER + fieldValue.replace(""+CHAR_FIELD_SURROUNDER, "'") + CHAR_FIELD_SURROUNDER;
}
return fieldValue;
}

/** return true if contentmust be quoted because it contains problematic chars */
boolean mustQuote(String fieldValue) {
protected boolean mustQuote(String fieldValue) {
if (fieldValue == null) return false;
for (char forbidden : mCsvSpecialChars.toCharArray()) {
if (fieldValue.indexOf(forbidden) >= 0) return true;
Expand Down
10 changes: 4 additions & 6 deletions fotolib2/src/main/java/de/k3b/csv2db/csv/CsvReader.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2015-2016 by k3b.
* Copyright (c) 2015-2017 by k3b.
*
* This file is part of AndroFotoFinder.
* This file is part of AndroFotoFinder / #APhotoManager.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -67,11 +67,9 @@ public String[] readLine() {
if (ch== CsvItem.DEFAULT_CHAR_LINE_DELIMITER) this.lineNumber++;

if (this.fieldSurrounder == 0) {
if (fieldDelimiter == 0)
{
if ((fieldDelimiter == 0) && POSSIBLE_DELIMITER_CHARS.indexOf(ch) >= 0) {
// fieldDelimiter unknown: infer
if (POSSIBLE_DELIMITER_CHARS.indexOf(ch) >= 0)
fieldDelimiter = (char) ch;
fieldDelimiter = (char) ch;
}
if (ch == fieldDelimiter) {
result.addElement(getStringWithoutDelimiters(content));
Expand Down
2 changes: 1 addition & 1 deletion fotolib2/src/main/java/de/k3b/database/QueryParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public String[] getWhereParameter(String sqlExprWithParameters, boolean remove)
return getExpresionParameter(sqlExprWithParameters, mWhere, mParameters, remove);
}

static String[] getExpresionParameter(String sqlExprWithParameters, List<String> expressions, List<String> parameters, boolean remove) {
protected static String[] getExpresionParameter(String sqlExprWithParameters, List<String> expressions, List<String> parameters, boolean remove) {
if ((sqlExprWithParameters != null) && (expressions != null) && (parameters != null)) {
int paramNo = 0;
for (String p : expressions) {
Expand Down
7 changes: 4 additions & 3 deletions fotolib2/src/main/java/de/k3b/database/SelectedItems.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2015 by k3b.
* Copyright (c) 2015-2017 by k3b.
*
* This file is part of AndroFotoFinder.
* This file is part of AndroFotoFinder / #APhotoManager
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -47,9 +47,10 @@ public static <T> String toString(Iterator<T> iter) {
}

public static <T> String toString(Iterator<T> iter, int intMaxCount) {
int i = intMaxCount;
StringBuilder result = new StringBuilder();
boolean mustAddDelimiter = false;
while(iter.hasNext() && (--intMaxCount >= 0)) {
while(iter.hasNext() && (--i >= 0)) {
if (mustAddDelimiter) {
result.append(DELIMITER);
}
Expand Down
6 changes: 3 additions & 3 deletions fotolib2/src/main/java/de/k3b/io/Directory.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2015 by k3b.
* Copyright (c) 2015-2017 by k3b.
*
* This file is part of AndroFotoFinder.
* This file is part of AndroFotoFinder / #APhotoManager
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -125,7 +125,7 @@ public String getAbsolute() {
return result.toString();
}

static StringBuilder toTreeString(StringBuilder result, Directory item, String delimiter, int options) {
protected static StringBuilder toTreeString(StringBuilder result, Directory item, String delimiter, int options) {
if (item != null) {
result.append(item.getRelPath());
appendCount(result, item, options);
Expand Down
8 changes: 4 additions & 4 deletions fotolib2/src/main/java/de/k3b/io/DirectoryNavigator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2015 by k3b.
* Copyright (c) 2015-2017 by k3b.
*
* This file is part of AndroFotoFinder.
* This file is part of AndroFotoFinder / #APhotoManager
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -99,8 +99,8 @@ public void navigateTo(IDirectory newSelection) {
setCurrentSelection(newSelection);
}

/** package to allow unit testing: calclulate Grandparent for navigateTo */
IDirectory getNavigationGrandparent(IDirectory newSelection) {
/** protected to allow unit testing: calclulate Grandparent for navigateTo */
protected IDirectory getNavigationGrandparent(IDirectory newSelection) {
if (newSelection != null) {
IDirectory parent = newSelection.getParent();
if (parent != null) {
Expand Down
15 changes: 7 additions & 8 deletions fotolib2/src/main/java/de/k3b/io/FileCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,13 @@ protected boolean osFileMove(File dest, File source) {
// #61 cannot move between different mountpoints/devices/partitions. do Copy+Delete instead
if (source.exists() && source.isFile() && source.canRead()
&& source.canWrite() // to delete after success
&& !dest.exists()) {
if (osFileCopy(dest, source)) {
if (osDeleteFile(source)) {
return true; // move: copy + delete(source) : success
} else {
// cannot delete souce: undo copy
osDeleteFile(dest);
}
&& !dest.exists()
&& osFileCopy(dest, source)) {
if (osDeleteFile(source)) {
return true; // move: copy + delete(source) : success
} else {
// cannot delete souce: undo copy
osDeleteFile(dest);
}
}
return false;
Expand Down
5 changes: 1 addition & 4 deletions fotolib2/src/main/java/de/k3b/io/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ public static boolean isNoMedia(String path, int maxLevel) {

// linux convention: folder names starting with "." are hidden
public static boolean isHiddenFolder(String path) {
if (path.indexOf("/.") >= 0) {
return true;
}
return false;
return (path.indexOf("/.") >= 0);
}

}
Loading

0 comments on commit 6599367

Please sign in to comment.