Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 38f684a

Browse files
committed
android splash screen
1 parent d08cbfa commit 38f684a

20 files changed

+339
-95
lines changed

android/app/app-release.apk

1.2 KB
Binary file not shown.

android/app/src/main/assets/index.android.bundle

+33-31
Large diffs are not rendered by default.
Binary file not shown.

android/app/src/main/java/com/gankio/MainActivity.java

+8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
package com.gankio;
22

3+
import android.os.Bundle;
4+
35
import com.facebook.react.ReactActivity;
6+
import com.gankio.util.SplashScreen;
47

58
public class MainActivity extends ReactActivity {
9+
@Override
10+
protected void onCreate(Bundle savedInstanceState) {
11+
SplashScreen.show(this, true);
12+
super.onCreate(savedInstanceState);
13+
}
614

715
/**
816
* Returns the name of the main component registered from JavaScript.

android/app/src/main/java/com/gankio/MainApplication.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ protected boolean getUseDeveloperSupport() {
2525
protected List<ReactPackage> getPackages() {
2626
return Arrays.<ReactPackage>asList(
2727
new MainReactPackage(),
28-
new VectorIconsPackage()
28+
new VectorIconsPackage(),
29+
new MyReactPackage()
2930
);
3031
}
3132
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.gankio;
2+
3+
import com.facebook.react.ReactPackage;
4+
import com.facebook.react.bridge.JavaScriptModule;
5+
import com.facebook.react.bridge.NativeModule;
6+
import com.facebook.react.bridge.ReactApplicationContext;
7+
import com.facebook.react.uimanager.ViewManager;
8+
import com.gankio.util.SplashScreenModule;
9+
10+
import java.util.ArrayList;
11+
import java.util.Collections;
12+
import java.util.List;
13+
14+
/**
15+
* Created by wangdi on 14/11/16.
16+
*/
17+
18+
public class MyReactPackage implements ReactPackage{
19+
@Override
20+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
21+
List<NativeModule> list = new ArrayList<>();
22+
list.add(new SplashScreenModule(reactContext));
23+
return list;
24+
}
25+
26+
@Override
27+
public List<Class<? extends JavaScriptModule>> createJSModules() {
28+
return Collections.emptyList();
29+
}
30+
31+
@Override
32+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
33+
return Collections.emptyList();
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.gankio.util;
2+
3+
import android.app.Activity;
4+
import android.app.Dialog;
5+
import java.lang.ref.WeakReference;
6+
7+
import com.gankio.R;
8+
9+
/**
10+
* Created by wangdi on 14/11/16.
11+
*/
12+
13+
public class SplashScreen {
14+
private static Dialog mSplashDialog;
15+
private static WeakReference<Activity> mActivity;
16+
17+
public static void show(final Activity activity, final boolean fullScreen){
18+
if (activity == null) return;
19+
mActivity = new WeakReference<Activity>(activity);
20+
activity.runOnUiThread(new Runnable() {
21+
@Override
22+
public void run() {
23+
if (!activity.isFinishing()) {
24+
25+
mSplashDialog = new Dialog(activity, fullScreen ? R.style.SplashScreen_Fullscreen: R.style.SplashScreen_SplashTheme);
26+
mSplashDialog.setContentView(R.layout.launch_screen);
27+
mSplashDialog.setCancelable(false);
28+
29+
if (!mSplashDialog.isShowing()) {
30+
mSplashDialog.show();
31+
}
32+
}
33+
}
34+
});
35+
}
36+
37+
public static void hide(Activity activity){
38+
if (activity == null) activity = mActivity.get();
39+
if (activity == null) return;
40+
41+
activity.runOnUiThread(new Runnable() {
42+
@Override
43+
public void run() {
44+
if (mSplashDialog != null && mSplashDialog.isShowing()) {
45+
mSplashDialog.dismiss();
46+
}
47+
}
48+
});
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.gankio.util;
2+
3+
import android.app.Activity;
4+
import android.app.Dialog;
5+
6+
import com.facebook.react.bridge.ReactApplicationContext;
7+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
8+
import com.facebook.react.bridge.ReactMethod;
9+
10+
import java.lang.ref.WeakReference;
11+
12+
/**
13+
* Created by wangdi on 14/11/16.
14+
*/
15+
16+
public class SplashScreenModule extends ReactContextBaseJavaModule{
17+
18+
19+
public SplashScreenModule(ReactApplicationContext reactContext) {
20+
super(reactContext);
21+
}
22+
23+
@Override
24+
public String getName() {
25+
return "SplashScreen";
26+
}
27+
28+
@ReactMethod
29+
public void hide(){
30+
SplashScreen.hide(getCurrentActivity());
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="#fff">
6+
<ImageView
7+
android:layout_width="80dp"
8+
android:layout_height="80dp"
9+
android:src="@drawable/js_assets_icon"
10+
android:id="@+id/logo"
11+
android:layout_centerHorizontal="true"
12+
android:layout_marginTop="130dp"/>
13+
14+
<TextView
15+
android:layout_width="wrap_content"
16+
android:layout_height="wrap_content"
17+
android:layout_below="@id/logo"
18+
android:text="干货集中营"
19+
android:textSize="20dp"
20+
android:layout_centerHorizontal="true"
21+
android:layout_marginTop="10dp"
22+
android:textColor="#000"/>
23+
24+
<TextView
25+
android:layout_width="wrap_content"
26+
android:layout_height="wrap_content"
27+
android:layout_centerHorizontal="true"
28+
android:layout_alignParentBottom="true"
29+
android:text="获取每日技术干货"
30+
android:textSize="16dp"
31+
android:textColor="#666"
32+
android:layout_marginBottom="50dp"/>
33+
34+
</RelativeLayout>

android/app/src/main/res/values/styles.xml

+12
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,16 @@
55
<!-- Customize your theme here. -->
66
</style>
77

8+
<style name="SplashScreen_SplashAnimation">
9+
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
10+
</style>
11+
12+
<style name="SplashScreen_SplashTheme" parent="Theme.AppCompat.NoActionBar">
13+
<item name="android:windowAnimationStyle">@style/SplashScreen_SplashAnimation</item>
14+
</style>
15+
16+
<style name="SplashScreen_Fullscreen" parent="SplashScreen_SplashTheme">
17+
<item name="android:windowFullscreen">true</item>
18+
</style>
19+
820
</resources>

js/App.js

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React from 'react';
88
import {Navigator} from 'react-native';
99
import {store} from './store/index';
1010
import MainPage from './containers/MainPage';
11+
import SplashScreen from './native_modules/SplashScreen';
1112
import Test from './containers/DiscoveryTab/GirlsPage'
1213

1314
export default class App extends React.Component{
@@ -23,4 +24,8 @@ export default class App extends React.Component{
2324
</Provider>
2425
);
2526
}
27+
28+
componentDidMount(){
29+
SplashScreen.hide();
30+
}
2631
}

js/assets/avatar.jpg

39.9 KB
Loading

js/assets/model.png

-51.8 KB
Loading

js/components/ListViewForGirls.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ class ListViewForGirls extends Component{
4747
onRequestClose={this._triggerModal.bind(this)}
4848
transparent={true}>
4949
<View style={styles.modalBackground}>
50-
<View style={styles.closeBtn}>
51-
<TouchableOpacity
52-
onPress={this._triggerModal.bind(this)}
53-
activeOpacity={theme.touchableOpacityActiveOpacity}>
54-
<Icon name="ios-close-circle-outline" color="#fff" size={px2dp(30)}/>
55-
</TouchableOpacity>
56-
</View>
5750
{this.state.loadedHD ?
5851
<View>
5952
<Image style={{width: this.state.imageWidth, height: this.state.imageHeight}}
@@ -62,6 +55,13 @@ class ListViewForGirls extends Component{
6255
:
6356
<ActivityIndicator size="large" color={this.props.tabIconColor}/>
6457
}
58+
<View style={styles.closeBtn}>
59+
<TouchableOpacity
60+
onPress={this._triggerModal.bind(this)}
61+
activeOpacity={theme.touchableOpacityActiveOpacity}>
62+
<Icon name="ios-close-circle-outline" color="#fff" size={px2dp(30)}/>
63+
</TouchableOpacity>
64+
</View>
6565
</View>
6666
</Modal>
6767
</View>
@@ -169,7 +169,8 @@ const styles = StyleSheet.create({
169169
alignItems: 'flex-end',
170170
justifyContent: 'flex-start',
171171
paddingTop: px2dp(20),
172-
paddingRight: px2dp(20)
172+
paddingRight: px2dp(20),
173+
zIndex: 1
173174
}
174175
});
175176

js/containers/MainPage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BottomTabBar extends Component{
4141
}
4242

4343
_renderItem(Component, tab, tabName, normalIcon, selectedIcon){
44-
const {navigator, mainThemeColor, tabIconColor} = this.props;
44+
const {navigator, tabIconColor} = this.props;
4545
return(
4646
<TabNavigator.Item
4747
selected={this.state.selectedTab === tab}

js/containers/MoreTab/AboutAuthor/index.js

-43
This file was deleted.

0 commit comments

Comments
 (0)