Permalink
Browse files

fix NPE

Conflicts:

	src/de/ub0r/android/smsdroid/MessageListActivity.java
  • Loading branch information...
1 parent f23961c commit d585504aad4d2779d243f652229fe172e9612324 @felixb committed May 6, 2012
@@ -132,26 +132,28 @@ public void onCreate() {
@Override
public void run() {
- Log.i(TAG, "Refresh Thread started");
+ Log.d(TAG, "Refresh Thread started");
Looper.prepare();
Ads.this.refreshLooper = Looper.myLooper();
- Ads.this.refreshHandler = new Handler(Ads.this.refreshLooper) {
-
- @Override
- public void handleMessage(final Message msg) {
- switch (msg.what) {
- case REFRESH_AD:
- Log.i(TAG, "Refresh Ad message received. Requesting ad from MobFox");
- Ads.this.mMobFoxView.loadNextAd();
- break;
- default:
- Log.w(TAG, "unknown msg.what: " + msg.what);
- break;
+ if (Ads.this.refreshLooper != null) {
+ Ads.this.refreshHandler = new Handler(Ads.this.refreshLooper) {
+
+ @Override
+ public void handleMessage(final Message msg) {
+ switch (msg.what) {
+ case REFRESH_AD:
+ Log.d(TAG, "Refresh Ad message received. Requesting ad from MobFox");
+ Ads.this.mMobFoxView.loadNextAd();
+ break;
+ default:
+ Log.w(TAG, "unknown msg.what: " + msg.what);
+ break;
+ }
}
- }
- };
- Looper.loop();
- Log.i(TAG, "Refresh Thread stopped");
+ };
+ Looper.loop();
+ Log.d(TAG, "Refresh Thread stopped");
+ }
}
};
refreshThread.start();
@@ -540,7 +540,13 @@ public void onClick(final DialogInterface dialog, final int which) {
final Uri u = MessageListActivity.this.conv.getContact().getUri();
i = new Intent(Intent.ACTION_VIEW, u);
}
- MessageListActivity.this.startActivity(i);
+ try {
+ MessageListActivity.this.startActivity(i);
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "activity not found: " + i.getAction(), e);
+ Toast.makeText(MessageListActivity.this, "activity not found",
+ Toast.LENGTH_LONG).show();
+ }
break;
case WHICH_CALL:
MessageListActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri
@@ -133,7 +133,9 @@ public static String cleanRecipient(final String recipient) {
return "";
}
String n;
- if (recipient.indexOf("<") < recipient.indexOf(">")) {
+ int i = recipient.indexOf("<");
+ int j = recipient.indexOf(">");
+ if (i != -1 && i < j) {
n = recipient.substring(recipient.indexOf("<"), recipient.indexOf(">"));
} else {
n = recipient;

0 comments on commit d585504

Please sign in to comment.