Apply inspections

pull/281/head
Alex Baker 10 years ago
parent 29b901c81b
commit 6acef7a37b

@ -160,7 +160,7 @@ public class TitleParserTest extends DatabaseTestCase {
// ----------------Days begin----------------//
public void disabled_testDays() throws Exception{
public void disabled_testDays() {
Calendar today = Calendar.getInstance();
Task task = new Task();

@ -4,6 +4,7 @@ import android.support.v4.app.FragmentManager;
import org.tasks.location.OnLocationPickedHandler;
@SuppressWarnings("EmptyMethod")
public class LocationPickerDialog {
public LocationPickerDialog(OnLocationPickedHandler onLocationPickedHandler) {

@ -4,6 +4,7 @@ import java.util.List;
import javax.inject.Inject;
@SuppressWarnings("EmptyMethod")
public class GeofenceApi {
@Inject

@ -432,8 +432,8 @@ public class TouchListView extends ListView {
}
public interface GrabberClickListener {
public void onClick(View v);
public void onLongClick(View v);
void onClick(View v);
void onLongClick(View v);
}
public interface DropListener {

@ -32,10 +32,8 @@ public class DatabaseDao<TYPE extends AbstractModel> {
private static final Logger log = LoggerFactory.getLogger(DatabaseDao.class);
private final Class<TYPE> modelClass;
private Table table;
private Database database;
private final Table table;
private final Database database;
public DatabaseDao(Database database, Class<TYPE> modelClass) {
this.modelClass = modelClass;
@ -56,7 +54,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
// --- listeners
public interface ModelUpdateListener<MTYPE> {
public void onModelUpdated(MTYPE model);
void onModelUpdated(MTYPE model);
}
private final ArrayList<ModelUpdateListener<TYPE>> listeners = new ArrayList<>();
@ -214,7 +212,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
}
private interface DatabaseChangeOp {
public boolean makeChange();
boolean makeChange();
}
private boolean insertOrUpdateAndRecordChanges(TYPE item, DatabaseChangeOp op) {

@ -124,13 +124,13 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
*
*/
public interface PropertyVisitor<RETURN, PARAMETER> {
public RETURN visitInteger(Property<Integer> property, PARAMETER data);
RETURN visitInteger(Property<Integer> property, PARAMETER data);
public RETURN visitLong(Property<Long> property, PARAMETER data);
RETURN visitLong(Property<Long> property, PARAMETER data);
public RETURN visitDouble(Property<Double> property, PARAMETER data);
RETURN visitDouble(Property<Double> property, PARAMETER data);
public RETURN visitString(Property<String> property, PARAMETER data);
RETURN visitString(Property<String> property, PARAMETER data);
}
// --- children

@ -241,7 +241,7 @@ public class AndroidUtilities {
}
public interface SerializedPut<T> {
public void put(T object, String key, char type, String value) throws NumberFormatException;
void put(T object, String key, char type, String value) throws NumberFormatException;
}
private static <T> void fromSerialized(String string, T object, SerializedPut<T> putter) {
@ -294,19 +294,6 @@ public class AndroidUtilities {
return result;
}
/**
* Returns true if a and b or null or a.equals(b)
*/
public static boolean equals(Object a, Object b) {
if(a == null && b == null) {
return true;
}
if(a == null) {
return false;
}
return a.equals(b);
}
/**
* Copy a file from one place to another
* @throws Exception

@ -47,7 +47,7 @@ import javax.inject.Inject;
* @author Arne
*
*/
public class AstridActivity extends InjectingAppCompatActivity
public abstract class AstridActivity extends InjectingAppCompatActivity
implements NavigationDrawerFragment.OnFilterItemClickedListener,
TaskListFragment.OnTaskListItemClickedListener {

@ -426,8 +426,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
Class<?> openControl = (Class<?>) getActivity().getIntent().getSerializableExtra(TOKEN_OPEN_CONTROL);
for (int i = 0; i < itemOrder.length; i++) {
String item = itemOrder[i];
for (String item : itemOrder) {
if (item.equals(hideAlwaysTrigger)) {
break; // As soon as we hit the hide section, we're done
} else {

@ -195,10 +195,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
TaskListFragment newFragment;
try {
newFragment = (TaskListFragment) component.newInstance();
} catch (java.lang.InstantiationException e) {
log.error(e.getMessage(), e);
newFragment = new TaskListFragment();
} catch (IllegalAccessException e) {
} catch (java.lang.InstantiationException | IllegalAccessException e) {
log.error(e.getMessage(), e);
newFragment = new TaskListFragment();
}
@ -225,7 +222,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
* does during the onAttach() callback
*/
public interface OnTaskListItemClickedListener {
public void onTaskListItemClicked(long taskId);
void onTaskListItemClicked(long taskId);
}
@Override

@ -75,7 +75,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
private static final Logger log = LoggerFactory.getLogger(TaskAdapter.class);
public interface OnCompletedTaskListener {
public void onCompletedTask(Task item, boolean newState);
void onCompletedTask(Task item, boolean newState);
}
private static final StringProperty TAGS = new StringProperty(null, "group_concat(nullif(" + TaskListFragment.TAGS_METADATA_JOIN + "." + TaskToTagMetadata.TAG_NAME.name + ", '')"+ ", ' | ')").as("tags");

@ -219,7 +219,7 @@ public class TasksXmlExporter {
}
}
private synchronized void serializeMetadata(Task task) throws IOException {
private synchronized void serializeMetadata(Task task) {
metadataDao.byTask(task.getId(), new Callback<Metadata>() {
@Override
public void apply(Metadata metadata) {
@ -296,11 +296,7 @@ public class TasksXmlExporter {
xml.attribute(null, property.name, valueString);
} catch (UnsupportedOperationException e) {
// didn't read this value, do nothing
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalStateException e) {
throw new RuntimeException(e);
} catch (IOException e) {
} catch (IllegalArgumentException | IllegalStateException | IOException e) {
throw new RuntimeException(e);
}
return null;

@ -1,5 +1,5 @@
package com.todoroo.astrid.dao;
public interface DatabaseUpdateListener {
public void onDatabaseUpdated();
void onDatabaseUpdated();
}

@ -209,7 +209,7 @@ public class TaskDao {
}
}
public boolean createNew(Task item) {
public void createNew(Task item) {
if(!item.containsValue(Task.CREATION_DATE)) {
item.setCreationDate(DateUtilities.now());
}
@ -230,12 +230,9 @@ public class TaskDao {
setDefaultReminders(preferences, item);
ContentValues values = item.getSetValues();
boolean result = dao.createNew(item);
if(result) {
if(dao.createNew(item)) {
afterSave(item, values);
}
return result;
}
public static void createDefaultHideUntil(Preferences preferences, Task item) {
@ -260,21 +257,19 @@ public class TaskDao {
}
}
public boolean saveExisting(Task item) {
public void saveExisting(Task item) {
ContentValues values = item.getSetValues();
if(values == null || values.size() == 0) {
return false;
return;
}
if(!TaskApiDao.insignificantChange(values)) {
if(!values.containsKey(Task.MODIFICATION_DATE.name)) {
item.setModificationDate(DateUtilities.now());
}
}
boolean result = dao.saveExisting(item);
if(result) {
if(dao.saveExisting(item)) {
afterSave(item, values);
}
return result;
}
private static final Property<?>[] SQL_CONSTRAINT_MERGE_PROPERTIES = new Property<?>[] {

@ -20,11 +20,11 @@ public class UserActivityDao {
dao = new RemoteModelDao<>(database, UserActivity.class);
}
public boolean createNew(UserActivity item) {
public void createNew(UserActivity item) {
if (!item.containsValue(UserActivity.CREATED_AT)) {
item.setCreatedAt(DateUtilities.now());
}
return dao.createNew(item);
dao.createNew(item);
}
public boolean saveExisting(UserActivity item) {

@ -171,8 +171,8 @@ public class FilesControlSet extends PopupControlSet {
}
}
public static interface PlaybackExceptionHandler {
public void playbackFailed();
public interface PlaybackExceptionHandler {
void playbackFailed();
}
private static void play(String file, PlaybackExceptionHandler handler) {

@ -55,7 +55,7 @@ public final class GtasksMetadataService {
* Clears metadata information. Used when user logs out of sync provider
*/
public void clearMetadata() {
metadataDao.deleteWhere(Metadata.KEY.eq(getMetadataKey()));
metadataDao.deleteWhere(Metadata.KEY.eq(GtasksMetadata.METADATA_KEY));
}
/**
@ -64,7 +64,7 @@ public final class GtasksMetadataService {
public void saveTaskAndMetadata(GtasksTaskContainer task) {
task.prepareForSaving();
taskDao.save(task.task);
synchronizeMetadata(task.task.getId(), task.metadata, getMetadataKey());
synchronizeMetadata(task.task.getId(), task.metadata, GtasksMetadata.METADATA_KEY);
}
/**
@ -73,7 +73,7 @@ public final class GtasksMetadataService {
*/
public Metadata getTaskMetadata(long taskId) {
return metadataDao.getFirst(Query.select(Metadata.PROPERTIES).where(
MetadataCriteria.byTaskAndwithKey(taskId, getMetadataKey())));
MetadataCriteria.byTaskAndwithKey(taskId, GtasksMetadata.METADATA_KEY)));
}
/**
@ -118,10 +118,6 @@ public final class GtasksMetadataService {
}
}
private String getMetadataKey() {
return GtasksMetadata.METADATA_KEY;
}
public synchronized void findLocalMatch(GtasksTaskContainer remoteTask) {
if(remoteTask.task.getId() != Task.NO_ID) {
return;
@ -141,7 +137,7 @@ public final class GtasksMetadataService {
private Metadata getMetadataByGtaskId(String gtaskId) {
return metadataDao.getFirst(Query.select(Metadata.PROPERTIES).where(Criterion.and(
Metadata.KEY.eq(getMetadataKey()),
Metadata.KEY.eq(GtasksMetadata.METADATA_KEY),
GtasksMetadata.ID.eq(gtaskId))));
}

@ -33,10 +33,6 @@ public class GtasksPreferenceService {
this.preferences = preferences;
}
public String getIdentifier() {
return IDENTIFIER;
}
public String getDefaultList() {
return preferences.getStringValue(PREF_DEFAULT_LIST);
}
@ -57,74 +53,52 @@ public class GtasksPreferenceService {
protected static final String PREF_LAST_SYNC = "_last_sync"; //$NON-NLS-1$
protected static final String PREF_LAST_ATTEMPTED_SYNC = "_last_attempted"; //$NON-NLS-1$
protected static final String PREF_LAST_ERROR = "_last_err"; //$NON-NLS-1$
protected static final String PREF_ONGOING = "_ongoing"; //$NON-NLS-1$
/**
* @return true if we have a token for this user, false otherwise
*/
public boolean isLoggedIn() {
return preferences.getStringValue(getIdentifier() + PREF_TOKEN) != null;
return preferences.getStringValue(IDENTIFIER + PREF_TOKEN) != null;
}
/** authentication token, or null if doesn't exist */
public String getToken() {
return preferences.getStringValue(getIdentifier() + PREF_TOKEN);
return preferences.getStringValue(IDENTIFIER + PREF_TOKEN);
}
/** Sets the authentication token. Set to null to clear. */
public void setToken(String setting) {
preferences.setString(getIdentifier() + PREF_TOKEN, setting);
preferences.setString(IDENTIFIER + PREF_TOKEN, setting);
}
/** @return Last Successful Sync Date, or 0 */
public long getLastSyncDate() {
return preferences.getLong(getIdentifier() + PREF_LAST_SYNC, 0);
}
/** @return Last Attempted Sync Date, or 0 if it was successful */
public long getLastAttemptedSyncDate() {
return preferences.getLong(getIdentifier() + PREF_LAST_ATTEMPTED_SYNC, 0);
}
/** @return Last Error, or null if no last error */
public String getLastError() {
return preferences.getStringValue(getIdentifier() + PREF_LAST_ERROR);
return preferences.getLong(IDENTIFIER + PREF_LAST_SYNC, 0);
}
/** @return Last Error, or null if no last error */
public boolean isOngoing() {
return preferences.getBoolean(getIdentifier() + PREF_ONGOING, false);
return preferences.getBoolean(IDENTIFIER + PREF_ONGOING, false);
}
/** Deletes Last Successful Sync Date */
public void clearLastSyncDate() {
preferences.clear(getIdentifier() + PREF_LAST_SYNC);
}
/** Set Last Error */
public void setLastError(String error) {
preferences.setString(getIdentifier() + PREF_LAST_ERROR, error);
preferences.clear(IDENTIFIER + PREF_LAST_SYNC);
}
/** Set Ongoing */
public void stopOngoing() {
preferences.setBoolean(getIdentifier() + PREF_ONGOING, false);
preferences.setBoolean(IDENTIFIER + PREF_ONGOING, false);
}
/** Set Last Successful Sync Date */
public void recordSuccessfulSync() {
preferences.setLong(getIdentifier() + PREF_LAST_SYNC, DateUtilities.now() + 1000);
preferences.setLong(getIdentifier() + PREF_LAST_ATTEMPTED_SYNC, 0);
preferences.setLong(IDENTIFIER + PREF_LAST_SYNC, DateUtilities.now() + 1000);
}
/** Set Last Attempted Sync Date */
public void recordSyncStart() {
preferences.setLong(getIdentifier() + PREF_LAST_ATTEMPTED_SYNC, DateUtilities.now());
preferences.clear(getIdentifier() + PREF_LAST_ERROR);
preferences.setBoolean(getIdentifier() + PREF_ONGOING, true);
preferences.setBoolean(IDENTIFIER + PREF_ONGOING, true);
}
}

@ -22,7 +22,7 @@ abstract public class OrderedMetadataListUpdater<LIST> {
private MetadataDao metadataDao;
public interface OrderedListIterator {
public void processTask(long taskId, Metadata metadata);
void processTask(long taskId, Metadata metadata);
}
// --- abstract and empty
@ -297,7 +297,7 @@ abstract public class OrderedMetadataListUpdater<LIST> {
// --- task cascading operations
public interface OrderedListNodeVisitor {
public void visitNode(Node node);
void visitNode(Node node);
}
/**

@ -56,7 +56,6 @@ public class GtasksSyncV2Provider {
public class SyncExceptionHandler {
public void handleException(String tag, Exception e) {
getUtilities().setLastError(e.toString());
log.error("{}: {}", tag, e.getMessage(), e);
}
}
@ -64,7 +63,7 @@ public class GtasksSyncV2Provider {
private final SyncExceptionHandler handler = new SyncExceptionHandler();
private void finishSync(SyncResultCallback callback) {
getUtilities().recordSuccessfulSync();
gtasksPreferenceService.recordSuccessfulSync();
callback.finished();
}
@ -111,10 +110,6 @@ public class GtasksSyncV2Provider {
return context.getString(R.string.gtasks_GPr_header);
}
public GtasksPreferenceService getUtilities() {
return gtasksPreferenceService;
}
public void signOut() {
gtasksPreferenceService.clearLastSyncDate();
gtasksPreferenceService.setToken(null);

@ -91,8 +91,8 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
private final List<UpdatesChangedListener> listeners = new LinkedList<>();
public interface UpdatesChangedListener {
public void updatesChanged();
public void commentAdded();
void updatesChanged();
void commentAdded();
}
public EditNoteActivity(

@ -384,7 +384,7 @@ public final class ReminderService {
* Interface for testing
*/
public interface AlarmScheduler {
public void createAlarm(Context context, Task task, long time, int type);
void createAlarm(Context context, Task task, long time, int type);
}
public void setScheduler(AlarmScheduler scheduler) {

@ -7,6 +7,6 @@ package com.todoroo.astrid.reminders;
public interface SnoozeCallback {
public void snoozeForTime(long time);
void snoozeForTime(long time);
}

@ -17,7 +17,6 @@ import com.todoroo.andlib.data.DatabaseDao.ModelUpdateListener;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.backup.BackupConstants;
import com.todoroo.astrid.backup.TasksXmlImporter;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.DatabaseUpdateListener;

@ -3,5 +3,5 @@ package com.todoroo.astrid.service;
import com.todoroo.astrid.data.Metadata;
public interface SynchronizeMetadataCallback {
public void beforeDeleteMetadata(Metadata m);
void beforeDeleteMetadata(Metadata m);
}

@ -236,8 +236,8 @@ public class TaskService {
* Parse quick add markup for the given task
* @param tags an empty array to apply tags to
*/
boolean parseQuickAddMarkup(Task task, ArrayList<String> tags) {
return TitleParser.parse(tagService, task, tags);
void parseQuickAddMarkup(Task task, ArrayList<String> tags) {
TitleParser.parse(tagService, task, tags);
}
/**

@ -29,7 +29,7 @@ public abstract class AstridOrderedListUpdater<LIST> {
}
public interface OrderedListNodeVisitor {
public void visitNode(Node node);
void visitNode(Node node);
}
public static class Node {

@ -148,8 +148,8 @@ public class SubtasksHelper {
return AstridOrderedListUpdater.serializeTree(tree);
}
public static interface TreeRemapHelper<T> {
public T getKeyFromOldUuid(String uuid);
public interface TreeRemapHelper<T> {
T getKeyFromOldUuid(String uuid);
}
public static <T> void remapTree(Node root, HashMap<T, String> idMap, TreeRemapHelper<T> helper) {

@ -9,10 +9,10 @@ public interface SyncResultCallback {
/**
* Provider started sync
*/
public void started();
void started();
/**
* Provider finished sync
*/
public void finished();
void finished();
}

@ -37,7 +37,7 @@ public class AstridTimePicker extends LinearLayout {
private boolean lastSelectionWasPm; // false for AM, true for PM
public interface TimePickerEnabledChangedListener {
public void timePickerEnabledChanged(boolean hasTime);
void timePickerEnabledChanged(boolean hasTime);
}
public AstridTimePicker(Context context, AttributeSet attrs) {

@ -73,7 +73,7 @@ public class CalendarView extends View {
private int currentHighlightDay = -1;
public interface OnSelectedDateListener {
public void onSelectedDate(Date date);
void onSelectedDate(Date date);
}
private OnSelectedDateListener onSelectedDateListener;

@ -19,7 +19,7 @@ import org.tasks.preferences.ActivityPreferences;
public class DateAndTimeDialog extends Dialog {
public interface DateAndTimeDialogListener {
public void onDateAndTimeSelected(long date);
void onDateAndTimeSelected(long date);
}
private final DateAndTimePicker dateAndTimePicker;

@ -36,7 +36,8 @@ public abstract class PopupControlSet extends TaskEditControlSetBase {
final PopupDialogClickListener okListener = new PopupDialogClickListener() {
@Override
public boolean onClick(DialogInterface d, int which) {
return onOkClick();
onOkClick();
return true;
}
};
@ -133,13 +134,8 @@ public abstract class PopupControlSet extends TaskEditControlSetBase {
// Subclasses can override
}
/**
* @return true if the dialog should be dismissed as the result of
* the click. Default is true.
*/
protected boolean onOkClick() {
protected void onOkClick() {
refreshDisplayView();
return true;
}
protected void onCancelClick() {

@ -141,7 +141,7 @@ public class ReminderControlSet extends TaskEditControlSetBase implements Adapte
return alertItem;
}
private View addAlarmRow(final View alertItem, String text, Long timestamp, final View.OnClickListener onRemove) {
private void addAlarmRow(final View alertItem, String text, Long timestamp, final View.OnClickListener onRemove) {
alertItem.setTag(timestamp);
TextView display = (TextView) alertItem.findViewById(R.id.alarm_string);
display.setText(text);
@ -156,7 +156,6 @@ public class ReminderControlSet extends TaskEditControlSetBase implements Adapte
}
});
updateSpinner();
return alertItem;
}
private void updateSpinner() {

@ -19,7 +19,7 @@ public class AACRecorder {
private AACRecorderCallbacks listener;
public interface AACRecorderCallbacks {
public void encodingFinished();
void encodingFinished();
}
@TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1)

@ -5,7 +5,7 @@ import android.os.Bundle;
import dagger.ObjectGraph;
public class InjectingActivity extends Activity implements Injector {
public abstract class InjectingActivity extends Activity implements Injector {
private ObjectGraph objectGraph;
@Override

@ -5,7 +5,7 @@ import android.support.v7.app.AppCompatActivity;
import dagger.ObjectGraph;
public class InjectingAppCompatActivity extends AppCompatActivity implements Injector {
public abstract class InjectingAppCompatActivity extends AppCompatActivity implements Injector {
private ObjectGraph objectGraph;
@Override

@ -3,7 +3,7 @@ package org.tasks.injection;
import android.app.IntentService;
import android.content.Intent;
public class InjectingIntentService extends IntentService {
public abstract class InjectingIntentService extends IntentService {
public InjectingIntentService(String name) {
super(name);

@ -5,7 +5,7 @@ import android.os.Bundle;
import dagger.ObjectGraph;
public class InjectingListActivity extends ListActivity implements Injector {
public abstract class InjectingListActivity extends ListActivity implements Injector {
private ObjectGraph objectGraph;
@Override

@ -45,7 +45,6 @@ import org.tasks.injection.ForApplication;
import org.tasks.injection.InjectingFragment;
import org.tasks.preferences.AppearancePreferences;
import org.tasks.preferences.BasicPreferences;
import org.tasks.preferences.Preferences;
import javax.inject.Inject;
@ -85,7 +84,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
private int mCurrentSelectedPosition = 0;
@Inject FilterCounter filterCounter;
@Inject Preferences preferences;
@Inject FilterProvider filterProvider;
@Inject @ForApplication Context context;
@ -383,7 +381,7 @@ public class NavigationDrawerFragment extends InjectingFragment {
}
public interface OnFilterItemClickedListener {
public boolean onFilterItemClicked(FilterListItem item);
boolean onFilterItemClicked(FilterListItem item);
}
public void clear() {
@ -429,10 +427,6 @@ public class NavigationDrawerFragment extends InjectingFragment {
new IntentFilter(AstridApiConstants.BROADCAST_EVENT_REFRESH));
}
public void restoreLastSelected() {
selectItem(mCurrentSelectedPosition);
}
/**
* Receiver which receives refresh intents
*

Binary file not shown.

Before

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

@ -204,10 +204,4 @@
<item name="android:textSize">18sp</item>
</style>
<style name="Widget"/>
<style name="Widget.Holo"/>
<style name="Widget.Holo.Light"/>
<style name="Widget.Holo.Light.CompoundButton"/>
<style name="Widget.Holo.Light.CompoundButton.Switch"/>
</resources>

Loading…
Cancel
Save