Update to JDK 1.7

pull/46/merge
Alex Baker 12 years ago
parent b929efa16f
commit 7e62156bf0

@ -17,6 +17,11 @@ android {
compileSdkVersion 19 compileSdkVersion 19
buildToolsVersion "19" buildToolsVersion "19"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig { defaultConfig {
minSdkVersion 7 minSdkVersion 7
targetSdkVersion 19 targetSdkVersion 19

@ -17,6 +17,11 @@ android {
compileSdkVersion 19 compileSdkVersion 19
buildToolsVersion "19" buildToolsVersion "19"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig { defaultConfig {
minSdkVersion 7 minSdkVersion 7
targetSdkVersion 19 targetSdkVersion 19

@ -93,7 +93,7 @@ abstract public class AbstractDatabase {
public void onDatabaseUpdated(); public void onDatabaseUpdated();
} }
private final ArrayList<DatabaseUpdateListener> listeners = new ArrayList<DatabaseUpdateListener>(); private final ArrayList<DatabaseUpdateListener> listeners = new ArrayList<>();
public void addListener(DatabaseUpdateListener listener) { public void addListener(DatabaseUpdateListener listener) {
listeners.add(listener); listeners.add(listener);

@ -379,7 +379,7 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
public synchronized void putTransitory(String key, Object value) { public synchronized void putTransitory(String key, Object value) {
if(transitoryData == null) { if(transitoryData == null) {
transitoryData = new HashMap<String, Object>(); transitoryData = new HashMap<>();
} }
transitoryData.put(key, value); transitoryData.put(key, value);
} }
@ -415,7 +415,7 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* Looks inside the given class and finds all declared properties * Looks inside the given class and finds all declared properties
*/ */
protected static Property<?>[] generateProperties(Class<? extends AbstractModel> cls) { protected static Property<?>[] generateProperties(Class<? extends AbstractModel> cls) {
ArrayList<Property<?>> properties = new ArrayList<Property<?>>(); ArrayList<Property<?>> properties = new ArrayList<>();
if(cls.getSuperclass() != AbstractModel.class) { if(cls.getSuperclass() != AbstractModel.class) {
properties.addAll(Arrays.asList(generateProperties( properties.addAll(Arrays.asList(generateProperties(
(Class<? extends AbstractModel>) cls.getSuperclass()))); (Class<? extends AbstractModel>) cls.getSuperclass())));
@ -434,9 +434,7 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
continue; continue;
} }
properties.add((Property<?>) field.get(null)); properties.add((Property<?>) field.get(null));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -524,9 +522,7 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
TYPE model; TYPE model;
try { try {
model = cls.newInstance(); model = cls.newInstance();
} catch (IllegalAccessException e) { } catch (IllegalAccessException | InstantiationException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
model.setValues = source.readParcelable(ContentValues.class.getClassLoader()); model.setValues = source.readParcelable(ContentValues.class.getClassLoader());

@ -70,7 +70,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
} }
private final ArrayList<ModelUpdateListener<TYPE>> listeners = private final ArrayList<ModelUpdateListener<TYPE>> listeners =
new ArrayList<ModelUpdateListener<TYPE>>(); new ArrayList<>();
public void addListener(ModelUpdateListener<TYPE> listener) { public void addListener(ModelUpdateListener<TYPE> listener) {
listeners.add(listener); listeners.add(listener);
@ -94,7 +94,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
Log.i("SQL-" + modelClass.getSimpleName(), query.toString()); //$NON-NLS-1$ Log.i("SQL-" + modelClass.getSimpleName(), query.toString()); //$NON-NLS-1$
} }
Cursor cursor = database.rawQuery(query.toString()); Cursor cursor = database.rawQuery(query.toString());
return new TodorooCursor<TYPE>(cursor, query.getFields()); return new TodorooCursor<>(cursor, query.getFields());
} }
/** /**
@ -105,7 +105,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
for(int i = 0; i < properties.length; i++) { for(int i = 0; i < properties.length; i++) {
fields[i] = properties[i].name; fields[i] = properties[i].name;
} }
return new TodorooCursor<TYPE>(database.getDatabase().query(table.name, return new TodorooCursor<>(database.getDatabase().query(table.name,
fields, selection, selectionArgs, null, null, null), fields, selection, selectionArgs, null, null, null),
properties); properties);
} }
@ -130,17 +130,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
} }
Constructor<TYPE> constructor = modelClass.getConstructor(TodorooCursor.class); Constructor<TYPE> constructor = modelClass.getConstructor(TodorooCursor.class);
return constructor.newInstance(cursor); return constructor.newInstance(cursor);
} catch (SecurityException e) { } catch (SecurityException | InvocationTargetException | IllegalAccessException | InstantiationException | IllegalArgumentException | NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
cursor.close(); cursor.close();
@ -280,7 +270,7 @@ public class DatabaseDao<TYPE extends AbstractModel> {
TodorooCursor<TYPE> cursor = query( TodorooCursor<TYPE> cursor = query(
Query.select(properties).where(AbstractModel.ID_PROPERTY.eq(id))); Query.select(properties).where(AbstractModel.ID_PROPERTY.eq(id)));
cursor.moveToFirst(); cursor.moveToFirst();
return new TodorooCursor<TYPE>(cursor, properties); return new TodorooCursor<>(cursor, properties);
} }
public int count(Query query) { public int count(Query query) {

@ -36,13 +36,7 @@ public final class Table extends SqlTable {
public Property<?>[] getProperties() { public Property<?>[] getProperties() {
try { try {
return (Property<?>[])modelClass.getField("PROPERTIES").get(null); return (Property<?>[])modelClass.getField("PROPERTIES").get(null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | NoSuchFieldException | IllegalAccessException | SecurityException e) {
throw new RuntimeException(e);
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

@ -43,7 +43,7 @@ public class TodorooCursor<TYPE extends AbstractModel> extends CursorWrapper {
super(cursor); super(cursor);
this.properties = properties; this.properties = properties;
columnIndexCache = new WeakHashMap<String, Integer>(); columnIndexCache = new WeakHashMap<>();
} }
/** /**

@ -42,13 +42,13 @@ abstract public class AbstractDependencyInjector {
/** /**
* Dependencies this class knows how to handle * Dependencies this class knows how to handle
*/ */
protected final HashMap<String, Object> injectables = new HashMap<String, Object>(); protected final HashMap<String, Object> injectables = new HashMap<>();
/** /**
* Cache of classes that were instantiated by the injector * Cache of classes that were instantiated by the injector
*/ */
protected final HashMap<Class<?>, WeakReference<Object>> createdObjects = protected final HashMap<Class<?>, WeakReference<Object>> createdObjects =
new HashMap<Class<?>, WeakReference<Object>>(); new HashMap<>();
/** /**
* Gets the injected object for this field. If implementing class does not * Gets the injected object for this field. If implementing class does not
@ -71,14 +71,11 @@ abstract public class AbstractDependencyInjector {
Class<?> cls = (Class<?>)injection; Class<?> cls = (Class<?>)injection;
try { try {
injection = cls.newInstance(); injection = cls.newInstance();
} catch (IllegalAccessException e) { } catch (IllegalAccessException | InstantiationException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
createdObjects.put(cls, createdObjects.put(cls, new WeakReference<>(injection));
new WeakReference<Object>(injection));
} }
} }

@ -30,7 +30,7 @@ public class DependencyInjectionService {
/** /**
* Dependency injectors. Use getters and setters to modify this list * Dependency injectors. Use getters and setters to modify this list
*/ */
private final LinkedList<AbstractDependencyInjector> injectors = new LinkedList<AbstractDependencyInjector>(); private final LinkedList<AbstractDependencyInjector> injectors = new LinkedList<>();
/** /**
* Perform dependency injection in the caller object * Perform dependency injection in the caller object
@ -55,13 +55,7 @@ public class DependencyInjectionService {
field.setAccessible(true); field.setAccessible(true);
try { try {
handleField(caller, field); handleField(caller, field);
} catch (IllegalStateException e) { } catch (IllegalStateException | IllegalAccessException | IllegalArgumentException e) {
throw new RuntimeException(String.format("Unable to set field '%s' of type '%s'",
field.getName(), field.getType()), e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(String.format("Unable to set field '%s' of type '%s'",
field.getName(), field.getType()), e);
} catch (IllegalAccessException e) {
throw new RuntimeException(String.format("Unable to set field '%s' of type '%s'", throw new RuntimeException(String.format("Unable to set field '%s' of type '%s'",
field.getName(), field.getType()), e); field.getName(), field.getType()), e);
} }

@ -22,7 +22,7 @@ public class Order {
private Order(Object expression, OrderType orderType) { private Order(Object expression, OrderType orderType) {
this.expression = expression; this.expression = expression;
this.orderType = orderType; this.orderType = orderType;
this.secondaryExpressions = new ArrayList<Order>(); this.secondaryExpressions = new ArrayList<>();
} }
public static Order asc(Object expression) { public static Order asc(Object expression) {

@ -27,11 +27,11 @@ public final class Query {
private SqlTable table; private SqlTable table;
private String queryTemplate = null; private String queryTemplate = null;
private final ArrayList<Criterion> criterions = new ArrayList<Criterion>(); private final ArrayList<Criterion> criterions = new ArrayList<>();
private final ArrayList<Field> fields = new ArrayList<Field>(); private final ArrayList<Field> fields = new ArrayList<>();
private final ArrayList<Join> joins = new ArrayList<Join>(); private final ArrayList<Join> joins = new ArrayList<>();
private final ArrayList<Field> groupBies = new ArrayList<Field>(); private final ArrayList<Field> groupBies = new ArrayList<>();
private final ArrayList<Order> orders = new ArrayList<Order>(); private final ArrayList<Order> orders = new ArrayList<>();
private int limits = -1; private int limits = -1;
private boolean distinct = false; private boolean distinct = false;

@ -24,10 +24,10 @@ import static java.util.Arrays.asList;
*/ */
public final class QueryTemplate { public final class QueryTemplate {
private final ArrayList<Criterion> criterions = new ArrayList<Criterion>(); private final ArrayList<Criterion> criterions = new ArrayList<>();
private final ArrayList<Join> joins = new ArrayList<Join>(); private final ArrayList<Join> joins = new ArrayList<>();
private final ArrayList<Field> groupBies = new ArrayList<Field>(); private final ArrayList<Field> groupBies = new ArrayList<>();
private final ArrayList<Order> orders = new ArrayList<Order>(); private final ArrayList<Order> orders = new ArrayList<>();
private Integer limit = null; private Integer limit = null;
public QueryTemplate join(Join... join) { public QueryTemplate join(Join... join) {

@ -121,5 +121,5 @@ public class Metadata extends AbstractModel {
// --- parcelable helpers // --- parcelable helpers
private static final Creator<Metadata> CREATOR = new ModelCreator<Metadata>(Metadata.class); private static final Creator<Metadata> CREATOR = new ModelCreator<>(Metadata.class);
} }

@ -19,7 +19,6 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
@ -133,8 +132,6 @@ abstract public class RemoteModel extends AbstractModel {
fos.flush(); fos.flush();
fos.close(); fos.close();
jsonObject.put("path", file.getAbsolutePath()); jsonObject.put("path", file.getAbsolutePath());
} catch (FileNotFoundException e) {
//
} catch (IOException e) { } catch (IOException e) {
// //
} }

@ -95,5 +95,5 @@ public class StoreObject extends AbstractModel {
// --- parcelable helpers // --- parcelable helpers
private static final Creator<StoreObject> CREATOR = new ModelCreator<StoreObject>(StoreObject.class); private static final Creator<StoreObject> CREATOR = new ModelCreator<>(StoreObject.class);
} }

@ -197,7 +197,7 @@ public final class TagData extends RemoteModel {
// --- parcelable helpers // --- parcelable helpers
public static final Creator<TagData> CREATOR = new ModelCreator<TagData>(TagData.class); public static final Creator<TagData> CREATOR = new ModelCreator<>(TagData.class);
// --- data access methods // --- data access methods

@ -75,5 +75,5 @@ public class TagMetadata extends AbstractModel {
// --- parcelable helpers // --- parcelable helpers
private static final Creator<TagMetadata> CREATOR = new ModelCreator<TagMetadata>(TagMetadata.class); private static final Creator<TagMetadata> CREATOR = new ModelCreator<>(TagMetadata.class);
} }

@ -301,7 +301,7 @@ public final class Task extends RemoteModel {
// --- parcelable helpers // --- parcelable helpers
public static final Creator<Task> CREATOR = new ModelCreator<Task>(Task.class); public static final Creator<Task> CREATOR = new ModelCreator<>(Task.class);
// --- data access methods // --- data access methods

@ -167,5 +167,5 @@ public final class TaskAttachment extends RemoteModel {
// --- parcelable helpers // --- parcelable helpers
public static final Creator<TaskAttachment> CREATOR = new ModelCreator<TaskAttachment>(TaskAttachment.class); public static final Creator<TaskAttachment> CREATOR = new ModelCreator<>(TaskAttachment.class);
} }

@ -118,5 +118,5 @@ public final class TaskListMetadata extends RemoteModel {
// --- parcelable helpers // --- parcelable helpers
public static final Creator<TaskListMetadata> CREATOR = new ModelCreator<TaskListMetadata>(TaskListMetadata.class); public static final Creator<TaskListMetadata> CREATOR = new ModelCreator<>(TaskListMetadata.class);
} }

@ -139,5 +139,5 @@ public class Update extends RemoteModel {
// --- parcelable helpers // --- parcelable helpers
private static final Creator<Update> CREATOR = new ModelCreator<Update>(Update.class); private static final Creator<Update> CREATOR = new ModelCreator<>(Update.class);
} }

@ -106,5 +106,5 @@ public class UserActivity extends RemoteModel {
return getIdHelper(ID); return getIdHelper(ID);
} }
private static final Creator<UserActivity> CREATOR = new ModelCreator<UserActivity>(UserActivity.class); private static final Creator<UserActivity> CREATOR = new ModelCreator<>(UserActivity.class);
} }

@ -247,7 +247,7 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
private static HashMap<String, Integer> getExceptionMap() { private static HashMap<String, Integer> getExceptionMap() {
if (exceptionsToDisplayMessages == null) { if (exceptionsToDisplayMessages == null) {
exceptionsToDisplayMessages = new HashMap<String, Integer>(); exceptionsToDisplayMessages = new HashMap<>();
exceptionsToDisplayMessages.put("java.net.ConnectionException", R.string.sync_error_offline); exceptionsToDisplayMessages.put("java.net.ConnectionException", R.string.sync_error_offline);
exceptionsToDisplayMessages.put("java.net.UnknownHostException", R.string.sync_error_offline); exceptionsToDisplayMessages.put("java.net.UnknownHostException", R.string.sync_error_offline);
} }

@ -34,6 +34,11 @@ android {
release release
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes { buildTypes {
release { release {
runProguard true runProguard true

@ -96,7 +96,7 @@ public class GtasksDetailExposerTest extends DatabaseTestCase {
private void givenTwoListSetup() { private void givenTwoListSetup() {
TaskLists lists = new TaskLists(); TaskLists lists = new TaskLists();
List<TaskList> newLists = new ArrayList<TaskList>(); List<TaskList> newLists = new ArrayList<>();
TaskList list = new TaskList(); TaskList list = new TaskList();
list.setId("listone-id"); list.setId("listone-id");
list.setTitle("List One"); //new GoogleTaskListInfo("listone-id", "List One"); list.setTitle("List One"); //new GoogleTaskListInfo("listone-id", "List One");

@ -137,7 +137,7 @@ public class GtasksIndentActionTest extends DatabaseTestCase {
super.setUp(); super.setUp();
TaskLists lists = new TaskLists(); TaskLists lists = new TaskLists();
List<TaskList> items = new ArrayList<TaskList>(); List<TaskList> items = new ArrayList<>();
TaskList list = new TaskList(); TaskList list = new TaskList();
list.setId("list"); list.setId("list");
list.setTitle("Test Tasks"); list.setTitle("Test Tasks");

@ -124,7 +124,7 @@ public class GtasksTaskListUpdaterTest extends DatabaseTestCase {
super.setUp(); super.setUp();
TaskLists lists = new TaskLists(); TaskLists lists = new TaskLists();
List<TaskList> items = new ArrayList<TaskList>(); List<TaskList> items = new ArrayList<>();
TaskList list = new TaskList(); TaskList list = new TaskList();
list.setId("1"); list.setId("1");
list.setTitle("Tim's Tasks"); list.setTitle("Tim's Tasks");

@ -241,7 +241,7 @@ public class GtasksTaskMovingTest extends DatabaseTestCase {
super.setUp(); super.setUp();
TaskLists lists = new TaskLists(); TaskLists lists = new TaskLists();
List<TaskList> items = new ArrayList<TaskList>(); List<TaskList> items = new ArrayList<>();
TaskList taskList = new TaskList(); TaskList taskList = new TaskList();
taskList.setId("1"); taskList.setId("1");
taskList.setTitle("Tim's Tasks"); taskList.setTitle("Tim's Tasks");

@ -28,13 +28,13 @@ public class TaskTests extends DatabaseTestCase {
assertTrue(Task.IMPORTANCE_MUST_DO < Task.IMPORTANCE_SHOULD_DO); assertTrue(Task.IMPORTANCE_MUST_DO < Task.IMPORTANCE_SHOULD_DO);
assertTrue(Task.IMPORTANCE_SHOULD_DO < Task.IMPORTANCE_NONE); assertTrue(Task.IMPORTANCE_SHOULD_DO < Task.IMPORTANCE_NONE);
ArrayList<Integer> reminderFlags = new ArrayList<Integer>(); ArrayList<Integer> reminderFlags = new ArrayList<>();
reminderFlags.add(Task.NOTIFY_AFTER_DEADLINE); reminderFlags.add(Task.NOTIFY_AFTER_DEADLINE);
reminderFlags.add(Task.NOTIFY_AT_DEADLINE); reminderFlags.add(Task.NOTIFY_AT_DEADLINE);
reminderFlags.add(Task.NOTIFY_MODE_NONSTOP); reminderFlags.add(Task.NOTIFY_MODE_NONSTOP);
// assert no duplicates // assert no duplicates
assertEquals(new TreeSet<Integer>(reminderFlags).size(), assertEquals(new TreeSet<>(reminderFlags).size(),
reminderFlags.size()); reminderFlags.size());
} }

@ -170,7 +170,7 @@ public class NewRepeatTests<REMOTE_MODEL> extends DatabaseTestCase {
result += DateUtilities.ONE_WEEK * rrule.getInterval(); result += DateUtilities.ONE_WEEK * rrule.getInterval();
return result; return result;
} }
HashSet<Weekday> weekdays = new HashSet<Weekday>(); HashSet<Weekday> weekdays = new HashSet<>();
for (WeekdayNum curr : weekdayNums) { for (WeekdayNum curr : weekdayNums) {
weekdays.add(curr.wday); weekdays.add(curr.wday);
} }
@ -361,7 +361,7 @@ public class NewRepeatTests<REMOTE_MODEL> extends DatabaseTestCase {
int interval = 1; int interval = 1;
rrule.setInterval(interval); rrule.setInterval(interval);
List<WeekdayNum> weekdays = new ArrayList<WeekdayNum>(); List<WeekdayNum> weekdays = new ArrayList<>();
weekdays.add(new WeekdayNum(0, Weekday.MO)); weekdays.add(new WeekdayNum(0, Weekday.MO));
weekdays.add(new WeekdayNum(0, Weekday.WE)); weekdays.add(new WeekdayNum(0, Weekday.WE));
rrule.setByDay(weekdays); rrule.setByDay(weekdays);
@ -374,7 +374,7 @@ public class NewRepeatTests<REMOTE_MODEL> extends DatabaseTestCase {
int interval = 1; int interval = 1;
rrule.setInterval(interval); rrule.setInterval(interval);
List<WeekdayNum> weekdays = new ArrayList<WeekdayNum>(); List<WeekdayNum> weekdays = new ArrayList<>();
weekdays.add(new WeekdayNum(0, Weekday.MO)); weekdays.add(new WeekdayNum(0, Weekday.MO));
weekdays.add(new WeekdayNum(0, Weekday.WE)); weekdays.add(new WeekdayNum(0, Weekday.WE));
rrule.setByDay(weekdays); rrule.setByDay(weekdays);

@ -70,7 +70,7 @@ public class QuickAddMarkupTest extends DatabaseTestCase {
// --- helpers // --- helpers
private Task task; private Task task;
private final ArrayList<String> tags = new ArrayList<String>(); private final ArrayList<String> tags = new ArrayList<>();
private void assertTagsAre(String... expectedTags) { private void assertTagsAre(String... expectedTags) {
List<String> expected = Arrays.asList(expectedTags); List<String> expected = Arrays.asList(expectedTags);

@ -548,7 +548,7 @@ public class TitleParserTest extends DatabaseTestCase {
for (String acceptedString : acceptedStrings) { for (String acceptedString : acceptedStrings) {
task = new Task(); task = new Task();
task.setValue(Task.TITLE, "Jog " + acceptedString); //test at end of task. should set importance. task.setValue(Task.TITLE, "Jog " + acceptedString); //test at end of task. should set importance.
ArrayList<String> tags = new ArrayList<String>(); ArrayList<String> tags = new ArrayList<>();
TitleParser.listHelper(task, tags); TitleParser.listHelper(task, tags);
String tag = TitleParser.trimParenthesis(acceptedString); String tag = TitleParser.trimParenthesis(acceptedString);
assertTrue("test pound at failed for string: " + acceptedString + " for tags: " + tags.toString(), tags.contains(tag)); assertTrue("test pound at failed for string: " + acceptedString + " for tags: " + tags.toString(), tags.contains(tag));
@ -567,7 +567,7 @@ public class TitleParserTest extends DatabaseTestCase {
for (String acceptedString : acceptedStrings) { for (String acceptedString : acceptedStrings) {
task = new Task(); task = new Task();
task.setValue(Task.TITLE, "Jog " + acceptedString); //test at end of task. should set importance. task.setValue(Task.TITLE, "Jog " + acceptedString); //test at end of task. should set importance.
ArrayList<String> tags = new ArrayList<String>(); ArrayList<String> tags = new ArrayList<>();
TitleParser.listHelper(task, tags); TitleParser.listHelper(task, tags);
String tag = TitleParser.trimParenthesis(acceptedString); String tag = TitleParser.trimParenthesis(acceptedString);
assertTrue("testTagsAt failed for string: " + acceptedString+ " for tags: " + tags.toString(), tags.contains(tag)); assertTrue("testTagsAt failed for string: " + acceptedString+ " for tags: " + tags.toString(), tags.contains(tag));

@ -91,7 +91,7 @@ public class AstridChronic {
tokens = Separator.scan(tokens, options); tokens = Separator.scan(tokens, options);
tokens = TimeZone.scan(tokens, options); tokens = TimeZone.scan(tokens, options);
List<Token> taggedTokens = new LinkedList<Token>(); List<Token> taggedTokens = new LinkedList<>();
for (Token token : tokens) { for (Token token : tokens) {
if (token.isTagged()) { if (token.isTagged()) {
taggedTokens.add(token); taggedTokens.add(token);
@ -156,7 +156,7 @@ public class AstridChronic {
*/ */
protected static List<Token> baseTokenize(String text) { protected static List<Token> baseTokenize(String text) {
String[] words = text.split(" "); String[] words = text.split(" ");
List<Token> tokens = new LinkedList<Token>(); List<Token> tokens = new LinkedList<>();
for (String word : words) { for (String word : words) {
tokens.add(new Token(word)); tokens.add(new Token(word));
} }

@ -39,7 +39,7 @@ public class ActFmCameraModule {
} }
public static void showPictureLauncher(final Fragment fragment, final ClearImageCallback clearImageOption) { public static void showPictureLauncher(final Fragment fragment, final ClearImageCallback clearImageOption) {
ArrayList<String> options = new ArrayList<String>(); ArrayList<String> options = new ArrayList<>();
final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
PackageManager pm = fragment.getActivity().getPackageManager(); PackageManager pm = fragment.getActivity().getPackageManager();
@ -54,7 +54,7 @@ public class ActFmCameraModule {
options.add(fragment.getString(R.string.actfm_picture_clear)); options.add(fragment.getString(R.string.actfm_picture_clear));
} }
ArrayAdapter<String> adapter = new ArrayAdapter<String>(fragment.getActivity(), ArrayAdapter<String> adapter = new ArrayAdapter<>(fragment.getActivity(),
android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()])); android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()]));
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {

@ -72,13 +72,13 @@ public class ActFmGoogleAuthActivity extends ListActivity {
accountManager = new GoogleAccountManager(this); accountManager = new GoogleAccountManager(this);
Account[] accounts = accountManager.getAccounts(); Account[] accounts = accountManager.getAccounts();
ArrayList<String> accountNames = new ArrayList<String>(); ArrayList<String> accountNames = new ArrayList<>();
for (Account a : accounts) { for (Account a : accounts) {
accountNames.add(a.name); accountNames.add(a.name);
} }
nameArray = accountNames.toArray(new String[accountNames.size()]); nameArray = accountNames.toArray(new String[accountNames.size()]);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, nameArray)); setListAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, nameArray));
findViewById(R.id.empty_button).setOnClickListener(new OnClickListener() { findViewById(R.id.empty_button).setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

@ -52,10 +52,10 @@ public class NameMaps {
static { static {
// Hardcoded local columns mapped to corresponding server names // Hardcoded local columns mapped to corresponding server names
TASK_PROPERTIES_LOCAL_TO_SERVER = new HashMap<Property<?>, String>(); TASK_PROPERTIES_LOCAL_TO_SERVER = new HashMap<>();
TASK_COLUMNS_LOCAL_TO_SERVER = new HashMap<String, String>(); TASK_COLUMNS_LOCAL_TO_SERVER = new HashMap<>();
TASK_COLUMN_NAMES_TO_PROPERTIES = new HashMap<String, Property<?>>(); TASK_COLUMN_NAMES_TO_PROPERTIES = new HashMap<>();
TASK_PROPERTIES_EXCLUDED = new HashSet<String>(); TASK_PROPERTIES_EXCLUDED = new HashSet<>();
putTaskPropertyToServerName(Task.TITLE, "title", true); putTaskPropertyToServerName(Task.TITLE, "title", true);
putTaskPropertyToServerName(Task.IMPORTANCE, "importance", true); putTaskPropertyToServerName(Task.IMPORTANCE, "importance", true);
@ -90,10 +90,10 @@ public class NameMaps {
} }
static { static {
// Hardcoded local columns mapped to corresponding server names // Hardcoded local columns mapped to corresponding server names
TAG_DATA_PROPERTIES_LOCAL_TO_SERVER = new HashMap<Property<?>, String>(); TAG_DATA_PROPERTIES_LOCAL_TO_SERVER = new HashMap<>();
TAG_DATA_COLUMNS_LOCAL_TO_SERVER = new HashMap<String, String>(); TAG_DATA_COLUMNS_LOCAL_TO_SERVER = new HashMap<>();
TAG_DATA_COLUMN_NAMES_TO_PROPERTIES = new HashMap<String, Property<?>>(); TAG_DATA_COLUMN_NAMES_TO_PROPERTIES = new HashMap<>();
TAG_PROPERTIES_EXCLUDED = new HashSet<String>(); TAG_PROPERTIES_EXCLUDED = new HashSet<>();
putTagPropertyToServerName(TagData.USER_ID, "user_id", true); putTagPropertyToServerName(TagData.USER_ID, "user_id", true);
putTagPropertyToServerName(TagData.NAME, "name", true); putTagPropertyToServerName(TagData.NAME, "name", true);
@ -120,10 +120,10 @@ public class NameMaps {
} }
static { static {
USER_ACTIVITY_PROPERTIES_LOCAL_TO_SERVER = new HashMap<Property<?>, String>(); USER_ACTIVITY_PROPERTIES_LOCAL_TO_SERVER = new HashMap<>();
USER_ACTIVITY_COLUMN_NAMES_TO_PROPERTIES = new HashMap<String, Property<?>>(); USER_ACTIVITY_COLUMN_NAMES_TO_PROPERTIES = new HashMap<>();
USER_ACTIVITY_COLUMNS_LOCAL_TO_SERVER = new HashMap<String, String>(); USER_ACTIVITY_COLUMNS_LOCAL_TO_SERVER = new HashMap<>();
USER_ACTIVITY_PROPERTIES_EXCLUDED = new HashSet<String>(); USER_ACTIVITY_PROPERTIES_EXCLUDED = new HashSet<>();
putUserActivityPropertyToServerName(UserActivity.UUID, "uuid", false); putUserActivityPropertyToServerName(UserActivity.UUID, "uuid", false);
putUserActivityPropertyToServerName(UserActivity.USER_UUID, "user_id", false); putUserActivityPropertyToServerName(UserActivity.USER_UUID, "user_id", false);
@ -150,10 +150,10 @@ public class NameMaps {
} }
static { static {
TASK_ATTACHMENT_PROPERTIES_LOCAL_TO_SERVER = new HashMap<Property<?>, String>(); TASK_ATTACHMENT_PROPERTIES_LOCAL_TO_SERVER = new HashMap<>();
TASK_ATTACHMENT_COLUMN_NAMES_TO_PROPERTIES = new HashMap<String, Property<?>>(); TASK_ATTACHMENT_COLUMN_NAMES_TO_PROPERTIES = new HashMap<>();
TASK_ATTACHMENT_COLUMNS_LOCAL_TO_SERVER = new HashMap<String, String>(); TASK_ATTACHMENT_COLUMNS_LOCAL_TO_SERVER = new HashMap<>();
TASK_ATTACHMENT_PROPERTIES_EXCLUDED = new HashSet<String>(); TASK_ATTACHMENT_PROPERTIES_EXCLUDED = new HashSet<>();
putTaskAttachmentPropertyToServerName(TaskAttachment.UUID, "uuid", false); putTaskAttachmentPropertyToServerName(TaskAttachment.UUID, "uuid", false);
putTaskAttachmentPropertyToServerName(TaskAttachment.USER_UUID, "user_id", false); putTaskAttachmentPropertyToServerName(TaskAttachment.USER_UUID, "user_id", false);
@ -180,10 +180,10 @@ public class NameMaps {
} }
static { static {
TASK_LIST_METADATA_PROPERTIES_LOCAL_TO_SERVER = new HashMap<Property<?>, String>(); TASK_LIST_METADATA_PROPERTIES_LOCAL_TO_SERVER = new HashMap<>();
TASK_LIST_METADATA_COLUMN_NAMES_TO_PROPERTIES = new HashMap<String, Property<?>>(); TASK_LIST_METADATA_COLUMN_NAMES_TO_PROPERTIES = new HashMap<>();
TASK_LIST_METADATA_COLUMNS_LOCAL_TO_SERVER = new HashMap<String, String>(); TASK_LIST_METADATA_COLUMNS_LOCAL_TO_SERVER = new HashMap<>();
TASK_LIST_METADATA_PROPERTIES_EXCLUDED = new HashSet<String>(); TASK_LIST_METADATA_PROPERTIES_EXCLUDED = new HashSet<>();
putTaskListMetadataPropertyToServerName(TaskListMetadata.UUID, "uuid", false); putTaskListMetadataPropertyToServerName(TaskListMetadata.UUID, "uuid", false);
putTaskListMetadataPropertyToServerName(TaskListMetadata.TAG_UUID, "tag_id", true); putTaskListMetadataPropertyToServerName(TaskListMetadata.TAG_UUID, "tag_id", true);

@ -100,7 +100,7 @@ public class BeastModePreferences extends ListActivity {
setContentView(R.layout.beast_mode_pref_activity); setContentView(R.layout.beast_mode_pref_activity);
setTitle(R.string.EPr_beastMode_desc); setTitle(R.string.EPr_beastMode_desc);
prefsToDescriptions = new HashMap<String, String>(); prefsToDescriptions = new HashMap<>();
buildDescriptionMap(getResources()); buildDescriptionMap(getResources());
TouchListView touchList = (TouchListView) getListView(); TouchListView touchList = (TouchListView) getListView();
@ -171,7 +171,7 @@ public class BeastModePreferences extends ListActivity {
public static ArrayList<String> constructOrderedControlList(Context context) { public static ArrayList<String> constructOrderedControlList(Context context) {
String order = Preferences.getStringValue(BEAST_MODE_ORDER_PREF); String order = Preferences.getStringValue(BEAST_MODE_ORDER_PREF);
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<>();
String[] itemsArray; String[] itemsArray;
if (order == null) { if (order == null) {
itemsArray = context.getResources().getStringArray(R.array.TEA_control_sets_prefs); itemsArray = context.getResources().getStringArray(R.array.TEA_control_sets_prefs);

@ -185,7 +185,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
startActivity(intent); startActivity(intent);
} }
private static final HashMap<Class<?>, Integer> PREFERENCE_REQUEST_CODES = new HashMap<Class<?>, Integer>(); private static final HashMap<Class<?>, Integer> PREFERENCE_REQUEST_CODES = new HashMap<>();
static { static {
PREFERENCE_REQUEST_CODES.put(SyncProviderPreferences.class, REQUEST_CODE_SYNC); PREFERENCE_REQUEST_CODES.put(SyncProviderPreferences.class, REQUEST_CODE_SYNC);
} }
@ -196,7 +196,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent, List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent,
PackageManager.GET_META_DATA); PackageManager.GET_META_DATA);
LinkedHashMap<String, ArrayList<Preference>> categoryPreferences = LinkedHashMap<String, ArrayList<Preference>> categoryPreferences =
new LinkedHashMap<String, ArrayList<Preference>>(); new LinkedHashMap<>();
// Loop through a list of all packages (including plugins, addons) // Loop through a list of all packages (including plugins, addons)
// that have a settings action // that have a settings action

@ -189,7 +189,7 @@ public class FilterListFragment extends ListFragment {
final Filter filter = adapter.getItem(position); final Filter filter = adapter.getItem(position);
final String[] labels = filter.contextMenuLabels; final String[] labels = filter.contextMenuLabels;
final Intent[] intents = filter.contextMenuIntents; final Intent[] intents = filter.contextMenuIntents;
ArrayAdapter<String> intentAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1); ArrayAdapter<String> intentAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1);
intentAdapter.add(getString(R.string.FLA_context_shortcut)); intentAdapter.add(getString(R.string.FLA_context_shortcut));
for (String l : labels) { for (String l : labels) {
intentAdapter.add(l); intentAdapter.add(l);

@ -184,7 +184,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
private EditText title; private EditText title;
private EditNoteActivity editNotes; private EditNoteActivity editNotes;
private ViewPager mPager; private ViewPager mPager;
private HashMap<String, TaskEditControlSet> controlSetMap = new HashMap<String, TaskEditControlSet>(); private HashMap<String, TaskEditControlSet> controlSetMap = new HashMap<>();
private final List<TaskEditControlSet> controls = Collections.synchronizedList(new ArrayList<TaskEditControlSet>()); private final List<TaskEditControlSet> controls = Collections.synchronizedList(new ArrayList<TaskEditControlSet>());
@ -353,7 +353,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
constructWhenDialog(whenDialogView); constructWhenDialog(whenDialogView);
controlSetMap = new HashMap<String, TaskEditControlSet>(); controlSetMap = new HashMap<>();
// populate control set // populate control set
EditTitleControlSet editTitle = new EditTitleControlSet(getActivity(), EditTitleControlSet editTitle = new EditTitleControlSet(getActivity(),
@ -829,11 +829,11 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
} }
private void startAttachFile() { private void startAttachFile() {
ArrayList<String> options = new ArrayList<String>(); ArrayList<String> options = new ArrayList<>();
options.add(getString(R.string.file_add_picture)); options.add(getString(R.string.file_add_picture));
options.add(getString(R.string.file_add_sdcard)); options.add(getString(R.string.file_add_sdcard));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(),
android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()])); android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()]));
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@ -893,7 +893,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
private void attachImage(Bitmap bitmap) { private void attachImage(Bitmap bitmap) {
AtomicReference<String> nameRef = new AtomicReference<String>(); AtomicReference<String> nameRef = new AtomicReference<>();
String path = FileUtilities.getNewImageAttachmentPath(getActivity(), nameRef); String path = FileUtilities.getNewImageAttachmentPath(getActivity(), nameRef);
try { try {

@ -23,7 +23,7 @@ public class TaskEditViewPager extends PagerAdapter {
public static final int TAB_SHOW_ACTIVITY = 1; public static final int TAB_SHOW_ACTIVITY = 1;
public TaskEditViewPager(Context context, int tabStyleMask) { public TaskEditViewPager(Context context, int tabStyleMask) {
ArrayList<String> titleList = new ArrayList<String>(); ArrayList<String> titleList = new ArrayList<>();
if ((tabStyleMask & TAB_SHOW_ACTIVITY) > 0) { if ((tabStyleMask & TAB_SHOW_ACTIVITY) > 0) {
titleList.add(context.getString(R.string.TEA_tab_activity)); titleList.add(context.getString(R.string.TEA_tab_activity));
} }

@ -159,7 +159,7 @@ public class TaskListFragment extends ListFragment implements OnSortSelectedList
protected TaskAdapter taskAdapter = null; protected TaskAdapter taskAdapter = null;
protected DetailReceiver detailReceiver = new DetailReceiver(); protected DetailReceiver detailReceiver = new DetailReceiver();
protected RefreshReceiver refreshReceiver = new RefreshReceiver(); protected RefreshReceiver refreshReceiver = new RefreshReceiver();
protected final AtomicReference<String> sqlQueryTemplate = new AtomicReference<String>(); protected final AtomicReference<String> sqlQueryTemplate = new AtomicReference<>();
protected SyncActionHelper syncActionHelper; protected SyncActionHelper syncActionHelper;
protected Filter filter; protected Filter filter;
protected int sortFlags; protected int sortFlags;

@ -122,7 +122,7 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
this.layout = rowLayout; this.layout = rowLayout;
this.skipIntentFilters = skipIntentFilters; this.skipIntentFilters = skipIntentFilters;
this.selectable = selectable; this.selectable = selectable;
this.filterCounts = new HashMap<Filter, Integer>(); this.filterCounts = new HashMap<>();
inflater = (LayoutInflater) activity.getSystemService( inflater = (LayoutInflater) activity.getSystemService(
Context.LAYOUT_INFLATER_SERVICE); Context.LAYOUT_INFLATER_SERVICE);

@ -189,7 +189,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
protected final Context context; protected final Context context;
protected final TaskListFragment fragment; protected final TaskListFragment fragment;
protected final Resources resources; protected final Resources resources;
protected final HashMap<Object, Boolean> completedItems = new HashMap<Object, Boolean>(0); protected final HashMap<Object, Boolean> completedItems = new HashMap<>(0);
protected OnCompletedTaskListener onCompletedTaskListener = null; protected OnCompletedTaskListener onCompletedTaskListener = null;
protected final int resource; protected final int resource;
protected final LayoutInflater inflater; protected final LayoutInflater inflater;
@ -563,7 +563,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
protected TaskRowListener listener = new TaskRowListener(); protected TaskRowListener listener = new TaskRowListener();
private Pair<Float, Float> lastTouchYRawY = new Pair<Float, Float>(0f, 0f); private Pair<Float, Float> lastTouchYRawY = new Pair<>(0f, 0f);
/** /**
* Set listeners for this view. This is called once per view when it is * Set listeners for this view. This is called once per view when it is
@ -576,7 +576,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
OnTouchListener otl = new OnTouchListener() { OnTouchListener otl = new OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
lastTouchYRawY = new Pair<Float, Float>(event.getY(), event.getRawY()); lastTouchYRawY = new Pair<>(event.getY(), event.getRawY());
return false; return false;
} }
}; };
@ -655,7 +655,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
* ============================================================== details * ============================================================== details
* ====================================================================== */ * ====================================================================== */
private final HashMap<String, Spanned> htmlCache = new HashMap<String, Spanned>(8); private final HashMap<String, Spanned> htmlCache = new HashMap<>(8);
private Spanned convertToHtml(String string, ImageGetter imageGetter) { private Spanned convertToHtml(String string, ImageGetter imageGetter) {
if(!htmlCache.containsKey(string)) { if(!htmlCache.containsKey(string)) {
@ -671,7 +671,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
return htmlCache.get(string); return htmlCache.get(string);
} }
private final HashMap<Long, String> dateCache = new HashMap<Long, String>(8); private final HashMap<Long, String> dateCache = new HashMap<>(8);
private String formatDate(long date) { private String formatDate(long date) {
if(dateCache.containsKey(date)) { if(dateCache.containsKey(date)) {
@ -812,18 +812,23 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
private final ImageGetter detailImageGetter = new ImageGetter() { private final ImageGetter detailImageGetter = new ImageGetter() {
private final HashMap<Integer, Drawable> cache = private final HashMap<Integer, Drawable> cache =
new HashMap<Integer, Drawable>(3); new HashMap<>(3);
@Override @Override
public Drawable getDrawable(String source) { public Drawable getDrawable(String source) {
int drawable = 0; int drawable = 0;
if(source.equals("silk_clock")) { switch (source) {
case "silk_clock":
drawable = R.drawable.details_alarm; drawable = R.drawable.details_alarm;
} else if(source.equals("silk_tag_pink")) { break;
case "silk_tag_pink":
drawable = R.drawable.details_tag; drawable = R.drawable.details_tag;
} else if(source.equals("silk_date")) { break;
case "silk_date":
drawable = R.drawable.details_repeat; drawable = R.drawable.details_repeat;
} else if(source.equals("silk_note")) { break;
case "silk_note":
drawable = R.drawable.details_note; drawable = R.drawable.details_note;
break;
} }
if (drawable == 0) { if (drawable == 0) {

@ -81,7 +81,7 @@ public final class AlarmControlSet extends TaskEditControlSet {
@Override @Override
protected void writeToModelAfterInitialized(Task task) { protected void writeToModelAfterInitialized(Task task) {
LinkedHashSet<Long> alarms = new LinkedHashSet<Long>(); LinkedHashSet<Long> alarms = new LinkedHashSet<>();
for(int i = 0; i < alertsContainer.getChildCount(); i++) { for(int i = 0; i < alertsContainer.getChildCount(); i++) {
Long dateValue = (Long) alertsContainer.getChildAt(i).getTag(); Long dateValue = (Long) alertsContainer.getChildAt(i).getTag();
if(dateValue == null) { if(dateValue == null) {

@ -72,7 +72,7 @@ public class AlarmService {
public boolean synchronizeAlarms(final long taskId, LinkedHashSet<Long> alarms) { public boolean synchronizeAlarms(final long taskId, LinkedHashSet<Long> alarms) {
MetadataService service = PluginServices.getMetadataService(); MetadataService service = PluginServices.getMetadataService();
ArrayList<Metadata> metadata = new ArrayList<Metadata>(); ArrayList<Metadata> metadata = new ArrayList<>();
for(Long alarm : alarms) { for(Long alarm : alarms) {
Metadata item = new Metadata(); Metadata item = new Metadata();
item.setValue(Metadata.KEY, AlarmFields.METADATA_KEY); item.setValue(Metadata.KEY, AlarmFields.METADATA_KEY);

@ -43,7 +43,7 @@ public class AlarmTaskRepeatListener extends BroadcastReceiver {
} }
Metadata metadata = new Metadata(); Metadata metadata = new Metadata();
LinkedHashSet<Long> alarms = new LinkedHashSet<Long>(cursor.getCount()); LinkedHashSet<Long> alarms = new LinkedHashSet<>(cursor.getCount());
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
metadata.readFromCursor(cursor); metadata.readFromCursor(cursor);
alarms.add(metadata.getValue(AlarmFields.TIME) + (newDueDate - oldDueDate)); alarms.add(metadata.getValue(AlarmFields.TIME) + (newDueDate - oldDueDate));

@ -285,11 +285,7 @@ public class TasksXmlExporter {
xml.attribute(null, property.name, valueString); xml.attribute(null, property.name, valueString);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
// didn't read this value, do nothing // didn't read this value, do nothing
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | IOException | IllegalStateException e) {
throw new RuntimeException(e);
} catch (IllegalStateException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return null; return null;
@ -303,11 +299,7 @@ public class TasksXmlExporter {
xml.attribute(null, property.name, valueString); xml.attribute(null, property.name, valueString);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
// didn't read this value, do nothing // didn't read this value, do nothing
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | IOException | IllegalStateException e) {
throw new RuntimeException(e);
} catch (IllegalStateException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return null; return null;
@ -323,11 +315,7 @@ public class TasksXmlExporter {
xml.attribute(null, property.name, value); xml.attribute(null, property.name, value);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
// didn't read this value, do nothing // didn't read this value, do nothing
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | IOException | IllegalStateException e) {
throw new RuntimeException(e);
} catch (IllegalStateException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return null; return null;

@ -121,10 +121,7 @@ public class TasksXmlImporter {
public void run() { public void run() {
try { try {
performImport(); performImport();
} catch (IOException e) { } catch (IOException | XmlPullParserException e) {
exceptionService.displayAndReportError(context,
context.getString(R.string.backup_TXI_error), e);
} catch (XmlPullParserException e) {
exceptionService.displayAndReportError(context, exceptionService.displayAndReportError(context,
context.getString(R.string.backup_TXI_error), e); context.getString(R.string.backup_TXI_error), e);
} }
@ -391,12 +388,16 @@ public class TasksXmlImporter {
} }
try { try {
if (tag.equals(BackupConstants.TASK_TAG)) { switch (tag) {
case BackupConstants.TASK_TAG:
parseTask(); parseTask();
} else if (tag.equals(BackupConstants.METADATA_TAG)) { break;
case BackupConstants.METADATA_TAG:
parseMetadata(3); parseMetadata(3);
} else if (tag.equals(BackupConstants.TAGDATA_TAG)) { break;
case BackupConstants.TAGDATA_TAG:
parseTagdata(); parseTagdata();
break;
} }
} catch (Exception e) { } catch (Exception e) {
errorCount++; errorCount++;
@ -424,7 +425,7 @@ public class TasksXmlImporter {
private String upgradeNotes = null; private String upgradeNotes = null;
private boolean syncOnComplete = false; private boolean syncOnComplete = false;
private final LinkedHashSet<String> tags = new LinkedHashSet<String>(); private final LinkedHashSet<String> tags = new LinkedHashSet<>();
public Format1TaskImporter(XmlPullParser xpp) throws XmlPullParserException, IOException { public Format1TaskImporter(XmlPullParser xpp) throws XmlPullParserException, IOException {
this.xpp = xpp; this.xpp = xpp;
@ -551,32 +552,33 @@ public class TasksXmlImporter {
/** helper method to set field on a task */ /** helper method to set field on a task */
private boolean setTaskField(Task task, String field, String value) { private boolean setTaskField(Task task, String field, String value) {
if(field.equals(LegacyTaskModel.ID)) { switch (field) {
case LegacyTaskModel.ID:
// ignore // ignore
} break;
else if(field.equals(LegacyTaskModel.NAME)) { case LegacyTaskModel.NAME:
task.setValue(Task.TITLE, value); task.setValue(Task.TITLE, value);
} break;
else if(field.equals(LegacyTaskModel.NOTES)) { case LegacyTaskModel.NOTES:
task.setValue(Task.NOTES, value); task.setValue(Task.NOTES, value);
} break;
else if(field.equals(LegacyTaskModel.PROGRESS_PERCENTAGE)) { case LegacyTaskModel.PROGRESS_PERCENTAGE:
// ignore // ignore
} break;
else if(field.equals(LegacyTaskModel.IMPORTANCE)) { case LegacyTaskModel.IMPORTANCE:
task.setValue(Task.IMPORTANCE, LegacyImportance.valueOf(value).ordinal()); task.setValue(Task.IMPORTANCE, LegacyImportance.valueOf(value).ordinal());
} break;
else if(field.equals(LegacyTaskModel.ESTIMATED_SECONDS)) { case LegacyTaskModel.ESTIMATED_SECONDS:
task.setValue(Task.ESTIMATED_SECONDS, Integer.parseInt(value)); task.setValue(Task.ESTIMATED_SECONDS, Integer.parseInt(value));
} break;
else if(field.equals(LegacyTaskModel.ELAPSED_SECONDS)) { case LegacyTaskModel.ELAPSED_SECONDS:
task.setValue(Task.ELAPSED_SECONDS, Integer.parseInt(value)); task.setValue(Task.ELAPSED_SECONDS, Integer.parseInt(value));
} break;
else if(field.equals(LegacyTaskModel.TIMER_START)) { case LegacyTaskModel.TIMER_START:
task.setValue(Task.TIMER_START, task.setValue(Task.TIMER_START,
BackupDateUtilities.getDateFromIso8601String(value).getTime()); BackupDateUtilities.getDateFromIso8601String(value).getTime());
} break;
else if(field.equals(LegacyTaskModel.DEFINITE_DUE_DATE)) { case LegacyTaskModel.DEFINITE_DUE_DATE:
String preferred = xpp.getAttributeValue(null, LegacyTaskModel.PREFERRED_DUE_DATE); String preferred = xpp.getAttributeValue(null, LegacyTaskModel.PREFERRED_DUE_DATE);
if (preferred != null) { if (preferred != null) {
Date preferredDate = BackupDateUtilities.getDateFromIso8601String(value); Date preferredDate = BackupDateUtilities.getDateFromIso8601String(value);
@ -585,8 +587,8 @@ public class TasksXmlImporter {
} }
task.setValue(Task.DUE_DATE, task.setValue(Task.DUE_DATE,
BackupDateUtilities.getTaskDueDateFromIso8601String(value).getTime()); BackupDateUtilities.getTaskDueDateFromIso8601String(value).getTime());
} break;
else if(field.equals(LegacyTaskModel.PREFERRED_DUE_DATE)) { case LegacyTaskModel.PREFERRED_DUE_DATE:
String definite = xpp.getAttributeValue(null, LegacyTaskModel.DEFINITE_DUE_DATE); String definite = xpp.getAttributeValue(null, LegacyTaskModel.DEFINITE_DUE_DATE);
if (definite != null) { if (definite != null) {
// handled above // handled above
@ -594,42 +596,42 @@ public class TasksXmlImporter {
task.setValue(Task.DUE_DATE, task.setValue(Task.DUE_DATE,
BackupDateUtilities.getTaskDueDateFromIso8601String(value).getTime()); BackupDateUtilities.getTaskDueDateFromIso8601String(value).getTime());
} }
} break;
else if(field.equals(LegacyTaskModel.HIDDEN_UNTIL)) { case LegacyTaskModel.HIDDEN_UNTIL:
task.setValue(Task.HIDE_UNTIL, task.setValue(Task.HIDE_UNTIL,
BackupDateUtilities.getDateFromIso8601String(value).getTime()); BackupDateUtilities.getDateFromIso8601String(value).getTime());
} break;
else if(field.equals(LegacyTaskModel.BLOCKING_ON)) { case LegacyTaskModel.BLOCKING_ON:
// ignore // ignore
} break;
else if(field.equals(LegacyTaskModel.POSTPONE_COUNT)) { case LegacyTaskModel.POSTPONE_COUNT:
task.setValue(Task.POSTPONE_COUNT, Integer.parseInt(value)); task.setValue(Task.POSTPONE_COUNT, Integer.parseInt(value));
} break;
else if(field.equals(LegacyTaskModel.NOTIFICATIONS)) { case LegacyTaskModel.NOTIFICATIONS:
task.setValue(Task.REMINDER_PERIOD, Integer.parseInt(value) * 1000L); task.setValue(Task.REMINDER_PERIOD, Integer.parseInt(value) * 1000L);
} break;
else if(field.equals(LegacyTaskModel.CREATION_DATE)) { case LegacyTaskModel.CREATION_DATE:
task.setValue(Task.CREATION_DATE, task.setValue(Task.CREATION_DATE,
BackupDateUtilities.getDateFromIso8601String(value).getTime()); BackupDateUtilities.getDateFromIso8601String(value).getTime());
} break;
else if(field.equals(LegacyTaskModel.COMPLETION_DATE)) { case LegacyTaskModel.COMPLETION_DATE:
String completion = xpp.getAttributeValue(null, LegacyTaskModel.PROGRESS_PERCENTAGE); String completion = xpp.getAttributeValue(null, LegacyTaskModel.PROGRESS_PERCENTAGE);
if ("100".equals(completion)) { if ("100".equals(completion)) {
task.setValue(Task.COMPLETION_DATE, task.setValue(Task.COMPLETION_DATE,
BackupDateUtilities.getDateFromIso8601String(value).getTime()); BackupDateUtilities.getDateFromIso8601String(value).getTime());
} }
} break;
else if(field.equals(LegacyTaskModel.NOTIFICATION_FLAGS)) { case LegacyTaskModel.NOTIFICATION_FLAGS:
task.setValue(Task.REMINDER_FLAGS, Integer.parseInt(value)); task.setValue(Task.REMINDER_FLAGS, Integer.parseInt(value));
} break;
else if(field.equals(LegacyTaskModel.LAST_NOTIFIED)) { case LegacyTaskModel.LAST_NOTIFIED:
task.setValue(Task.REMINDER_LAST, task.setValue(Task.REMINDER_LAST,
BackupDateUtilities.getDateFromIso8601String(value).getTime()); BackupDateUtilities.getDateFromIso8601String(value).getTime());
} break;
else if(field.equals("repeat_interval")) { case "repeat_interval":
// handled below // handled below
} break;
else if(field.equals("repeat_value")) { case "repeat_value":
int repeatValue = Integer.parseInt(value); int repeatValue = Integer.parseInt(value);
String repeatInterval = xpp.getAttributeValue(null, "repeat_interval"); String repeatInterval = xpp.getAttributeValue(null, "repeat_interval");
if (repeatValue > 0 && repeatInterval != null) { if (repeatValue > 0 && repeatInterval != null) {
@ -638,13 +640,13 @@ public class TasksXmlImporter {
RRule rrule = repeatInfo.toRRule(); RRule rrule = repeatInfo.toRRule();
task.setValue(Task.RECURRENCE, rrule.toIcal()); task.setValue(Task.RECURRENCE, rrule.toIcal());
} }
} break;
else if(field.equals(LegacyTaskModel.FLAGS)) { case LegacyTaskModel.FLAGS:
if (Integer.parseInt(value) == LegacyTaskModel.FLAG_SYNC_ON_COMPLETE) { if (Integer.parseInt(value) == LegacyTaskModel.FLAG_SYNC_ON_COMPLETE) {
syncOnComplete = true; syncOnComplete = true;
} }
} break;
else { default:
return false; return false;
} }

@ -57,7 +57,7 @@ public final class CoreFilterExposer extends BroadcastReceiver implements Astrid
private FilterListItem[] prepareFilters(Resources r) { private FilterListItem[] prepareFilters(Resources r) {
// core filters // core filters
List<FilterListItem> filters = new ArrayList<FilterListItem>(3); List<FilterListItem> filters = new ArrayList<>(3);
filters.add(buildInboxFilter(r)); filters.add(buildInboxFilter(r));
if (Preferences.getBoolean(R.string.p_show_today_filter, true)) { if (Preferences.getBoolean(R.string.p_show_today_filter, true)) {

@ -168,7 +168,7 @@ public class CustomFilterActivity extends ActionBarActivity {
populateCriteria(); populateCriteria();
filterName = (TextView)findViewById(R.id.filterName); filterName = (TextView)findViewById(R.id.filterName);
List<CriterionInstance> startingCriteria = new ArrayList<CriterionInstance>(); List<CriterionInstance> startingCriteria = new ArrayList<>();
startingCriteria.add(getStartingUniverse()); startingCriteria.add(getStartingUniverse());
adapter = new CustomFilterAdapter(this, startingCriteria); adapter = new CustomFilterAdapter(this, startingCriteria);
listView.setAdapter(adapter); listView.setAdapter(adapter);

@ -113,7 +113,7 @@ public class CustomFilterAdapter extends ArrayAdapter<CriterionInstance> {
if(item.criterion instanceof MultipleSelectCriterion) { if(item.criterion instanceof MultipleSelectCriterion) {
MultipleSelectCriterion multiSelectCriterion = (MultipleSelectCriterion) item.criterion; MultipleSelectCriterion multiSelectCriterion = (MultipleSelectCriterion) item.criterion;
final String[] titles = multiSelectCriterion.entryTitles; final String[] titles = multiSelectCriterion.entryTitles;
ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, ArrayAdapter<String> adapter = new ArrayAdapter<>(activity,
android.R.layout.simple_spinner_dropdown_item, titles); android.R.layout.simple_spinner_dropdown_item, titles);
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override @Override

@ -74,7 +74,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
StoreObject.TYPE.eq(SavedFilter.TYPE)).orderBy(Order.asc(SavedFilter.NAME))); StoreObject.TYPE.eq(SavedFilter.TYPE)).orderBy(Order.asc(SavedFilter.NAME)));
} }
try { try {
ArrayList<Filter> list = new ArrayList<Filter>(); ArrayList<Filter> list = new ArrayList<>();
// stock filters // stock filters
if (Preferences.getBoolean(R.string.p_show_recently_modified_filter, true)) { if (Preferences.getBoolean(R.string.p_show_recently_modified_filter, true)) {

@ -114,7 +114,7 @@ public class LinkActionExposer {
return new TaskAction(PendingIntent.getActivity(context, (int)id, actionIntent, 0), (BitmapDrawable)icon); return new TaskAction(PendingIntent.getActivity(context, (int)id, actionIntent, 0), (BitmapDrawable)icon);
} }
private static final HashMap<Integer, BitmapDrawable> IMAGE_CACHE = new HashMap<Integer, BitmapDrawable>(); private static final HashMap<Integer, BitmapDrawable> IMAGE_CACHE = new HashMap<>();
private static BitmapDrawable getBitmapDrawable(int resId, Resources resources) { private static BitmapDrawable getBitmapDrawable(int resId, Resources resources) {
if (IMAGE_CACHE.containsKey(resId)) { if (IMAGE_CACHE.containsKey(resId)) {

@ -79,7 +79,7 @@ public class MetadataDao extends DatabaseDao<Metadata> {
*/ */
public void synchronizeMetadata(long taskId, ArrayList<Metadata> metadata, public void synchronizeMetadata(long taskId, ArrayList<Metadata> metadata,
Criterion metadataCriteria) { Criterion metadataCriteria) {
HashSet<ContentValues> newMetadataValues = new HashSet<ContentValues>(); HashSet<ContentValues> newMetadataValues = new HashSet<>();
for(Metadata metadatum : metadata) { for(Metadata metadatum : metadata) {
metadatum.setValue(Metadata.TASK, taskId); metadatum.setValue(Metadata.TASK, taskId);
metadatum.clearValue(Metadata.ID); metadatum.clearValue(Metadata.ID);
@ -142,7 +142,7 @@ public class MetadataDao extends DatabaseDao<Metadata> {
Query sql = Query.select(properties).from(Metadata.TABLE).join(Join.left(Task.TABLE, Query sql = Query.select(properties).from(Metadata.TABLE).join(Join.left(Task.TABLE,
Metadata.TASK.eq(Task.ID))).where(Task.TITLE.isNull()); Metadata.TASK.eq(Task.ID))).where(Task.TITLE.isNull());
Cursor cursor = database.rawQuery(sql.toString()); Cursor cursor = database.rawQuery(sql.toString());
return new TodorooCursor<Metadata>(cursor, properties); return new TodorooCursor<>(cursor, properties);
} }
} }

@ -49,7 +49,7 @@ public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE
TodorooCursor<RTYPE> cursor = query( TodorooCursor<RTYPE> cursor = query(
Query.select(properties).where(RemoteModel.UUID_PROPERTY.eq(uuid))); Query.select(properties).where(RemoteModel.UUID_PROPERTY.eq(uuid)));
cursor.moveToFirst(); cursor.moveToFirst();
return new TodorooCursor<RTYPE>(cursor, properties); return new TodorooCursor<>(cursor, properties);
} }
public String uuidFromLocalId(long localId) { public String uuidFromLocalId(long localId) {

@ -89,10 +89,10 @@ public class TagMetadataDao extends DatabaseDao<TagMetadata> {
public void synchronizeMembers(TagData tagData, String legacyMembersString, String tagUuid, JSONArray members) { public void synchronizeMembers(TagData tagData, String legacyMembersString, String tagUuid, JSONArray members) {
long tagId = tagData.getId(); long tagId = tagData.getId();
Set<String> emails = new HashSet<String>(); Set<String> emails = new HashSet<>();
Set<String> ids = new HashSet<String>(); Set<String> ids = new HashSet<>();
HashMap<String, String> idToEmail = new HashMap<String, String>(); HashMap<String, String> idToEmail = new HashMap<>();
for (int i = 0; i < members.length(); i++) { for (int i = 0; i < members.length(); i++) {
JSONObject person = members.optJSONObject(i); JSONObject person = members.optJSONObject(i);

@ -87,7 +87,7 @@ public class AACRecordingActivity extends Activity implements AACRecorderCallbac
public void encodingFinished() { public void encodingFinished() {
try { try {
AtomicReference<String> nameRef = new AtomicReference<String>(); AtomicReference<String> nameRef = new AtomicReference<>();
String outFile = FileUtilities.getNewAudioAttachmentPath(this, nameRef); String outFile = FileUtilities.getNewAudioAttachmentPath(this, nameRef);
new AACToM4A().convert(this, tempFile, outFile); new AACToM4A().convert(this, tempFile, outFile);

@ -37,7 +37,7 @@ import java.util.ArrayList;
public class FileExplore extends Activity { public class FileExplore extends Activity {
// Stores names of traversed directories // Stores names of traversed directories
ArrayList<String> str = new ArrayList<String>(); ArrayList<String> str = new ArrayList<>();
// Check if the first level of the directory structure is the one showing // Check if the first level of the directory structure is the one showing
private Boolean firstLvl = true; private Boolean firstLvl = true;

@ -57,7 +57,7 @@ public class FilesControlSet extends PopupControlSet {
@Autowired @Autowired
private TaskAttachmentDao taskAttachmentDao; private TaskAttachmentDao taskAttachmentDao;
private final ArrayList<TaskAttachment> files = new ArrayList<TaskAttachment>(); private final ArrayList<TaskAttachment> files = new ArrayList<>();
private final LinearLayout fileDisplayList; private final LinearLayout fileDisplayList;
private final LayoutInflater inflater; private final LayoutInflater inflater;
private final ImageView image; private final ImageView image;

@ -113,11 +113,11 @@ public class CalendarAlarmReceiver extends BroadcastReceiver {
int emailIndex = attendees.getColumnIndexOrThrow(Calendars.ATTENDEES_EMAIL_COL); int emailIndex = attendees.getColumnIndexOrThrow(Calendars.ATTENDEES_EMAIL_COL);
int nameIndex = attendees.getColumnIndexOrThrow(Calendars.ATTENDEES_NAME_COL); int nameIndex = attendees.getColumnIndexOrThrow(Calendars.ATTENDEES_NAME_COL);
ArrayList<String> names = new ArrayList<String>(); ArrayList<String> names = new ArrayList<>();
ArrayList<String> emails = new ArrayList<String>(); ArrayList<String> emails = new ArrayList<>();
Account[] accountArray = AccountManager.get(context).getAccounts(); Account[] accountArray = AccountManager.get(context).getAccounts();
Set<String> phoneAccounts = new HashSet<String>(); Set<String> phoneAccounts = new HashSet<>();
for (Account a : accountArray) { for (Account a : accountArray) {
phoneAccounts.add(a.name); phoneAccounts.add(a.name);
} }

@ -71,11 +71,12 @@ public class Calendars {
} }
private static Uri getIcsUri(String table) { private static Uri getIcsUri(String table) {
if (CALENDAR_CONTENT_CALENDARS.equals(table)) { switch (table) {
case CALENDAR_CONTENT_CALENDARS:
return CalendarContract.Calendars.CONTENT_URI; return CalendarContract.Calendars.CONTENT_URI;
} else if (CALENDAR_CONTENT_EVENTS.equals(table)) { case CALENDAR_CONTENT_EVENTS:
return CalendarContract.Events.CONTENT_URI; return CalendarContract.Events.CONTENT_URI;
} else if (CALENDAR_CONTENT_ATTENDEES.equals(table)) { case CALENDAR_CONTENT_ATTENDEES:
return CalendarContract.Attendees.CONTENT_URI; return CalendarContract.Attendees.CONTENT_URI;
} }
return null; return null;
@ -179,11 +180,11 @@ public class Calendars {
int currentSettingIndex = -1; int currentSettingIndex = -1;
ArrayList<CharSequence> entries = new ArrayList<CharSequence>(); ArrayList<CharSequence> entries = new ArrayList<>();
entries.addAll(Arrays.asList(r.getStringArray(R.array.EPr_default_addtocalendar))); entries.addAll(Arrays.asList(r.getStringArray(R.array.EPr_default_addtocalendar)));
entries.addAll(Arrays.asList(calendars.calendars)); entries.addAll(Arrays.asList(calendars.calendars));
ArrayList<CharSequence> entryValues = new ArrayList<CharSequence>(); ArrayList<CharSequence> entryValues = new ArrayList<>();
entryValues.addAll(Arrays.asList(r.getStringArray(R.array.EPr_default_addtocalendar_values))); entryValues.addAll(Arrays.asList(r.getStringArray(R.array.EPr_default_addtocalendar_values)));
entryValues.addAll(Arrays.asList(calendars.calendarIds)); entryValues.addAll(Arrays.asList(calendars.calendarIds));

@ -73,11 +73,11 @@ public class GCalControlSet extends PopupControlSet {
((LinearLayout) getDisplayView()).addView(getView()); //hack for spinner ((LinearLayout) getDisplayView()).addView(getView()); //hack for spinner
this.calendarSelector = (Spinner) getView().findViewById(R.id.calendars); this.calendarSelector = (Spinner) getView().findViewById(R.id.calendars);
ArrayList<String> items = new ArrayList<String>(); ArrayList<String> items = new ArrayList<>();
Collections.addAll(items, calendars.calendars); Collections.addAll(items, calendars.calendars);
items.add(0, activity.getString(R.string.gcal_TEA_nocal)); items.add(0, activity.getString(R.string.gcal_TEA_nocal));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, ArrayAdapter<String> adapter = new ArrayAdapter<>(activity,
android.R.layout.simple_spinner_item, items.toArray(new String[items.size()])); android.R.layout.simple_spinner_item, items.toArray(new String[items.size()]));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

@ -55,7 +55,7 @@ public class GtasksListFragment extends SubtasksListFragment {
@Override @Override
protected OrderedListFragmentHelperInterface<?> createFragmentHelper() { protected OrderedListFragmentHelperInterface<?> createFragmentHelper() {
return new OrderedMetadataListFragmentHelper<StoreObject>(this, gtasksTaskListUpdater); return new OrderedMetadataListFragmentHelper<>(this, gtasksTaskListUpdater);
} }
@Override @Override

@ -76,7 +76,7 @@ public class GtasksListService {
public synchronized void updateLists(TaskLists remoteLists) { public synchronized void updateLists(TaskLists remoteLists) {
readLists(); readLists();
HashSet<Long> previousLists = new HashSet<Long>(lists.length); HashSet<Long> previousLists = new HashSet<>(lists.length);
for(StoreObject list : lists) { for(StoreObject list : lists) {
previousLists.add(list.getId()); previousLists.add(list.getId());
} }

@ -107,7 +107,7 @@ public final class GtasksMetadataService extends SyncMetadataService<GtasksTaskC
@Override @Override
protected TodorooCursor<Task> filterLocallyUpdated(TodorooCursor<Task> tasks, long lastSyncDate) { protected TodorooCursor<Task> filterLocallyUpdated(TodorooCursor<Task> tasks, long lastSyncDate) {
HashSet<Long> taskIds = new HashSet<Long>(); HashSet<Long> taskIds = new HashSet<>();
for(tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) { for(tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) {
taskIds.add(tasks.get(Task.ID)); taskIds.add(tasks.get(Task.ID));
} }
@ -182,7 +182,7 @@ public final class GtasksMetadataService extends SyncMetadataService<GtasksTaskC
public String getRemoteSiblingId(String listId, Metadata gtasksMetadata) { public String getRemoteSiblingId(String listId, Metadata gtasksMetadata) {
final AtomicInteger indentToMatch = new AtomicInteger(gtasksMetadata.getValue(GtasksMetadata.INDENT)); final AtomicInteger indentToMatch = new AtomicInteger(gtasksMetadata.getValue(GtasksMetadata.INDENT));
final AtomicLong parentToMatch = new AtomicLong(gtasksMetadata.getValue(GtasksMetadata.PARENT_TASK)); final AtomicLong parentToMatch = new AtomicLong(gtasksMetadata.getValue(GtasksMetadata.PARENT_TASK));
final AtomicReference<String> sibling = new AtomicReference<String>(); final AtomicReference<String> sibling = new AtomicReference<>();
OrderedListIterator iterator = new OrderedListIterator() { OrderedListIterator iterator = new OrderedListIterator() {
@Override @Override
public void processTask(long taskId, Metadata metadata) { public void processTask(long taskId, Metadata metadata) {

@ -32,13 +32,13 @@ import java.util.concurrent.atomic.AtomicLong;
public class GtasksTaskListUpdater extends OrderedMetadataListUpdater<StoreObject> { public class GtasksTaskListUpdater extends OrderedMetadataListUpdater<StoreObject> {
/** map of task -> parent task */ /** map of task -> parent task */
final HashMap<Long, Long> parents = new HashMap<Long, Long>(); final HashMap<Long, Long> parents = new HashMap<>();
/** map of task -> prior sibling */ /** map of task -> prior sibling */
final HashMap<Long, Long> siblings = new HashMap<Long, Long>(); final HashMap<Long, Long> siblings = new HashMap<>();
final HashMap<Long, String> localToRemoteIdMap = final HashMap<Long, String> localToRemoteIdMap =
new HashMap<Long, String>(); new HashMap<>();
@Autowired private GtasksListService gtasksListService; @Autowired private GtasksListService gtasksListService;
@Autowired private GtasksMetadataService gtasksMetadataService; @Autowired private GtasksMetadataService gtasksMetadataService;

@ -82,14 +82,14 @@ public class GtasksLoginActivity extends ListActivity {
accountManager = new GoogleAccountManager(this); accountManager = new GoogleAccountManager(this);
Account[] accounts = accountManager.getAccounts(); Account[] accounts = accountManager.getAccounts();
ArrayList<String> accountNames = new ArrayList<String>(); ArrayList<String> accountNames = new ArrayList<>();
for (Account a : accounts) { for (Account a : accounts) {
accountNames.add(a.name); accountNames.add(a.name);
} }
nameArray = accountNames.toArray(new String[accountNames.size()]); nameArray = accountNames.toArray(new String[accountNames.size()]);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, nameArray)); setListAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, nameArray));
findViewById(R.id.empty_button).setOnClickListener(new OnClickListener() { findViewById(R.id.empty_button).setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

@ -48,7 +48,7 @@ public final class GtasksSyncService {
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
} }
private final LinkedBlockingQueue<SyncOnSaveOperation> operationQueue = new LinkedBlockingQueue<SyncOnSaveOperation>(); private final LinkedBlockingQueue<SyncOnSaveOperation> operationQueue = new LinkedBlockingQueue<>();
private abstract class SyncOnSaveOperation { private abstract class SyncOnSaveOperation {
abstract public void op(GtasksInvoker invoker) throws IOException; abstract public void op(GtasksInvoker invoker) throws IOException;

@ -242,7 +242,7 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
List<com.google.api.services.tasks.model.Task> tasks = taskList.getItems(); List<com.google.api.services.tasks.model.Task> tasks = taskList.getItems();
if (tasks != null) { if (tasks != null) {
callback.incrementMax(tasks.size() * 10); callback.incrementMax(tasks.size() * 10);
HashSet<Long> localIds = new HashSet<Long>(tasks.size()); HashSet<Long> localIds = new HashSet<>(tasks.size());
for (com.google.api.services.tasks.model.Task t : tasks) { for (com.google.api.services.tasks.model.Task t : tasks) {
GtasksTaskContainer container = parseRemoteTask(t, listId); GtasksTaskContainer container = parseRemoteTask(t, listId);
gtasksMetadataService.findLocalMatch(container); gtasksMetadataService.findLocalMatch(container);
@ -287,7 +287,7 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
private GtasksTaskContainer parseRemoteTask(com.google.api.services.tasks.model.Task remoteTask, String listId) { private GtasksTaskContainer parseRemoteTask(com.google.api.services.tasks.model.Task remoteTask, String listId) {
Task task = new Task(); Task task = new Task();
ArrayList<Metadata> metadata = new ArrayList<Metadata>(); ArrayList<Metadata> metadata = new ArrayList<>();
task.setValue(Task.TITLE, remoteTask.getTitle()); task.setValue(Task.TITLE, remoteTask.getTitle());
task.setValue(Task.CREATION_DATE, DateUtilities.now()); task.setValue(Task.CREATION_DATE, DateUtilities.now());

@ -54,7 +54,7 @@ public class SyncActionHelper {
public static final String PREF_LAST_AUTO_SYNC = "taskListLastAutoSync"; //$NON-NLS-1$ public static final String PREF_LAST_AUTO_SYNC = "taskListLastAutoSync"; //$NON-NLS-1$
private final LinkedHashSet<SyncAction> syncActions = new LinkedHashSet<SyncAction>(); private final LinkedHashSet<SyncAction> syncActions = new LinkedHashSet<>();
public final SyncResultCallback syncResultCallback; public final SyncResultCallback syncResultCallback;
@ -179,7 +179,7 @@ public class SyncActionHelper {
PackageManager pm = activity.getPackageManager(); PackageManager pm = activity.getPackageManager();
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities( List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(
queryIntent, PackageManager.GET_META_DATA); queryIntent, PackageManager.GET_META_DATA);
ArrayList<Intent> syncIntents = new ArrayList<Intent>(); ArrayList<Intent> syncIntents = new ArrayList<>();
// Loop through a list of all packages (including plugins, addons) // Loop through a list of all packages (including plugins, addons)
// that have a settings action: filter to sync actions // that have a settings action: filter to sync actions
@ -239,7 +239,7 @@ public class SyncActionHelper {
return; return;
} }
ArrayAdapter<TYPE> adapter = new ArrayAdapter<TYPE>(activity, ArrayAdapter<TYPE> adapter = new ArrayAdapter<>(activity,
android.R.layout.simple_spinner_dropdown_item, items); android.R.layout.simple_spinner_dropdown_item, items);
// show a menu of available options // show a menu of available options

@ -75,7 +75,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
@Autowired UserActivityDao userActivityDao; @Autowired UserActivityDao userActivityDao;
@Autowired TaskService taskService; @Autowired TaskService taskService;
private final ArrayList<NoteOrUpdate> items = new ArrayList<NoteOrUpdate>(); private final ArrayList<NoteOrUpdate> items = new ArrayList<>();
private EditText commentField; private EditText commentField;
private final View commentsBar; private final View commentsBar;
private View timerView; private View timerView;
@ -93,7 +93,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
private static boolean respondToPicture = false; private static boolean respondToPicture = false;
private final List<UpdatesChangedListener> listeners = new LinkedList<UpdatesChangedListener>(); private final List<UpdatesChangedListener> listeners = new LinkedList<>();
public interface UpdatesChangedListener { public interface UpdatesChangedListener {
public void updatesChanged(); public void updatesChanged();

@ -179,25 +179,25 @@ public class Astrid3ContentProvider extends ContentProvider {
private UriHelper<?> generateHelper(Uri uri, boolean populateModel) { private UriHelper<?> generateHelper(Uri uri, boolean populateModel) {
if(uri.toString().startsWith(Task.CONTENT_URI.toString())) { if(uri.toString().startsWith(Task.CONTENT_URI.toString())) {
UriHelper<Task> helper = new UriHelper<Task>(); UriHelper<Task> helper = new UriHelper<>();
helper.model = populateModel ? new Task() : null; helper.model = populateModel ? new Task() : null;
helper.dao = taskDao; helper.dao = taskDao;
helper.dao.setDatabase(getDatabase()); helper.dao.setDatabase(getDatabase());
return helper; return helper;
} else if(uri.toString().startsWith(Metadata.CONTENT_URI.toString())) { } else if(uri.toString().startsWith(Metadata.CONTENT_URI.toString())) {
UriHelper<Metadata> helper = new UriHelper<Metadata>(); UriHelper<Metadata> helper = new UriHelper<>();
helper.model = populateModel ? new Metadata() : null; helper.model = populateModel ? new Metadata() : null;
helper.dao = metadataDao; helper.dao = metadataDao;
helper.dao.setDatabase(getDatabase()); helper.dao.setDatabase(getDatabase());
return helper; return helper;
} else if(uri.toString().startsWith(StoreObject.CONTENT_URI.toString())) { } else if(uri.toString().startsWith(StoreObject.CONTENT_URI.toString())) {
UriHelper<StoreObject> helper = new UriHelper<StoreObject>(); UriHelper<StoreObject> helper = new UriHelper<>();
helper.model = populateModel ? new StoreObject() : null; helper.model = populateModel ? new StoreObject() : null;
helper.dao = storeObjectDao; helper.dao = storeObjectDao;
helper.dao.setDatabase(getDatabase()); helper.dao.setDatabase(getDatabase());
return helper; return helper;
} else if(uri.toString().startsWith(UserActivity.CONTENT_URI.toString())) { } else if(uri.toString().startsWith(UserActivity.CONTENT_URI.toString())) {
UriHelper<UserActivity> helper = new UriHelper<UserActivity>(); UriHelper<UserActivity> helper = new UriHelper<>();
helper.model = populateModel ? new UserActivity() : null; helper.model = populateModel ? new UserActivity() : null;
helper.dao = userActivityDao; helper.dao = userActivityDao;
helper.dao.setDatabase(getDatabase()); helper.dao.setDatabase(getDatabase());
@ -358,7 +358,7 @@ public class Astrid3ContentProvider extends ContentProvider {
ContentValues setValues = model.getSetValues(); ContentValues setValues = model.getSetValues();
if (setValues != null) { if (setValues != null) {
Set<Entry<String, Object>> entries = setValues.valueSet(); Set<Entry<String, Object>> entries = setValues.valueSet();
Set<String> keysToRemove = new HashSet<String>(); Set<String> keysToRemove = new HashSet<>();
for (Entry<String, Object> entry: entries) { for (Entry<String, Object> entry: entries) {
String key = entry.getKey(); String key = entry.getKey();
if (key.startsWith(AbstractModel.RETAIN_TRANSITORY_PREFIX)) { if (key.startsWith(AbstractModel.RETAIN_TRANSITORY_PREFIX)) {

@ -83,7 +83,7 @@ public class RepeatControlSet extends PopupControlSet {
private long repeatUntilValue; private long repeatUntilValue;
private final List<RepeatChangedListener> listeners = new LinkedList<RepeatChangedListener>(); private final List<RepeatChangedListener> listeners = new LinkedList<>();
public interface RepeatChangedListener { public interface RepeatChangedListener {
public void repeatChanged(boolean repeat); public void repeatChanged(boolean repeat);
@ -333,7 +333,7 @@ public class RepeatControlSet extends PopupControlSet {
case INTERVAL_WEEKS: { case INTERVAL_WEEKS: {
rrule.setFreq(Frequency.WEEKLY); rrule.setFreq(Frequency.WEEKLY);
ArrayList<WeekdayNum> days = new ArrayList<WeekdayNum>(); ArrayList<WeekdayNum> days = new ArrayList<>();
for (CompoundButton dayOfWeek : daysOfWeek) { for (CompoundButton dayOfWeek : daysOfWeek) {
if (dayOfWeek.isChecked()) { if (dayOfWeek.isChecked()) {
days.add(new WeekdayNum(0, (Weekday) dayOfWeek.getTag())); days.add(new WeekdayNum(0, (Weekday) dayOfWeek.getTag()));

@ -102,7 +102,7 @@ public class MetadataService {
public boolean synchronizeMetadata(long taskId, ArrayList<Metadata> metadata, public boolean synchronizeMetadata(long taskId, ArrayList<Metadata> metadata,
Criterion metadataCriterion, SynchronizeMetadataCallback callback) { Criterion metadataCriterion, SynchronizeMetadataCallback callback) {
boolean dirty = false; boolean dirty = false;
HashSet<ContentValues> newMetadataValues = new HashSet<ContentValues>(); HashSet<ContentValues> newMetadataValues = new HashSet<>();
for(Metadata metadatum : metadata) { for(Metadata metadatum : metadata) {
metadatum.setValue(Metadata.TASK, taskId); metadatum.setValue(Metadata.TASK, taskId);
metadatum.clearValue(Metadata.CREATION_DATE); metadatum.clearValue(Metadata.CREATION_DATE);

@ -36,7 +36,7 @@ public class SyncV2Service {
* Returns active sync providers * Returns active sync providers
*/ */
public List<SyncV2Provider> activeProviders() { public List<SyncV2Provider> activeProviders() {
ArrayList<SyncV2Provider> actives = new ArrayList<SyncV2Provider>(); ArrayList<SyncV2Provider> actives = new ArrayList<>();
for(SyncV2Provider provider : providers) { for(SyncV2Provider provider : providers) {
if(provider.isActive()) { if(provider.isActive()) {
actives.add(provider); actives.add(provider);

@ -383,7 +383,7 @@ public class TaskService {
task.setValue(Task.TITLE, title); task.setValue(Task.TITLE, title);
} }
ArrayList<String> tags = new ArrayList<String>(); ArrayList<String> tags = new ArrayList<>();
boolean quickAddMarkup = false; boolean quickAddMarkup = false;
try { try {
quickAddMarkup = parseQuickAddMarkup(task, tags); quickAddMarkup = parseQuickAddMarkup(task, tags);

@ -48,10 +48,7 @@ public class UpdateScreenFlow extends Activity {
Class<?> activityClass = Class.forName(className); Class<?> activityClass = Class.forName(className);
Intent intent = new Intent(this, activityClass); Intent intent = new Intent(this, activityClass);
startActivityForResult(intent, REQUEST_CODE_SCREEN_FLOW); startActivityForResult(intent, REQUEST_CODE_SCREEN_FLOW);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException | ActivityNotFoundException e) {
e.printStackTrace();
finish();
} catch (ActivityNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
finish(); finish();
} }

@ -261,7 +261,7 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
return; return;
} }
final ArrayList<String> chained = new ArrayList<String>(); final ArrayList<String> chained = new ArrayList<>();
updater.applyToDescendants(itemId, new AstridOrderedListUpdater.OrderedListNodeVisitor() { updater.applyToDescendants(itemId, new AstridOrderedListUpdater.OrderedListNodeVisitor() {
@Override @Override
public void visitNode(AstridOrderedListUpdater.Node node) { public void visitNode(AstridOrderedListUpdater.Node node) {

@ -26,7 +26,7 @@ public abstract class AstridOrderedListUpdater<LIST> {
public AstridOrderedListUpdater() { public AstridOrderedListUpdater() {
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
idToNode = new HashMap<String, Node>(); idToNode = new HashMap<>();
} }
public interface OrderedListNodeVisitor { public interface OrderedListNodeVisitor {
@ -37,7 +37,7 @@ public abstract class AstridOrderedListUpdater<LIST> {
public String uuid; public String uuid;
public Node parent; public Node parent;
public int indent; public int indent;
public final ArrayList<Node> children = new ArrayList<Node>(); public final ArrayList<Node> children = new ArrayList<>();
public Node(String uuid, Node parent, int indent) { public Node(String uuid, Node parent, int indent) {
this.uuid = uuid; this.uuid = uuid;
@ -80,11 +80,11 @@ public abstract class AstridOrderedListUpdater<LIST> {
private void verifyTreeModel(LIST list, Filter filter) { private void verifyTreeModel(LIST list, Filter filter) {
boolean changedThings = false; boolean changedThings = false;
Set<String> keySet = idToNode.keySet(); Set<String> keySet = idToNode.keySet();
Set<String> currentIds = new HashSet<String>(); Set<String> currentIds = new HashSet<>();
for (String id : keySet) { for (String id : keySet) {
currentIds.add(id); currentIds.add(id);
} }
Set<String> idsInQuery = new HashSet<String>(); Set<String> idsInQuery = new HashSet<>();
String sql = filter.getSqlQuery().replaceAll("ORDER BY .*", ""); //$NON-NLS-1$//$NON-NLS-2$ String sql = filter.getSqlQuery().replaceAll("ORDER BY .*", ""); //$NON-NLS-1$//$NON-NLS-2$
sql = sql + String.format(" ORDER BY %s", Task.CREATION_DATE); //$NON-NLS-1$ sql = sql + String.format(" ORDER BY %s", Task.CREATION_DATE); //$NON-NLS-1$
TodorooCursor<Task> tasks = taskService.fetchFiltered(sql, null, Task.UUID); TodorooCursor<Task> tasks = taskService.fetchFiltered(sql, null, Task.UUID);
@ -138,7 +138,7 @@ public abstract class AstridOrderedListUpdater<LIST> {
} }
private String[] getOrderedIds() { private String[] getOrderedIds() {
ArrayList<String> ids = new ArrayList<String>(); ArrayList<String> ids = new ArrayList<>();
orderedIdHelper(treeRoot, ids); orderedIdHelper(treeRoot, ids);
return ids.toArray(new String[ids.size()]); return ids.toArray(new String[ids.size()]);
} }

@ -123,7 +123,7 @@ public class OrderedMetadataListFragmentHelper<LIST> implements OrderedListFragm
baseProperties = TaskAdapter.BASIC_PROPERTIES; baseProperties = TaskAdapter.BASIC_PROPERTIES;
} }
ArrayList<Property<?>> properties = new ArrayList<Property<?>>(Arrays.asList(baseProperties)); ArrayList<Property<?>> properties = new ArrayList<>(Arrays.asList(baseProperties));
properties.add(updater.indentProperty()); properties.add(updater.indentProperty());
properties.add(updater.orderProperty()); properties.add(updater.orderProperty());
return properties.toArray(new Property<?>[properties.size()]); return properties.toArray(new Property<?>[properties.size()]);
@ -272,7 +272,7 @@ public class OrderedMetadataListFragmentHelper<LIST> implements OrderedListFragm
return; return;
} }
final ArrayList<Long> chained = new ArrayList<Long>(); final ArrayList<Long> chained = new ArrayList<>();
final int parentIndent = item.getValue(updater.indentProperty()); final int parentIndent = item.getValue(updater.indentProperty());
updater.applyToChildren(list, itemId, new OrderedListNodeVisitor() { updater.applyToChildren(list, itemId, new OrderedListNodeVisitor() {
@Override @Override

@ -202,7 +202,7 @@ abstract public class OrderedMetadataListUpdater<LIST> {
protected static class Node { protected static class Node {
public final long taskId; public final long taskId;
public Node parent; public Node parent;
public final ArrayList<Node> children = new ArrayList<Node>(); public final ArrayList<Node> children = new ArrayList<>();
public Node(long taskId, Node parent) { public Node(long taskId, Node parent) {
this.taskId = taskId; this.taskId = taskId;
@ -251,7 +251,7 @@ abstract public class OrderedMetadataListUpdater<LIST> {
protected Node buildTreeModel(LIST list) { protected Node buildTreeModel(LIST list) {
final Node root = new Node(Task.NO_ID, null); final Node root = new Node(Task.NO_ID, null);
final AtomicInteger previoustIndent = new AtomicInteger(-1); final AtomicInteger previoustIndent = new AtomicInteger(-1);
final AtomicReference<Node> currentNode = new AtomicReference<Node>(root); final AtomicReference<Node> currentNode = new AtomicReference<>(root);
iterateThroughList(list, new OrderedListIterator() { iterateThroughList(list, new OrderedListIterator() {
@Override @Override

@ -103,7 +103,7 @@ public class SubtasksHelper {
@Deprecated @Deprecated
private static Long[] getIdArray(String serializedTree) { private static Long[] getIdArray(String serializedTree) {
ArrayList<Long> ids = new ArrayList<Long>(); ArrayList<Long> ids = new ArrayList<>();
String[] digitsOnly = serializedTree.split("[\\[\\],\\s]"); // Split on [ ] , or whitespace chars String[] digitsOnly = serializedTree.split("[\\[\\],\\s]"); // Split on [ ] , or whitespace chars
for (String idString : digitsOnly) { for (String idString : digitsOnly) {
try { try {
@ -118,7 +118,7 @@ public class SubtasksHelper {
} }
public static String[] getStringIdArray(String serializedTree) { public static String[] getStringIdArray(String serializedTree) {
ArrayList<String> ids = new ArrayList<String>(); ArrayList<String> ids = new ArrayList<>();
String[] values = serializedTree.split("[\\[\\],\"\\s]"); // Split on [ ] , or whitespace chars String[] values = serializedTree.split("[\\[\\],\"\\s]"); // Split on [ ] , or whitespace chars
for (String idString : values) { for (String idString : values) {
if (!TextUtils.isEmpty(idString)) { if (!TextUtils.isEmpty(idString)) {
@ -176,7 +176,7 @@ public class SubtasksHelper {
} }
private static <A, B> HashMap<A, B> getIdMap(A[] keys, Property<A> keyProperty, Property<B> valueProperty) { private static <A, B> HashMap<A, B> getIdMap(A[] keys, Property<A> keyProperty, Property<B> valueProperty) {
HashMap<A, B> map = new HashMap<A, B>(); HashMap<A, B> map = new HashMap<>();
TodorooCursor<Task> tasks = PluginServices.getTaskService().query(Query.select(keyProperty, valueProperty).where(keyProperty.in(keys))); TodorooCursor<Task> tasks = PluginServices.getTaskService().query(Query.select(keyProperty, valueProperty).where(keyProperty.in(keys)));
try { try {
for (tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) { for (tasks.moveToFirst(); !tasks.isAfterLast(); tasks.moveToNext()) {

@ -36,7 +36,7 @@ public class SubtasksListFragment extends TaskListFragment {
} }
protected OrderedListFragmentHelperInterface<?> createFragmentHelper() { protected OrderedListFragmentHelperInterface<?> createFragmentHelper() {
return new AstridOrderedListFragmentHelper<TaskListMetadata>(this, new SubtasksFilterUpdater()); return new AstridOrderedListFragmentHelper<>(this, new SubtasksFilterUpdater());
} }
@Override @Override

@ -24,7 +24,7 @@ public class SubtasksTagListFragment extends TagViewFragment {
public SubtasksTagListFragment() { public SubtasksTagListFragment() {
super(); super();
helper = new AstridOrderedListFragmentHelper<TaskListMetadata>(this, new SubtasksTagUpdater(isBeingFiltered)); helper = new AstridOrderedListFragmentHelper<>(this, new SubtasksTagUpdater(isBeingFiltered));
} }
@Override @Override

@ -127,7 +127,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
protected FilterListItem[] prepareFilters(Context context) { protected FilterListItem[] prepareFilters(Context context) {
ContextManager.setContext(context); ContextManager.setContext(context);
ArrayList<FilterListItem> list = new ArrayList<FilterListItem>(); ArrayList<FilterListItem> list = new ArrayList<>();
addTags(list); addTags(list);
@ -149,7 +149,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
boolean shouldAddUntagged = addUntaggedFilter && boolean shouldAddUntagged = addUntaggedFilter &&
Preferences.getBoolean(R.string.p_show_not_in_list_filter, true); Preferences.getBoolean(R.string.p_show_not_in_list_filter, true);
ArrayList<Filter> filters = new ArrayList<Filter>(tags.length); ArrayList<Filter> filters = new ArrayList<>(tags.length);
Context context = ContextManager.getContext(); Context context = ContextManager.getContext();
Resources r = context.getResources(); Resources r = context.getResources();

@ -171,7 +171,7 @@ public final class TagService {
orderBy(order).groupBy(TaskToTagMetadata.TAG_NAME); orderBy(order).groupBy(TaskToTagMetadata.TAG_NAME);
TodorooCursor<Metadata> cursor = metadataDao.query(query); TodorooCursor<Metadata> cursor = metadataDao.query(query);
try { try {
ArrayList<Tag> array = new ArrayList<Tag>(); ArrayList<Tag> array = new ArrayList<>();
for (int i = 0; i < cursor.getCount(); i++) { for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToNext(); cursor.moveToNext();
Tag tag = Tag.tagFromUUID(cursor.get(TaskToTagMetadata.TAG_UUID)); Tag tag = Tag.tagFromUUID(cursor.get(TaskToTagMetadata.TAG_UUID));
@ -293,7 +293,7 @@ public final class TagService {
* Return all tags (including metadata tags and TagData tags) in an array list * Return all tags (including metadata tags and TagData tags) in an array list
*/ */
public ArrayList<Tag> getTagList() { public ArrayList<Tag> getTagList() {
ArrayList<Tag> tagList = new ArrayList<Tag>(); ArrayList<Tag> tagList = new ArrayList<>();
TodorooCursor<TagData> cursor = tagDataService.query(Query.select(TagData.PROPERTIES).where(Criterion.and(TagData.DELETION_DATE.eq(0), Criterion.or(TagData.IS_FOLDER.isNull(), TodorooCursor<TagData> cursor = tagDataService.query(Query.select(TagData.PROPERTIES).where(Criterion.and(TagData.DELETION_DATE.eq(0), Criterion.or(TagData.IS_FOLDER.isNull(),
TagData.IS_FOLDER.neq(1)), TagData.NAME.isNotNull())).orderBy(Order.asc(Functions.upper(TagData.NAME)))); TagData.IS_FOLDER.neq(1)), TagData.NAME.isNotNull())).orderBy(Order.asc(Functions.upper(TagData.NAME))));
try { try {
@ -316,7 +316,7 @@ public final class TagService {
* Save the given array of tags into the database * Save the given array of tags into the database
*/ */
public void synchronizeTags(long taskId, String taskUuid, Set<String> tags) { public void synchronizeTags(long taskId, String taskUuid, Set<String> tags) {
HashSet<String> existingLinks = new HashSet<String>(); HashSet<String> existingLinks = new HashSet<>();
TodorooCursor<Metadata> links = metadataDao.query(Query.select(Metadata.PROPERTIES) TodorooCursor<Metadata> links = metadataDao.query(Query.select(Metadata.PROPERTIES)
.where(Criterion.and(TaskToTagMetadata.TASK_UUID.eq(taskUuid), Metadata.DELETION_DATE.eq(0)))); .where(Criterion.and(TaskToTagMetadata.TASK_UUID.eq(taskUuid), Metadata.DELETION_DATE.eq(0))));
try { try {

@ -77,7 +77,7 @@ public final class TagsControlSet extends PopupControlSet {
} }
private HashMap<String, Integer> buildTagIndices(ArrayList<String> tagNames) { private HashMap<String, Integer> buildTagIndices(ArrayList<String> tagNames) {
HashMap<String, Integer> indices = new HashMap<String, Integer>(); HashMap<String, Integer> indices = new HashMap<>();
for (int i = 0; i < tagNames.size(); i++) { for (int i = 0; i < tagNames.size(); i++) {
indices.put(tagNames.get(i), i); indices.put(tagNames.get(i), i);
} }
@ -85,7 +85,7 @@ public final class TagsControlSet extends PopupControlSet {
} }
private ArrayList<String> getTagNames(Tag[] tags) { private ArrayList<String> getTagNames(Tag[] tags) {
ArrayList<String> names = new ArrayList<String>(); ArrayList<String> names = new ArrayList<>();
for (Tag tag : tags) { for (Tag tag : tags) {
names.add(tag.toString()); names.add(tag.toString());
} }
@ -119,7 +119,7 @@ public final class TagsControlSet extends PopupControlSet {
} }
private LinkedHashSet<String> getTagSet() { private LinkedHashSet<String> getTagSet() {
LinkedHashSet<String> tags = new LinkedHashSet<String>(); LinkedHashSet<String> tags = new LinkedHashSet<>();
if (initialized) { if (initialized) {
for(int i = 0; i < selectedTags.getAdapter().getCount(); i++) { for(int i = 0; i < selectedTags.getAdapter().getCount(); i++) {
if (selectedTags.isItemChecked(i)) { if (selectedTags.isItemChecked(i)) {
@ -236,7 +236,7 @@ public final class TagsControlSet extends PopupControlSet {
super.readFromTask(task); super.readFromTask(task);
if(model.getId() != AbstractModel.NO_ID) { if(model.getId() != AbstractModel.NO_ID) {
TodorooCursor<Metadata> cursor = tagService.getTags(model.getId()); TodorooCursor<Metadata> cursor = tagService.getTags(model.getId());
LinkedHashSet<String> tags = new LinkedHashSet<String>(cursor.getCount()); LinkedHashSet<String> tags = new LinkedHashSet<>(cursor.getCount());
try { try {
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
String tag = cursor.get(TaskToTagMetadata.TAG_NAME); String tag = cursor.get(TaskToTagMetadata.TAG_NAME);
@ -287,7 +287,7 @@ public final class TagsControlSet extends PopupControlSet {
tagIndices = buildTagIndices(allTagNames); tagIndices = buildTagIndices(allTagNames);
selectedTags = (ListView) getView().findViewById(R.id.existingTags); selectedTags = (ListView) getView().findViewById(R.id.existingTags);
selectedTags.setAdapter(new ArrayAdapter<String>(activity, selectedTags.setAdapter(new ArrayAdapter<>(activity,
R.layout.simple_list_item_multiple_choice_themed, allTagNames)); R.layout.simple_list_item_multiple_choice_themed, allTagNames));
selectedTags.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); selectedTags.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

@ -29,7 +29,7 @@ public class TimerActionControlSet extends TaskEditControlSet {
private final ImageView timerButton; private final ImageView timerButton;
private final Chronometer chronometer; private final Chronometer chronometer;
private boolean timerActive; private boolean timerActive;
private final List<TimerActionListener> listeners = new LinkedList<TimerActionListener>(); private final List<TimerActionListener> listeners = new LinkedList<>();
public TimerActionControlSet(final Activity activity, View parent) { public TimerActionControlSet(final Activity activity, View parent) {
super(activity, -1); super(activity, -1);

@ -150,7 +150,7 @@ public class DateAndTimePicker extends LinearLayout {
} }
String[] labels = context.getResources().getStringArray(arrayResource); String[] labels = context.getResources().getStringArray(arrayResource);
ArrayList<UrgencyValue> urgencyValues = new ArrayList<UrgencyValue>(); ArrayList<UrgencyValue> urgencyValues = new ArrayList<>();
todayUrgency = new UrgencyValue(labels[2], todayUrgency = new UrgencyValue(labels[2],
Task.URGENCY_TODAY); Task.URGENCY_TODAY);
if (useShortcuts) { if (useShortcuts) {

@ -162,7 +162,7 @@ public class HideUntilControlSet extends PopupControlSet implements OnItemSelect
private void customDateFinished() { private void customDateFinished() {
HideUntilValue[] list = createHideUntilList(customDate.getTime()); HideUntilValue[] list = createHideUntilList(customDate.getTime());
adapter = new ArrayAdapter<HideUntilValue>( adapter = new ArrayAdapter<>(
activity, android.R.layout.simple_spinner_item, activity, android.R.layout.simple_spinner_item,
list); list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@ -246,7 +246,7 @@ public class HideUntilControlSet extends PopupControlSet implements OnItemSelect
} }
HideUntilValue[] list = createHideUntilList(date); HideUntilValue[] list = createHideUntilList(date);
adapter = new ArrayAdapter<HideUntilValue>( adapter = new ArrayAdapter<>(
activity, android.R.layout.simple_spinner_item, list); activity, android.R.layout.simple_spinner_item, list);
super.readFromTask(task); super.readFromTask(task);

@ -29,9 +29,9 @@ import java.util.List;
* *
*/ */
public class ImportanceControlSet extends TaskEditControlSet { public class ImportanceControlSet extends TaskEditControlSet {
private final List<CompoundButton> buttons = new LinkedList<CompoundButton>(); private final List<CompoundButton> buttons = new LinkedList<>();
private final int[] colors; private final int[] colors;
private final List<ImportanceChangedListener> listeners = new LinkedList<ImportanceChangedListener>(); private final List<ImportanceChangedListener> listeners = new LinkedList<>();
private static final int TEXT_SIZE = 18; private static final int TEXT_SIZE = 18;

@ -28,7 +28,7 @@ public class NNumberPickerDialog extends AlertDialog implements OnClickListener
void onNumbersPicked(int[] number); void onNumbersPicked(int[] number);
} }
private final List<NumberPicker> pickers = new LinkedList<NumberPicker>(); private final List<NumberPicker> pickers = new LinkedList<>();
private final OnNNumberPickedListener mCallback; private final OnNNumberPickedListener mCallback;
/** Instantiate the dialog box. /** Instantiate the dialog box.

@ -233,7 +233,7 @@ public class QuickAddBar extends LinearLayout {
Task empty = new Task(); Task empty = new Task();
TagData tagData = fragment.getActiveTagData(); TagData tagData = fragment.getActiveTagData();
if (tagData != null) { if (tagData != null) {
HashSet<String> tagsTransitory = new HashSet<String>(); HashSet<String> tagsTransitory = new HashSet<>();
tagsTransitory.add(tagData.getValue(TagData.NAME)); tagsTransitory.add(tagData.getValue(TagData.NAME));
empty.putTransitory(TaskService.TRANS_TAGS, tagsTransitory); empty.putTransitory(TaskService.TRANS_TAGS, tagsTransitory);
} }
@ -298,7 +298,7 @@ public class QuickAddBar extends LinearLayout {
if (currentVoiceFile != null) { if (currentVoiceFile != null) {
AtomicReference<String> nameRef = new AtomicReference<String>(); AtomicReference<String> nameRef = new AtomicReference<>();
String path = FileUtilities.getNewAudioAttachmentPath(activity, nameRef); String path = FileUtilities.getNewAudioAttachmentPath(activity, nameRef);
voiceRecognizer.convert(path); voiceRecognizer.convert(path);

@ -54,7 +54,7 @@ public class RandomReminderControlSet extends TaskEditControlSet {
}); });
// create adapter // create adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>( ArrayAdapter<String> adapter = new ArrayAdapter<>(
activity, android.R.layout.simple_spinner_item, activity, android.R.layout.simple_spinner_item,
activity.getResources().getStringArray(R.array.TEA_reminder_random)); activity.getResources().getStringArray(R.array.TEA_reminder_random));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

@ -46,7 +46,7 @@ public class ReminderControlSet extends PopupControlSet {
public ReminderControlSet(Activity activity, int viewLayout, int displayViewLayout) { public ReminderControlSet(Activity activity, int viewLayout, int displayViewLayout) {
super(activity, viewLayout, displayViewLayout, R.string.TEA_reminders_group_label); super(activity, viewLayout, displayViewLayout, R.string.TEA_reminders_group_label);
extraViews = new ArrayList<View>(); extraViews = new ArrayList<>();
label = (TextView) getDisplayView().findViewById(R.id.display_row_edit); label = (TextView) getDisplayView().findViewById(R.id.display_row_edit);
image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon); image = (ImageView) getDisplayView().findViewById(R.id.display_row_icon);
@ -123,7 +123,7 @@ public class ReminderControlSet extends PopupControlSet {
activity.getString(R.string.TEA_reminder_mode_five), activity.getString(R.string.TEA_reminder_mode_five),
activity.getString(R.string.TEA_reminder_mode_nonstop), activity.getString(R.string.TEA_reminder_mode_nonstop),
}; };
final ArrayAdapter<String> adapter = new ArrayAdapter<String>( final ArrayAdapter<String> adapter = new ArrayAdapter<>(
activity, android.R.layout.simple_spinner_item, list); activity, android.R.layout.simple_spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mode.setOnItemSelectedListener(new OnItemSelectedListener() { mode.setOnItemSelectedListener(new OnItemSelectedListener() {

@ -108,7 +108,7 @@ abstract public class SyncMetadataService<TYPE extends SyncContainer> {
try { try {
TodorooCursor<Metadata> metadata = getRemoteTaskMetadata(); TodorooCursor<Metadata> metadata = getRemoteTaskMetadata();
try { try {
ArrayList<Long> matchingRows = new ArrayList<Long>(); ArrayList<Long> matchingRows = new ArrayList<>();
joinRows(tasks, metadata, matchingRows, both); joinRows(tasks, metadata, matchingRows, both);
return return

@ -47,7 +47,7 @@ public class TitleParser {
Pattern tagPattern = Pattern.compile("(\\s|^)#(\\(.*\\)|[^\\s]+)"); Pattern tagPattern = Pattern.compile("(\\s|^)#(\\(.*\\)|[^\\s]+)");
Pattern contextPattern = Pattern.compile("(\\s|^)@(\\(.*\\)|[^\\s]+)"); Pattern contextPattern = Pattern.compile("(\\s|^)@(\\(.*\\)|[^\\s]+)");
Set<String> addedTags = new HashSet<String>(); Set<String> addedTags = new HashSet<>();
TagService tagService = TagService.getInstance(); TagService tagService = TagService.getInstance();
while(true) { while(true) {
@ -262,7 +262,7 @@ public class TitleParser {
inputText = removeIfParenthetical(match, inputText); inputText = removeIfParenthetical(match, inputText);
} }
HashMap<String, Integer> dayTimes = new HashMap<String, Integer>(); HashMap<String, Integer> dayTimes = new HashMap<>();
dayTimes.put("(?i)\\bbreakfast\\b", 8); dayTimes.put("(?i)\\bbreakfast\\b", 8);
dayTimes.put("(?i)\\blunch\\b", 12); dayTimes.put("(?i)\\blunch\\b", 12);
dayTimes.put("(?i)\\bsupper\\b", 18); dayTimes.put("(?i)\\bsupper\\b", 18);
@ -375,7 +375,7 @@ public class TitleParser {
return false; return false;
} }
String inputText = task.getValue(Task.TITLE); String inputText = task.getValue(Task.TITLE);
HashMap<String, Frequency> repeatTimes = new HashMap<String, Frequency>(); HashMap<String, Frequency> repeatTimes = new HashMap<>();
repeatTimes.put("(?i)\\bevery ?\\w{0,6} days?\\b" , Frequency.DAILY); repeatTimes.put("(?i)\\bevery ?\\w{0,6} days?\\b" , Frequency.DAILY);
repeatTimes.put("(?i)\\bevery ?\\w{0,6} ?nights?\\b" , Frequency.DAILY); repeatTimes.put("(?i)\\bevery ?\\w{0,6} ?nights?\\b" , Frequency.DAILY);
repeatTimes.put("(?i)\\bevery ?\\w{0,6} ?mornings?\\b" , Frequency.DAILY); repeatTimes.put("(?i)\\bevery ?\\w{0,6} ?mornings?\\b" , Frequency.DAILY);
@ -386,7 +386,7 @@ public class TitleParser {
repeatTimes.put("(?i)\\bevery \\w{0,6} ?months?\\b", Frequency.MONTHLY); repeatTimes.put("(?i)\\bevery \\w{0,6} ?months?\\b", Frequency.MONTHLY);
repeatTimes.put("(?i)\\bevery \\w{0,6} ?years?\\b", Frequency.YEARLY); repeatTimes.put("(?i)\\bevery \\w{0,6} ?years?\\b", Frequency.YEARLY);
HashMap<String, Frequency> repeatTimesIntervalOne = new HashMap<String, Frequency>(); HashMap<String, Frequency> repeatTimesIntervalOne = new HashMap<>();
//pre-determined intervals of 1 //pre-determined intervals of 1
repeatTimesIntervalOne.put( "(?i)\\bdaily\\b" , Frequency.DAILY); repeatTimesIntervalOne.put( "(?i)\\bdaily\\b" , Frequency.DAILY);
repeatTimesIntervalOne.put( "(?i)\\beveryday\\b" , Frequency.DAILY); repeatTimesIntervalOne.put( "(?i)\\beveryday\\b" , Frequency.DAILY);
@ -426,7 +426,7 @@ public class TitleParser {
//helper method for repeatHelper. //helper method for repeatHelper.
private static int findInterval(String inputText) { private static int findInterval(String inputText) {
HashMap<String,Integer> wordsToNum = new HashMap<String, Integer>(); HashMap<String,Integer> wordsToNum = new HashMap<>();
String[] words = new String[] { String[] words = new String[] {
"one", "two", "three", "four", "five", "six", "one", "two", "three", "four", "five", "six",
"seven", "eight", "nine", "ten", "eleven", "twelve" "seven", "eight", "nine", "ten", "eleven", "twelve"

@ -30,7 +30,7 @@ public class Api6VoiceOutputAssistant implements OnInitListener, VoiceOutputAssi
private boolean isTTSInitialized; private boolean isTTSInitialized;
private boolean retryLastSpeak; private boolean retryLastSpeak;
private String lastTextToSpeak; private String lastTextToSpeak;
private static final HashMap<String, String> ttsParams = new HashMap<String, String>(); private static final HashMap<String, String> ttsParams = new HashMap<>();
static { static {
ttsParams.put(TextToSpeech.Engine.KEY_PARAM_STREAM, ttsParams.put(TextToSpeech.Engine.KEY_PARAM_STREAM,

Loading…
Cancel
Save