Skip to content

Commit

Permalink
Merge pull request #1 from shivamvk/shivamvk-patch-1
Browse files Browse the repository at this point in the history
Update SplashScreen.java
  • Loading branch information
shivamvk authored Sep 19, 2021
2 parents d4e860d + 2c22658 commit 405c81a
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions android/src/main/java/org/devio/rn/splashscreen/SplashScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import android.app.Activity;
import android.app.Dialog;
import android.os.Build;
import android.widget.VideoView;
import android.net.Uri;
import android.util.DisplayMetrics;

import java.lang.ref.WeakReference;
import java.net.URI;

/**
* SplashScreen
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Email:[email protected]
* SplashScreen 启动屏 from:http://www.devio.org Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy Email:[email protected]
*/
public class SplashScreen {
private static Dialog mSplashDialog;
Expand All @@ -21,19 +21,25 @@ public class SplashScreen {
/**
* 打开启动屏
*/
public static void show(final Activity activity, final int themeResId) {
if (activity == null) return;
public static void show(final Activity activity, final int themeResId, final boolean isvideoSplash) {
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);
mSplashDialog.setContentView(R.layout.launch_screen);
mSplashDialog.setCancelable(false);

if (!mSplashDialog.isShowing()) {
mSplashDialog.show();
if(isvideoSplash){
String path = "android.resource://" + activity.getPackageName() + "/" + R.raw.splash_video;
VideoView mVideoView = (VideoView) mSplashDialog.findViewById(R.id.simpleVideoView);
mVideoView.setVideoURI(Uri.parse(path));
mVideoView.start();
mSplashDialog.setCancelable(false);
}
}
}
}
Expand All @@ -43,17 +49,17 @@ public void run() {
/**
* 打开启动屏
*/
public static void show(final Activity activity, final boolean fullScreen) {
public static void show(final Activity activity, final boolean fullScreen, final boolean isvideoSplash) {
int resourceId = fullScreen ? R.style.SplashScreen_Fullscreen : R.style.SplashScreen_SplashTheme;

show(activity, resourceId);
show(activity, resourceId, isvideoSplash);
}

/**
* 打开启动屏
*/
public static void show(final Activity activity) {
show(activity, false);
show(activity, false, false);
}

/**
Expand All @@ -67,7 +73,8 @@ public static void hide(Activity activity) {
activity = mActivity.get();
}

if (activity == null) return;
if (activity == null)
return;

final Activity _activity = activity;

Expand Down

0 comments on commit 405c81a

Please sign in to comment.