Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Code cleanup for show method #176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Create a style definition for this in `android/app/src/main/res/values/colors.xm

Change your `show` method to include your custom style:
```java
SplashScreen.show(this, false, R.style.SplashScreenTheme);
SplashScreen.show(this, R.style.SplashScreenTheme);
```

### iOS
Expand Down
15 changes: 5 additions & 10 deletions android/src/main/java/org/devio/rn/splashscreen/SplashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,20 @@
* Email:crazycodeboy@gmail.com
*/
public class SplashScreen {
private static int NULL_ID = 0;
private static Dialog mSplashDialog;
private static WeakReference<Activity> mActivity;

/**
* 打开启动屏
*/
public static void show(final Activity activity, final boolean fullScreen, final int themeResId) {
public static void show(final Activity activity, final int themeResId) {
if (activity == null) return;
mActivity = new WeakReference<Activity>(activity);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!activity.isFinishing()) {

mSplashDialog = new Dialog(
activity,
themeResId != NULL_ID ? themeResId
: fullScreen ? R.style.SplashScreen_Fullscreen
: R.style.SplashScreen_SplashTheme
);
mSplashDialog = new Dialog(activity, themeResId);
mSplashDialog.setContentView(R.layout.launch_screen);
mSplashDialog.setCancelable(false);

Expand All @@ -50,7 +43,9 @@ public void run() {
* 打开启动屏
*/
public static void show(final Activity activity, final boolean fullScreen) {
show(activity, fullScreen, 0);
int resourceId = fullScreen ? R.style.SplashScreen_Fullscreen : R.style.SplashScreen_SplashTheme;

show(activity, resourceId);
}

/**
Expand Down