Inline variables

Alex Baker 13 years ago
parent 3ce085751d
commit bab89cb49e

@ -115,8 +115,7 @@ public class AndroidUtilities {
is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is, 16384);
try {
Bitmap bitmap = BitmapFactory.decodeStream(bis);
return bitmap;
return BitmapFactory.decodeStream(bis);
} finally {
bis.close();
}
@ -717,8 +716,7 @@ public class AndroidUtilities {
String methodName, Class<?>[] params, Object... args) {
try {
Method method = cls.getMethod(methodName, params);
Object result = method.invoke(receiver, args);
return result;
return method.invoke(receiver, args);
} catch (SecurityException e) {
getExceptionService().reportError("call-method", e);
} catch (NoSuchMethodException e) {

@ -153,8 +153,7 @@ abstract public class SyncBackgroundService extends Service {
* Create the alarm intent
*/
private Intent createAlarmIntent(Context context) {
Intent intent = new Intent(context, getClass());
return intent;
return new Intent(context, getClass());
}
// --- utility methods

@ -163,8 +163,7 @@ abstract public class SyncV2BackgroundService extends Service {
* Create the alarm intent
*/
private Intent createAlarmIntent(Context context) {
Intent intent = new Intent(context, getClass());
return intent;
return new Intent(context, getClass());
}
// --- utility methods

@ -188,7 +188,6 @@ public class AstridChronic {
} else {
guessValue = span.getBegin();
}
Span guess = new Span(guessValue, guessValue);
return guess;
return new Span(guessValue, guessValue);
}
}

@ -251,8 +251,7 @@ public class ImageCache extends DiskCache<String, Bitmap> {
Log.d(TAG, "disk cache hit for key " + key);
}
try {
final Bitmap image = BitmapFactory.decodeStream(in);
return image;
return BitmapFactory.decodeStream(in);
} catch (final OutOfMemoryError oom) {
oomClear();

@ -314,8 +314,7 @@ public class GCMIntentService extends GCMBaseIntentService {
new QueryTemplate().where(Task.ID.eq(task.getId())),
null);
Intent launchIntent = ShortcutActivity.createIntent(filter);
return launchIntent;
return ShortcutActivity.createIntent(filter);
} finally {
cursor.close();
}

@ -141,8 +141,7 @@ public class ActFmCameraModule {
String storageState = Environment.getExternalStorageState();
if (storageState.equals(Environment.MEDIA_MOUNTED)) {
String path = Environment.getExternalStorageDirectory().getName() + File.separatorChar + "Android/data/" + activity.getPackageName() + "/files/";
File photoFile = File.createTempFile("comment_pic_" + DateUtilities.now(), ".jpg", new File(path));
return photoFile;
return File.createTempFile("comment_pic_" + DateUtilities.now(), ".jpg", new File(path));
}
} catch (IOException e) {
return null;

@ -99,9 +99,7 @@ public abstract class CommentsFragment extends SherlockListFragment {
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View v = inflater.inflate(getLayout(), container, false);
return v;
return inflater.inflate(getLayout(), container, false);
}
protected abstract int getLayout();

@ -355,10 +355,9 @@ public class TasksXmlExporter {
* @throws IOException
*/
private String setupFile(File directory, ExportType exportType) throws IOException {
File astridDir = directory;
if (astridDir != null) {
if (directory != null) {
// Check for /sdcard/astrid directory. If it doesn't exist, make it.
if (astridDir.exists() || astridDir.mkdir()) {
if (directory.exists() || directory.mkdir()) {
String fileName = ""; //$NON-NLS-1$
switch (exportType) {
case EXPORT_TYPE_SERVICE:
@ -373,11 +372,11 @@ public class TasksXmlExporter {
default:
throw new IllegalArgumentException("Invalid export type"); //$NON-NLS-1$
}
return astridDir.getAbsolutePath() + File.separator + fileName;
return directory.getAbsolutePath() + File.separator + fileName;
} else {
// Unable to make the /sdcard/astrid directory.
throw new IOException(context.getString(R.string.DLG_error_sdcard,
astridDir.getAbsolutePath()));
directory.getAbsolutePath()));
}
} else {
// Unable to access the sdcard because it's not in the mounted state.

@ -152,8 +152,7 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver {
try {
if (c.moveToFirst()) {
long id = c.getLong(c.getColumnIndex(ContactsContract.PhoneLookup._ID));
return id;
return c.getLong(c.getColumnIndex(ContactsContract.PhoneLookup._ID));
}
} finally {
c.close();

@ -68,8 +68,7 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
DependencyInjectionService.getInstance().inject(this);
Resources r = context.getResources();
Filter[] savedFilters = buildSavedFilters(context, r);
return savedFilters;
return buildSavedFilters(context, r);
}
private Filter[] buildSavedFilters(Context context, Resources r) {

@ -66,14 +66,12 @@ public class LinkActionExposer {
Resources r = context.getResources();
if (hasAttachments) {
BitmapDrawable icon = getBitmapDrawable(R.drawable.action_attachments, r);
FilesAction filesAction = new FilesAction("", null, icon); //$NON-NLS-1$
return filesAction;
return new FilesAction("", null, icon);
}
if (hasNotes && !Preferences.getBoolean(R.string.p_showNotes, false)) {
BitmapDrawable icon = getBitmapDrawable(R.drawable.action_notes, r);
NotesAction notesAction = new NotesAction("", null, icon); //$NON-NLS-1$
return notesAction;
return new NotesAction("", null, icon);
}
return null;
@ -116,9 +114,8 @@ public class LinkActionExposer {
text = text.substring(0, 12) + "..."; //$NON-NLS-1$
}
TaskAction action = new TaskAction(text,
return new TaskAction(text,
PendingIntent.getActivity(context, (int) id, actionIntent, 0), (BitmapDrawable) icon);
return action;
}
private static final HashMap<Integer, BitmapDrawable> IMAGE_CACHE = new HashMap<Integer, BitmapDrawable>();

@ -62,8 +62,7 @@ public class GtasksApiUtilities {
date.setMinutes(0);
date.setSeconds(0);
date.setTime(date.getTime() - date.getTimezoneOffset() * 60000);
DateTime dateTime = new DateTime(date, TimeZone.getTimeZone("UTC"));
return dateTime;
return new DateTime(date, TimeZone.getTimeZone("UTC"));
}
// public static DateTime unixTimeToGtasksDueDate(long time) {

@ -372,9 +372,8 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
gtasksMetadata.setValue(GtasksMetadata.ID, remoteTask.getId());
gtasksMetadata.setValue(GtasksMetadata.LIST_ID, listId);
GtasksTaskContainer container = new GtasksTaskContainer(task, metadata,
return new GtasksTaskContainer(task, metadata,
gtasksMetadata);
return container;
}
private void write(GtasksTaskContainer task) throws IOException {

@ -100,9 +100,8 @@ public class OpencrxCoreUtils extends SyncProviderUtilities {
protected static SharedPreferences getPrefs() {
try {
Context crxContext = ContextManager.getContext().createPackageContext(OPENCRX_PACKAGE, 0);
SharedPreferences sharedPreferences = crxContext.getSharedPreferences(PREFS_FILE,
return crxContext.getSharedPreferences(PREFS_FILE,
Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
return sharedPreferences;
} catch (NameNotFoundException e) {
return null;
}

@ -150,8 +150,7 @@ public class Notifications extends BroadcastReceiver {
*/
public static String getRandomReminder(String[] reminders) {
int next = ReminderService.random.nextInt(reminders.length);
String reminder = reminders[next];
return reminder;
return reminders[next];
}
/**
@ -388,8 +387,7 @@ public class Notifications extends BroadcastReceiver {
voiceReminder = false;
} else if (notificationPreference != null) {
if (notificationPreference.length() > 0 && soundIntervalOk) {
Uri notificationSound = Uri.parse(notificationPreference);
notification.sound = notificationSound;
notification.sound = Uri.parse(notificationPreference);
} else {
notification.sound = null;
}

@ -78,8 +78,7 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
}
public DraggableListView getTouchListView() {
DraggableListView tlv = (DraggableListView) fragment.getListView();
return tlv;
return (DraggableListView) fragment.getListView();
}
@Override

@ -82,8 +82,7 @@ public class OrderedMetadataListFragmentHelper<LIST> implements OrderedListFragm
}
public DraggableListView getTouchListView() {
DraggableListView tlv = (DraggableListView) fragment.getListView();
return tlv;
return (DraggableListView) fragment.getListView();
}
@Override

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

@ -151,8 +151,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
addTags(list);
// transmit filter list
FilterListItem[] listAsArray = list.toArray(new FilterListItem[list.size()]);
return listAsArray;
return list.toArray(new FilterListItem[list.size()]);
}
private void addTags(ArrayList<FilterListItem> list) {
@ -193,8 +192,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
filters.add(f);
}
}
FilterCategory filter = new FilterCategory(context.getString(name), filters.toArray(new Filter[filters.size()]));
return filter;
return new FilterCategory(context.getString(name), filters.toArray(new Filter[filters.size()]));
}
protected Filter constructFilter(Context context, Tag tag) {

@ -238,8 +238,7 @@ public final class TagsControlSet extends PopupControlSet {
return null;
}
View lastItem = newTags.getChildAt(newTags.getChildCount() - 1);
TextView lastText = (TextView) lastItem.findViewById(R.id.text1);
return lastText;
return (TextView) lastItem.findViewById(R.id.text1);
}
@Override

@ -38,8 +38,7 @@ public class TagsPlugin extends BroadcastReceiver {
*/
public static Intent newTagDialog(Context context) {
Class<?> settingsComponent = AstridPreferences.useTabletLayout(context) ? TagSettingsActivityTablet.class : TagSettingsActivity.class;
Intent intent = new Intent(context, settingsComponent);
return intent;
return new Intent(context, settingsComponent);
}
}

@ -33,10 +33,9 @@ public class AlertController extends LegacyAbstractController {
* Get a cursor to tag identifiers
*/
public Cursor getTaskAlertsCursor(TaskIdentifier taskId) throws SQLException {
Cursor cursor = alertDatabase.query(alertsTable,
return alertDatabase.query(alertsTable,
Alert.FIELD_LIST, Alert.TASK + " = ?",
new String[]{taskId.idAsString()}, null, null, null);
return cursor;
}
/**

@ -220,8 +220,7 @@ public class TagController extends LegacyAbstractController {
try {
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
TagModelForView model = new TagModelForView(cursor);
return model;
return new TagModelForView(cursor);
}
return null;
} finally {
@ -243,8 +242,7 @@ public class TagController extends LegacyAbstractController {
try {
if (cursor != null) {
cursor.moveToFirst();
TagModelForView model = new TagModelForView(cursor);
return model;
return new TagModelForView(cursor);
}
throw new SQLException("Returned empty set!");

@ -469,8 +469,7 @@ public class TaskController extends LegacyAbstractController {
return null;
}
activity.startManagingCursor(cursor);
TaskModelForEdit model = new TaskModelForEdit(taskId, cursor);
return model;
return new TaskModelForEdit(taskId, cursor);
}
/**
@ -550,8 +549,7 @@ public class TaskController extends LegacyAbstractController {
return null;
}
cursor.moveToFirst();
TaskModelForSync model = new TaskModelForSync(cursor);
return model;
return new TaskModelForSync(cursor);
} finally {
if (cursor != null) {
cursor.close();

@ -213,10 +213,9 @@ public class LegacyTasksXmlExporter {
}
private boolean setupFile(File directory) {
File astridDir = directory;
if (astridDir != null) {
if (directory != null) {
// Check for /sdcard/astrid directory. If it doesn't exist, make it.
if (astridDir.exists() || astridDir.mkdir()) {
if (directory.exists() || directory.mkdir()) {
String fileName;
if (isService) {
fileName = BACKUP_FILE_NAME;
@ -224,11 +223,11 @@ public class LegacyTasksXmlExporter {
fileName = EXPORT_FILE_NAME;
}
fileName = String.format(fileName, BackupDateUtilities.getDateForExport());
setOutput(astridDir.getAbsolutePath() + "/" + fileName);
setOutput(directory.getAbsolutePath() + "/" + fileName);
return true;
} else {
// Unable to make the /sdcard/astrid directory.
String error = ctx.getString(R.string.DLG_error_sdcard, astridDir.getAbsolutePath());
String error = ctx.getString(R.string.DLG_error_sdcard, directory.getAbsolutePath());
Log.e("TasksXmlExporter", error);
if (!isService) {
displayErrorToast(error);

@ -77,31 +77,27 @@ public class AstridActivity extends SherlockFragmentActivity
private TaskDao taskDao;
public FilterListFragment getFilterListFragment() {
FilterListFragment frag = (FilterListFragment) getSupportFragmentManager()
.findFragmentByTag(FilterListFragment.TAG_FILTERLIST_FRAGMENT);
return frag;
return (FilterListFragment) getSupportFragmentManager()
.findFragmentByTag(FilterListFragment.TAG_FILTERLIST_FRAGMENT);
}
public TaskListFragment getTaskListFragment() {
TaskListFragment frag = (TaskListFragment) getSupportFragmentManager()
.findFragmentByTag(TaskListFragment.TAG_TASKLIST_FRAGMENT);
return frag;
return (TaskListFragment) getSupportFragmentManager()
.findFragmentByTag(TaskListFragment.TAG_TASKLIST_FRAGMENT);
}
public TaskEditFragment getTaskEditFragment() {
TaskEditFragment frag = (TaskEditFragment) getSupportFragmentManager()
.findFragmentByTag(TaskEditFragment.TAG_TASKEDIT_FRAGMENT);
return frag;
return (TaskEditFragment) getSupportFragmentManager()
.findFragmentByTag(TaskEditFragment.TAG_TASKEDIT_FRAGMENT);
}
public CommentsFragment getTagUpdatesFragment() {
CommentsFragment frag = (CommentsFragment) getSupportFragmentManager()
.findFragmentByTag(CommentsFragment.TAG_UPDATES_FRAGMENT);
return frag;
return (CommentsFragment) getSupportFragmentManager()
.findFragmentByTag(CommentsFragment.TAG_UPDATES_FRAGMENT);
}

@ -134,8 +134,7 @@ public class FilterListFragment extends SherlockListFragment {
Bundle savedInstanceState) {
Activity activity = getActivity();
int layout = getLayout(activity);
ViewGroup parent = (ViewGroup) activity.getLayoutInflater().inflate(layout, container, false);
return parent;
return (ViewGroup) activity.getLayoutInflater().inflate(layout, container, false);
}
protected int getLayout(Activity activity) {
@ -284,9 +283,8 @@ public class FilterListFragment extends SherlockListFragment {
android.view.MenuItem menuItem;
if (item instanceof Filter) {
Filter filter = item;
menuItem = menu.add(0, CONTEXT_MENU_SHORTCUT, 0, R.string.FLA_context_shortcut);
menuItem.setIntent(ShortcutActivity.createIntent(filter));
menuItem.setIntent(ShortcutActivity.createIntent(item));
}
for (int i = 0; i < item.contextMenuLabels.length; i++) {

@ -162,8 +162,7 @@ public class ShortcutActivity extends Activity {
}
((FilterWithCustomIntent) filter).customExtras = customExtras; // Something
ComponentName customTaskList = ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS));
((FilterWithCustomIntent) filter).customTaskList = customTaskList;
((FilterWithCustomIntent) filter).customTaskList = ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS));
} else {
filter = new Filter(title, title, sql, values);
}

@ -322,9 +322,7 @@ public final class TaskEditFragment extends SherlockFragment implements
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View v = inflater.inflate(R.layout.task_edit_activity, container, false);
return v;
return inflater.inflate(R.layout.task_edit_activity, container, false);
}
@Override

@ -333,9 +333,8 @@ public class TaskAdapter extends CursorAdapter {
}
// perform query
TodorooCursor<Task> newCursor = taskService.fetchFiltered(
return taskService.fetchFiltered(
query.get(), constraint, fragment.taskProperties());
return newCursor;
}
public String getQuery() {

@ -129,8 +129,7 @@ public class SqlContentProvider extends ContentProvider {
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
Cursor cursor = database.rawQuery(selection, null);
return cursor;
return database.rawQuery(selection, null);
}
}

@ -174,9 +174,8 @@ public class HideUntilControlSet extends PopupControlSet implements OnItemSelect
// --- setting up values
public void setDefaults() {
int setting = Preferences.getIntegerFromString(R.string.p_default_hideUntil_key,
selection = Preferences.getIntegerFromString(R.string.p_default_hideUntil_key,
Task.HIDE_UNTIL_NONE);
selection = setting;
if (spinner != null) {
spinner.setSelection(selection);
}

@ -80,8 +80,7 @@ public class RandomReminderControlSet extends TaskEditControlSet {
/*
default interval for spinner if date is unselected
*/
long DEFAULT_INTERVAL = DateUtilities.ONE_WEEK * 2;
time = DEFAULT_INTERVAL;
time = DateUtilities.ONE_WEEK * 2;
}
int i;

@ -1162,10 +1162,9 @@ class Entities {
*/
public boolean containsKey(int key) {
Entry tab[] = table;
int hash = key;
int index = (hash & 0x7FFFFFFF) % tab.length;
int index = (key & 0x7FFFFFFF) % tab.length;
for (Entry e = tab[index]; e != null; e = e.next) {
if (e.hash == hash) {
if (e.hash == key) {
return true;
}
}
@ -1183,10 +1182,9 @@ class Entities {
*/
public Object get(int key) {
Entry tab[] = table;
int hash = key;
int index = (hash & 0x7FFFFFFF) % tab.length;
int index = (key & 0x7FFFFFFF) % tab.length;
for (Entry e = tab[index]; e != null; e = e.next) {
if (e.hash == hash) {
if (e.hash == key) {
return e.value;
}
}
@ -1242,10 +1240,9 @@ class Entities {
public Object put(int key, Object value) {
// Makes sure the key is not already in the hashtable.
Entry tab[] = table;
int hash = key;
int index = (hash & 0x7FFFFFFF) % tab.length;
int index = (key & 0x7FFFFFFF) % tab.length;
for (Entry e = tab[index]; e != null; e = e.next) {
if (e.hash == hash) {
if (e.hash == key) {
Object old = e.value;
e.value = value;
return old;
@ -1257,11 +1254,11 @@ class Entities {
rehash();
tab = table;
index = (hash & 0x7FFFFFFF) % tab.length;
index = (key & 0x7FFFFFFF) % tab.length;
}
// Creates the new entry.
Entry e = new Entry(hash, key, value, tab[index]);
Entry e = new Entry(key, key, value, tab[index]);
tab[index] = e;
count++;
return null;
@ -1280,10 +1277,9 @@ class Entities {
*/
public Object remove(int key) {
Entry tab[] = table;
int hash = key;
int index = (hash & 0x7FFFFFFF) % tab.length;
int index = (key & 0x7FFFFFFF) % tab.length;
for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) {
if (e.hash == hash) {
if (e.hash == key) {
if (prev != null) {
prev.next = e.next;
} else {

@ -39,8 +39,7 @@ public class TitleParser {
pattern = pattern.substring(1);
}
if ('(' == pattern.charAt(0)) {
String list = pattern.substring(1, pattern.length() - 1);
return list;
return pattern.substring(1, pattern.length() - 1);
}
return pattern;
}
@ -194,8 +193,7 @@ public class TitleParser {
Matcher m = pattern.matcher(inputText);
if (m.find()) {
String toParse = stripParens(m.group(0));
Calendar dayCal = AstridChronic.parse(toParse).getBeginCalendar();
cal = dayCal;
cal = AstridChronic.parse(toParse).getBeginCalendar();
inputText = removeIfParenthetical(m, inputText);
//then put it into task
}

@ -158,9 +158,8 @@ public class TasksWidget extends AppWidgetProvider {
// "System server dead" was sometimes thrown here by the OS. Abort if that happens
}
} else {
int id = extrasId;
RemoteViews updateViews = buildUpdate(this, id);
manager.updateAppWidget(id, updateViews);
RemoteViews updateViews = buildUpdate(this, extrasId);
manager.updateAppWidget(extrasId, updateViews);
}
stopSelf();
@ -417,8 +416,7 @@ public class TasksWidget extends AppWidgetProvider {
((FilterWithCustomIntent) filter).customTaskList = component;
String serializedExtras = Preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_EXTRAS
+ widgetId);
Bundle extras = AndroidUtilities.bundleFromSerializedString(serializedExtras);
((FilterWithCustomIntent) filter).customExtras = extras;
((FilterWithCustomIntent) filter).customExtras = AndroidUtilities.bundleFromSerializedString(serializedExtras);
}
// Validate tagData

Loading…
Cancel
Save