Fix for crashes and errors, including jchronic, and some preventative try/catches

pull/14/head
Tim Su 13 years ago
parent 3c2f614cec
commit a7fe80fadd

@ -82,21 +82,12 @@ public class AstridChronic {
throw new RuntimeException("Failed to scan tokens.", e);
}
List<Class> scannerClasses = new LinkedList<Class>();
scannerClasses.add(Grabber.class);
scannerClasses.add(Pointer.class);
scannerClasses.add(Scalar.class);
scannerClasses.add(Ordinal.class);
scannerClasses.add(Separator.class);
scannerClasses.add(TimeZone.class);
for (Class scannerClass : scannerClasses) {
try {
tokens = (List<Token>) scannerClass.getMethod("scan", List.class, Options.class).invoke(null, tokens, options);
}
catch (Throwable e) {
throw new RuntimeException("Failed to scan tokens.", e);
}
}
tokens = Grabber.scan(tokens, options);
tokens = Pointer.scan(tokens, options);
tokens = Scalar.scan(tokens, options);
tokens = Ordinal.scan(tokens, options);
tokens = Separator.scan(tokens, options);
tokens = TimeZone.scan(tokens, options);
List<Token> taggedTokens = new LinkedList<Token>();
for (Token token : tokens) {

@ -9,6 +9,7 @@
-dontobfuscate
-keepattributes SourceFile, SourceDir, LineNumberTable, LocalVariableTable, LocalVariableTypeTable
-keep, allowshrinking, allowoptimization class com.todoroo.**
-keep class com.mdimension.**
# ignore reflection-based access from google libraries
-dontwarn com.google.**

@ -1025,7 +1025,12 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
R.anim.slide_left_in, R.anim.slide_left_out);
}
}
activity.unregisterReceiver(this);
try {
activity.unregisterReceiver(this);
} catch (IllegalArgumentException e) {
// ignore
}
}
}

@ -12,7 +12,7 @@ import com.todoroo.astrid.service.SyncV2Service.SyncResultCallback;
public class ProgressBarSyncResultCallback implements SyncResultCallback {
private final ProgressBar progressBar;
private ProgressBar progressBar;
private final Activity activity;
private final Runnable onFinished;
@ -23,6 +23,10 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
this.progressBar = (ProgressBar) activity.findViewById(progressBarId);
this.activity = activity;
this.onFinished = onFinished;
if(progressBar == null)
progressBar = new ProgressBar(activity);
progressBar.setProgress(0);
progressBar.setMax(0);
}
@ -33,14 +37,18 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setMax(100);
progressBar.setProgress(100);
AlphaAnimation animation = new AlphaAnimation(1, 0);
animation.setFillAfter(true);
animation.setDuration(1000L);
progressBar.startAnimation(animation);
try {
progressBar.setMax(100);
progressBar.setProgress(100);
AlphaAnimation animation = new AlphaAnimation(1, 0);
animation.setFillAfter(true);
animation.setDuration(1000L);
progressBar.startAnimation(animation);
onFinished.run();
onFinished.run();
} catch (Exception e) {
// ignore, view could have been destroyed
}
}
});
new Thread() {
@ -50,7 +58,11 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.GONE);
try {
progressBar.setVisibility(View.GONE);
} catch (Exception e) {
// ignore
}
}
});
}
@ -63,7 +75,11 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.setMax(progressBar.getMax() + incrementBy);
try {
progressBar.setMax(progressBar.getMax() + incrementBy);
} catch (Exception e) {
// ignore
}
}
});
}
@ -73,7 +89,11 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.incrementProgressBy(incrementBy);
try {
progressBar.incrementProgressBy(incrementBy);
} catch (Exception e) {
// ignore
}
}
});
}

@ -21,7 +21,8 @@ public class EditTitleControlSet extends EditTextControlSet implements Importanc
@Override
public void importanceChanged(int i, int color) {
importance.setImageResource(IMPORTANCE_DRAWABLES[i]);
if(importance != null)
importance.setImageResource(IMPORTANCE_DRAWABLES[i]);
}
}

@ -13,8 +13,9 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.viewpagerindicator.TitleProvider;
public class ViewPagerAdapter extends PagerAdapter
public class ViewPagerAdapter extends PagerAdapter implements TitleProvider
{
private static int[] images = new int[]
{
@ -120,4 +121,11 @@ public class ViewPagerAdapter extends PagerAdapter
@Override
public void startUpdate( View view ) {}
@Override
public String getTitle(int position) {
return context.getString(title[position]);
}
}
Loading…
Cancel
Save