Based on profiling, fixed some ish

pull/14/head
Tim Su 14 years ago
parent 38ca50123d
commit 6611db1560

@ -9,8 +9,8 @@ import android.app.AlertDialog;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.util.Log; import android.util.Log;
@ -133,16 +133,16 @@ public class StartupService {
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
exceptionService.reportError("reminder-startup", e); //$NON-NLS-1$ exceptionService.reportError("reminder-startup", e); //$NON-NLS-1$
} }
}
}).start();
Preferences.setPreferenceDefaults();
// if sync ongoing flag was set, clear it // if sync ongoing flag was set, clear it
ProducteevUtilities.INSTANCE.stopOngoing(); ProducteevUtilities.INSTANCE.stopOngoing();
ProducteevBackgroundService.scheduleService(); ProducteevBackgroundService.scheduleService();
BackupService.scheduleService(context); BackupService.scheduleService(context);
}
}).start();
Preferences.setPreferenceDefaults();
// check for task killers // check for task killers
if(!Constants.OEM) if(!Constants.OEM)

@ -35,9 +35,11 @@ public class TimeDurationControlSet implements OnNNumberPickedListener,
private final Activity activity; private final Activity activity;
private final Button timeButton; private final Button timeButton;
private final NNumberPickerDialog dialog;
private final int prefixResource; private final int prefixResource;
private int timeDuration; private int timeDuration;
private int[] initialValues = null;
private final int titleResource;
private NNumberPickerDialog dialog = null;
public TimeDurationControlSet(Activity activity, int timeButtonId, public TimeDurationControlSet(Activity activity, int timeButtonId,
int prefixResource, int titleResource) { int prefixResource, int titleResource) {
@ -45,37 +47,10 @@ public class TimeDurationControlSet implements OnNNumberPickedListener,
this.activity = activity; this.activity = activity;
this.prefixResource = prefixResource; this.prefixResource = prefixResource;
this.titleResource = titleResource;
timeButton = (Button)activity.findViewById(timeButtonId); timeButton = (Button)activity.findViewById(timeButtonId);
timeButton.setOnClickListener(this); timeButton.setOnClickListener(this);
dialog = new NNumberPickerDialog(activity, this,
activity.getResources().getString(titleResource),
new int[] {0, 0}, new int[] {1, 5}, new int[] {0, 0},
new int[] {999, 59}, new String[] {":", null});
final NumberPicker hourPicker = dialog.getPicker(0);
final NumberPicker minutePicker = dialog.getPicker(1);
minutePicker.setFormatter(new NumberPicker.Formatter() {
@Override
public String toString(int value) {
return String.format("%02d", value);
}
});
minutePicker.setOnChangeListener(new NumberPicker.OnChangedListener() {
@Override
public int onChanged(NumberPicker picker, int oldVal, int newVal) {
if(newVal < 0) {
if(hourPicker.getCurrent() == 0)
return 0;
hourPicker.setCurrent(hourPicker.getCurrent() - 1);
return 60 + newVal;
} else if(newVal > 59) {
hourPicker.setCurrent(hourPicker.getCurrent() + 1);
return newVal % 60;
}
return newVal;
}
});
} }
public int getTimeDurationInSeconds() { public int getTimeDurationInSeconds() {
@ -100,7 +75,7 @@ public class TimeDurationControlSet implements OnNNumberPickedListener,
timeButton.setText(prefix + DateUtils.formatElapsedTime(timeDuration)); timeButton.setText(prefix + DateUtils.formatElapsedTime(timeDuration));
int hours = timeDuration / 3600; int hours = timeDuration / 3600;
int minutes = timeDuration / 60 - 60 * hours; int minutes = timeDuration / 60 - 60 * hours;
dialog.setInitialValues(new int[] { hours, minutes }); initialValues = new int[] { hours, minutes };
} }
/** Called when NumberPicker activity is completed */ /** Called when NumberPicker activity is completed */
@ -110,6 +85,39 @@ public class TimeDurationControlSet implements OnNNumberPickedListener,
/** Called when time button is clicked */ /** Called when time button is clicked */
public void onClick(View v) { public void onClick(View v) {
if(dialog == null) {
dialog = new NNumberPickerDialog(activity, this,
activity.getResources().getString(titleResource),
new int[] {0, 0}, new int[] {1, 5}, new int[] {0, 0},
new int[] {999, 59}, new String[] {":", null});
final NumberPicker hourPicker = dialog.getPicker(0);
final NumberPicker minutePicker = dialog.getPicker(1);
minutePicker.setFormatter(new NumberPicker.Formatter() {
@Override
public String toString(int value) {
return String.format("%02d", value);
}
});
minutePicker.setOnChangeListener(new NumberPicker.OnChangedListener() {
@Override
public int onChanged(NumberPicker picker, int oldVal, int newVal) {
if(newVal < 0) {
if(hourPicker.getCurrent() == 0)
return 0;
hourPicker.setCurrent(hourPicker.getCurrent() - 1);
return 60 + newVal;
} else if(newVal > 59) {
hourPicker.setCurrent(hourPicker.getCurrent() + 1);
return newVal % 60;
}
return newVal;
}
});
}
if(initialValues != null)
dialog.setInitialValues(initialValues);
dialog.show(); dialog.show();
} }

Loading…
Cancel
Save