Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit

Permalink
Closing out known crashes
Browse files Browse the repository at this point in the history
- Better message tab refresh avoiding UI flicker.
- Fixed #100 NetworkOnMainThreadException in ExchangeActivity
- Fixed #86 IllegalStateException in RecipientDbAdapter
- Fixed #96 WindowManager$BadTokenException in ExchangeActivity
  • Loading branch information
Michael Farb committed Feb 12, 2015
1 parent c8ba846 commit 95bb2c4
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager.BadTokenException;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
Expand Down Expand Up @@ -305,8 +306,12 @@ protected void showMessage(String title, String msg) {
args.putString(EXTRA_TITLE, title);
args.putString(EXTRA_MSG, msg);
if (!isFinishing()) {
removeDialog(MENU_MSG);
showDialog(MENU_MSG, args);
try {
removeDialog(MENU_MSG);
showDialog(MENU_MSG, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager.BadTokenException;
import android.widget.Toast;
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig.extra;

Expand All @@ -51,8 +52,12 @@ protected void showHelp(String title, String msg) {
args.putString(extra.RESID_TITLE, title);
args.putString(extra.RESID_MSG, msg);
if (!isFinishing()) {
removeDialog(DIALOG_HELP);
showDialog(DIALOG_HELP, args);
try {
removeDialog(DIALOG_HELP);
showDialog(DIALOG_HELP, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager.BadTokenException;
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig.extra;

/***
Expand Down Expand Up @@ -542,8 +543,12 @@ private void showError(String msg) {
Bundle args = new Bundle();
args.putString(extra.RESID_MSG, msg);
if (!isFinishing()) {
removeDialog(DIALOG_ERROR);
showDialog(DIALOG_ERROR, args);
try {
removeDialog(DIALOG_ERROR);
showDialog(DIALOG_ERROR, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -575,8 +580,12 @@ private void showLowestUserIdPrompt(int usrid) {

private void showGroupSizePicker() {
if (!isFinishing()) {
removeDialog(DIALOG_GRP_SIZE);
showDialog(DIALOG_GRP_SIZE);
try {
removeDialog(DIALOG_GRP_SIZE);
showDialog(DIALOG_GRP_SIZE);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -673,8 +682,12 @@ private void showQuestion(String msg, final int requestCode) {
args.putInt(extra.REQUEST_CODE, requestCode);
args.putString(extra.RESID_MSG, msg);
if (!isFinishing()) {
removeDialog(DIALOG_QUESTION);
showDialog(DIALOG_QUESTION, args);
try {
removeDialog(DIALOG_QUESTION);
showDialog(DIALOG_QUESTION, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -709,8 +722,16 @@ private void showProgress(String msg) {
Bundle args = new Bundle();
args.putString(extra.RESID_MSG, msg);
if (!isFinishing()) {
removeDialog(DIALOG_PROGRESS);
showDialog(DIALOG_PROGRESS, args);
try {
try {
removeDialog(DIALOG_PROGRESS);
showDialog(DIALOG_PROGRESS, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -784,6 +805,5 @@ protected void onDestroy() {
if (mHandler != null) {
mHandler.removeCallbacks(mUpdateReceivedProg);
}
mProt.endProtocol();
}
}
2 changes: 1 addition & 1 deletion safeslinger-messenger/res/layout/messagelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
android:visibility="visible" >

<ProgressBar
android:id="@+id/pbHeaderProgress"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.BadTokenException;
import android.webkit.MimeTypeMap;
import android.widget.CheckBox;
import android.widget.SimpleAdapter;
Expand Down Expand Up @@ -625,8 +626,12 @@ protected void showHelp(String title, String msg) {
args.putString(extra.RESID_TITLE, title);
args.putString(extra.RESID_MSG, msg);
if (!isFinishing()) {
removeDialog(DIALOG_HELP);
showDialog(DIALOG_HELP, args);
try {
removeDialog(DIALOG_HELP);
showDialog(DIALOG_HELP, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -700,8 +705,12 @@ private boolean doCleanupOldKeyData(String[] keyNames) {

protected void showAbout() {
if (!isFinishing()) {
removeDialog(DIALOG_ABOUT);
showDialog(DIALOG_ABOUT);
try {
removeDialog(DIALOG_ABOUT);
showDialog(DIALOG_ABOUT);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -1281,8 +1290,12 @@ protected void onPause() {

protected void showBackupQuery() {
if (!isFinishing()) {
removeDialog(DIALOG_BACKUPQUERY);
showDialog(DIALOG_BACKUPQUERY);
try {
removeDialog(DIALOG_BACKUPQUERY);
showDialog(DIALOG_BACKUPQUERY);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -1350,8 +1363,12 @@ public void onCancel(DialogInterface dialog) {

protected void showReference() {
if (!isFinishing()) {
removeDialog(DIALOG_REFERENCE);
showDialog(DIALOG_REFERENCE);
try {
removeDialog(DIALOG_REFERENCE);
showDialog(DIALOG_REFERENCE);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -1408,8 +1425,12 @@ public void onCancel(DialogInterface dialog) {

protected void showAddContactInvite() {
if (!isFinishing()) {
removeDialog(DIALOG_CONTACTINVITE);
showDialog(DIALOG_CONTACTINVITE);
try {
removeDialog(DIALOG_CONTACTINVITE);
showDialog(DIALOG_CONTACTINVITE);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -1572,8 +1593,12 @@ private void showCustomContactPicker(int resultCode) {
Bundle args = new Bundle();
args.putInt(extra.RESULT_CODE, resultCode);
if (!isFinishing()) {
removeDialog(DIALOG_CONTACTTYPE);
showDialog(DIALOG_CONTACTTYPE, args);
try {
removeDialog(DIALOG_CONTACTTYPE);
showDialog(DIALOG_CONTACTTYPE, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.BadTokenException;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;
Expand Down Expand Up @@ -158,8 +159,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
private void showFilePicker() {
MyLog.d(TAG, mPath.getAbsolutePath());
if (!isFinishing()) {
removeDialog(DIALOG_LOAD_FILE);
showDialog(DIALOG_LOAD_FILE);
try {
removeDialog(DIALOG_LOAD_FILE);
showDialog(DIALOG_LOAD_FILE);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.BadTokenException;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListAdapter;
Expand Down Expand Up @@ -155,8 +156,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
private void showFileLoader() {
MyLog.d(TAG, mPath.getAbsolutePath());
if (!isFinishing()) {
removeDialog(DIALOG_LOAD_FILE);
showDialog(DIALOG_LOAD_FILE);
try {
removeDialog(DIALOG_LOAD_FILE);
showDialog(DIALOG_LOAD_FILE);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -240,8 +245,12 @@ protected void showFileSaveAs() {
Intent intent = getIntent();
Bundle args = intent.getExtras();
if (!isFinishing()) {
removeDialog(DIALOG_TEXT_ENTRY);
showDialog(DIALOG_TEXT_ENTRY, args);
try {
removeDialog(DIALOG_TEXT_ENTRY);
showDialog(DIALOG_TEXT_ENTRY, args);
} catch (BadTokenException e) {
e.printStackTrace();
}
}
}

Expand Down
Loading

0 comments on commit 95bb2c4

Please sign in to comment.