Fix a bunch of crashes

pull/14/head
Tim Su 15 years ago
parent 61003bd535
commit a5dfaf119d

@ -10,7 +10,8 @@
<ScrollView
android:id="@+id/tab_basic"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="fill_parent"
android:layout_weight="100">
<LinearLayout
android:id="@+id/event"
android:paddingRight="8dip"
@ -119,6 +120,7 @@
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dip"
android:padding="5dip"
android:background="@drawable/edit_header"
@ -144,7 +146,8 @@
<ScrollView
android:id="@+id/tab_extra"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="fill_parent"
android:layout_weight="100">
<LinearLayout
android:paddingRight="8dip"
android:orientation="vertical"
@ -222,6 +225,7 @@
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dip"
android:padding="5dip"
android:background="@drawable/edit_header"

@ -32,10 +32,10 @@ import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
@ -48,6 +48,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
@ -62,7 +63,6 @@ import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.widget.AdapterView.OnItemSelectedListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property.StringProperty;
@ -340,19 +340,23 @@ public final class TaskEditActivity extends TabActivity {
};
// set up save, cancel, and delete buttons
ImageButton saveButtonGeneral = (ImageButton) findViewById(R.id.save_basic);
saveButtonGeneral.setOnClickListener(mSaveListener);
ImageButton saveButtonDates = (ImageButton) findViewById(R.id.save_extra);
saveButtonDates.setOnClickListener(mSaveListener);
ImageButton saveButtonNotify = (ImageButton) findViewById(R.id.save_addons);
saveButtonNotify.setOnClickListener(mSaveListener);
ImageButton discardButtonGeneral = (ImageButton) findViewById(R.id.discard_basic);
discardButtonGeneral.setOnClickListener(mDiscardListener);
ImageButton discardButtonDates = (ImageButton) findViewById(R.id.discard_extra);
discardButtonDates.setOnClickListener(mDiscardListener);
ImageButton discardButtonNotify = (ImageButton) findViewById(R.id.discard_addons);
discardButtonNotify.setOnClickListener(mDiscardListener);
try {
ImageButton saveButtonGeneral = (ImageButton) findViewById(R.id.save_basic);
saveButtonGeneral.setOnClickListener(mSaveListener);
ImageButton saveButtonDates = (ImageButton) findViewById(R.id.save_extra);
saveButtonDates.setOnClickListener(mSaveListener);
ImageButton saveButtonNotify = (ImageButton) findViewById(R.id.save_addons);
saveButtonNotify.setOnClickListener(mSaveListener);
ImageButton discardButtonGeneral = (ImageButton) findViewById(R.id.discard_basic);
discardButtonGeneral.setOnClickListener(mDiscardListener);
ImageButton discardButtonDates = (ImageButton) findViewById(R.id.discard_extra);
discardButtonDates.setOnClickListener(mDiscardListener);
ImageButton discardButtonNotify = (ImageButton) findViewById(R.id.discard_addons);
discardButtonNotify.setOnClickListener(mDiscardListener);
} catch (Exception e) {
// error loading the proper activity
}
}
/* ======================================================================

@ -25,6 +25,7 @@ import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.Html.ImageGetter;
import android.text.Html.TagHandler;
import android.text.Spannable;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.ContextMenu;
@ -376,7 +377,12 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
private Spanned convertToHtml(String string, ImageGetter imageGetter, TagHandler tagHandler) {
if(!htmlCache.containsKey(string)) {
Spanned html = Html.fromHtml(string, imageGetter, tagHandler);
Spanned html;
try {
html = Html.fromHtml(string, imageGetter, tagHandler);
} catch (RuntimeException e) {
html = Spannable.Factory.getInstance().newSpannable(string);
}
htmlCache.put(string, html);
return html;
}

@ -286,7 +286,13 @@ public class Astrid2TaskProvider extends ContentProvider {
if (LOGD)
Log.d(TAG, "notifyDatabaseModification");
ctx.getContentResolver().notifyChange(CONTENT_URI, null);
if(ctx == null)
ctx = ContextManager.getContext();
try {
ctx.getContentResolver().notifyChange(CONTENT_URI, null);
} catch (Exception e) {
// no context was available
}
}
}

@ -158,9 +158,14 @@ public class StartupService {
private void onFirstTime() {
Resources r = ContextManager.getResources();
addIntroTask(r, R.string.intro_task_1_summary, R.string.intro_task_1_note);
addIntroTask(r, R.string.intro_task_2_summary, R.string.intro_task_2_note);
addIntroTask(r, R.string.intro_task_3_summary, R.string.intro_task_3_note);
try {
database.openForWriting();
addIntroTask(r, R.string.intro_task_1_summary, R.string.intro_task_1_note);
addIntroTask(r, R.string.intro_task_2_summary, R.string.intro_task_2_note);
addIntroTask(r, R.string.intro_task_3_summary, R.string.intro_task_3_note);
} catch (Exception e) {
exceptionService.reportError("on-first-time", e); //$NON-NLS-1$
}
}
private void addIntroTask(Resources r, int summary, int note) {

Loading…
Cancel
Save