Skip to content

Commit 0d78682

Browse files
Code cleanup for show method
Concerns are now more separated for the SplashScreen#show methods.
1 parent a6ab78b commit 0d78682

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Create a style definition for this in `android/app/src/main/res/values/colors.xm
233233

234234
Change your `show` method to include your custom style:
235235
```java
236-
SplashScreen.show(this, false, R.style.SplashScreenTheme);
236+
SplashScreen.show(this, R.style.SplashScreenTheme);
237237
```
238238

239239
### iOS

android/src/main/java/org/devio/rn/splashscreen/SplashScreen.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,20 @@
1414
* Email:crazycodeboy@gmail.com
1515
*/
1616
public class SplashScreen {
17-
private static int NULL_ID = 0;
1817
private static Dialog mSplashDialog;
1918
private static WeakReference<Activity> mActivity;
2019

2120
/**
2221
* 打开启动屏
2322
*/
24-
public static void show(final Activity activity, final boolean fullScreen, final int themeResId) {
23+
public static void show(final Activity activity, final int themeResId) {
2524
if (activity == null) return;
2625
mActivity = new WeakReference<Activity>(activity);
2726
activity.runOnUiThread(new Runnable() {
2827
@Override
2928
public void run() {
3029
if (!activity.isFinishing()) {
31-
32-
mSplashDialog = new Dialog(
33-
activity,
34-
themeResId != NULL_ID ? themeResId
35-
: fullScreen ? R.style.SplashScreen_Fullscreen
36-
: R.style.SplashScreen_SplashTheme
37-
);
30+
mSplashDialog = new Dialog(activity, themeResId);
3831
mSplashDialog.setContentView(R.layout.launch_screen);
3932
mSplashDialog.setCancelable(false);
4033

@@ -50,7 +43,9 @@ public void run() {
5043
* 打开启动屏
5144
*/
5245
public static void show(final Activity activity, final boolean fullScreen) {
53-
show(activity, fullScreen, 0);
46+
int resourceId = fullScreen ? R.style.SplashScreen_Fullscreen : R.style.SplashScreen_SplashTheme;
47+
48+
show(activity, resourceId);
5449
}
5550

5651
/**

0 commit comments

Comments
 (0)