forked from crazycodeboy/react-native-splash-screen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from shivamvk/shivamvk-patch-1
Update SplashScreen.java
- Loading branch information
Showing
1 changed file
with
21 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -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); | ||
} | ||
|
||
/** | ||
|
@@ -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; | ||
|
||
|