-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
183 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityOnCrash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.tamsiree.rxdemo.activity; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.os.AsyncTask; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import com.tamsiree.rxdemo.R; | ||
import com.tamsiree.rxui.activity.ActivityBase; | ||
|
||
public class ActivityOnCrash extends ActivityBase { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_on_crash); | ||
|
||
|
||
Button crashMainThreadButton = findViewById(R.id.button_crash_main_thread); | ||
Button crashBgThreadButton = findViewById(R.id.button_crash_bg_thread); | ||
Button crashWithDelayButton = findViewById(R.id.button_crash_with_delay); | ||
|
||
crashMainThreadButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
throw new RuntimeException("I'm a cool exception and I crashed the main thread!"); | ||
} | ||
}); | ||
|
||
crashBgThreadButton.setOnClickListener(new View.OnClickListener() { | ||
@SuppressLint("StaticFieldLeak") //For demo purposes we don't care about leaks | ||
@Override | ||
public void onClick(View view) { | ||
new AsyncTask<Void, Void, Void>() { | ||
@Override | ||
protected Void doInBackground(Void... voids) { | ||
throw new RuntimeException("I'm also cool, and I crashed the background thread!"); | ||
} | ||
}.execute(); | ||
} | ||
}); | ||
|
||
crashWithDelayButton.setOnClickListener(new View.OnClickListener() { | ||
@SuppressLint("StaticFieldLeak") //For demo purposes we don't care about leaks | ||
@Override | ||
public void onClick(View view) { | ||
new AsyncTask<Void, Void, Void>() { | ||
@Override | ||
protected Void doInBackground(Void... voids) { | ||
try { | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
//meh | ||
} | ||
throw new RuntimeException("I am a not so cool exception, and I am delayed, so you can check if the app crashes when in background!"); | ||
} | ||
}.execute(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context=".activity.ActivityOnCrash"> | ||
|
||
<com.tamsiree.rxui.view.RxTitle | ||
android:id="@+id/rx_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="@dimen/dp_55" | ||
android:background="@color/colorPrimary" | ||
app:title="Hold住崩溃界面" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center_horizontal" | ||
android:orientation="vertical" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:paddingBottom="20dp" | ||
android:text="@string/hello" /> | ||
|
||
<Button | ||
android:id="@+id/button_crash_main_thread" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/crash_main_thread" /> | ||
|
||
<Button | ||
android:id="@+id/button_crash_bg_thread" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/crash_background_thread" /> | ||
|
||
<Button | ||
android:id="@+id/button_crash_with_delay" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/crash_with_delay" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.