Skip to content

Commit

Permalink
Merge pull request #41 from febobo/develop
Browse files Browse the repository at this point in the history
optimize listview
  • Loading branch information
febobo authored Jul 4, 2016
2 parents 74a5545 + 76b3bd1 commit cf07aa8
Show file tree
Hide file tree
Showing 31 changed files with 738 additions and 32 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ android {
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.feinn"
applicationId "com.Feinn"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
Expand Down
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/FeInn/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
* on the same Wi-Fi network.
*/

jsCodeLocation = [NSURL URLWithString:@"http://192.168.1.83:8081/index.ios.bundle?platform=ios&dev=true"];
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

/**
* OPTION 2
Expand Down
Binary file added ios/FeInn/Images.xcassets/48.imageset/48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions ios/FeInn/Images.xcassets/48.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "48.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added ios/FeInn/Images.xcassets/96.imageset/96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions ios/FeInn/Images.xcassets/96.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "96.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
11 changes: 9 additions & 2 deletions ios/FeInn/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "favicon.png",
"size" : "72x72",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 0 additions & 13 deletions ios/FeInn/Images.xcassets/chest.imageset/Contents.json

This file was deleted.

Binary file removed ios/FeInn/Images.xcassets/chest.imageset/chest.png
Binary file not shown.
21 changes: 21 additions & 0 deletions ios/FeInn/Images.xcassets/feinn.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "feinn.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions ios/FeInn/Images.xcassets/ic_launcher.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_launcher.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
596 changes: 596 additions & 0 deletions ios/bundle/index.ios.jsbundle

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"react-native-tab-navigator": "^0.3.2",
"react-native-vector-icons": "^2.0.2",
"react-native-video": "^0.8.0",
"react-native-wechat": "^1.4.6",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-actions": "^0.10.0",
Expand Down
2 changes: 1 addition & 1 deletion src/container/tabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as WelfarePage from '../page/Welfare';
import * as Login from '../page/Login';
import connectComponent from '../utils/connectComponent';
import TabNavigator from 'react-native-tab-navigator';
import iconHome from '../public/favicon.png';
// import iconHome from '../public/favicon.png';
const Essence = connectComponent(EssencePage);
const Article = connectComponent(ArticlePage);
const Welfare = connectComponent(WelfarePage);
Expand Down
35 changes: 26 additions & 9 deletions src/page/Article.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ class Article extends Component {
this.loadList()
}

shouldComponentUpdate(nextProps){
if(nextProps.Acticle.photos == this.props.Acticle.photos){
return false
}
return true
}

loadList (){
const { actions , Acticle } = this.props;
actions.getPhoto({
Expand Down Expand Up @@ -54,15 +61,17 @@ class Article extends Component {

render (){
const { Acticle } = this.props;
console.log(Acticle)
return (
<View style={[styles.container]}>
{
Acticle && Acticle.photos && Acticle.photos.length !=0 ?

<ScrollView style={{flex:1}}
onScroll={this._onScroll}
initialListSize={1}
pageSize={1}
refreshControl={
<RefreshControl
refreshing={Acticle.getPhotosIsPending || false}
refreshing={Acticle.getPhotosIsPending}
onRefresh={this._onRefresh}
tintColor="#ff0000"
title="Loading..."
Expand All @@ -71,7 +80,8 @@ class Article extends Component {
/>
}
>

{
Acticle && Acticle.photos && Acticle.photos.length !=0 ?
<View style={styles.imgsWrap}>
<View style={styles.imgs}>
{this._renderImg(Acticle.photos.slice(0,Acticle.photos.length/2))}
Expand All @@ -80,11 +90,16 @@ class Article extends Component {
{this._renderImg(Acticle.photos.slice(Acticle.photos.length/2,Acticle.photos.length))}
</View>
</View>
</ScrollView> :
<View style={{flexDirection:'row',paddingTop:30,alignItems : 'center',justifyContent : 'center'}}>
<Text style={{fontSize:20}}>说好的妹子呢</Text>
</View>
}
: null

}
{
Acticle && Acticle.getPhotosIsPending == false && Acticle.photos.length == 0 ?
<View style={{flexDirection:'row',paddingTop:30,alignItems : 'center',justifyContent : 'center'}}>
<Text style={{fontSize:20}}>说好的妹子呢</Text>
</View> :null
}
</ScrollView>
</View>
)
}
Expand Down Expand Up @@ -143,6 +158,7 @@ class Article extends Component {
<Image
style={{width:width/2,height:parseInt(Math.random() * (width/4) + (width/2))}}
source={{uri : v.url}}
defaultSource={require('../public/defaultImg.png')}
/>
</LightBox>
</TouchableOpacity>
Expand All @@ -155,6 +171,7 @@ const { width , height } = Dimensions.get('window');
const styles = StyleSheet.create({
container : {
flex : 1,
paddingBottom : 50
// alignItems : 'center',
// justifyContent : 'center',
// backgroundColor : 'blue'
Expand Down
2 changes: 2 additions & 0 deletions src/page/Detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Detail extends Component {
<Image
style={styles.authorImg}
source={{uri : data.author.avatar_url}}
defaultSource={require('../public/defaultImg.png')}
/>
</View>
<View
Expand Down Expand Up @@ -126,6 +127,7 @@ const defaultMaxImageWidth = width - 30 - 20;
const styles = StyleSheet.create({
container : {
flex : 1,
paddingBottom:Platform.OS == 'ios' ? 0 : 50,
},
wrapStyle : {
flex : 1,
Expand Down
1 change: 1 addition & 0 deletions src/page/Essence.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class Essence extends Component {
<Image
style={styles.article}
source={{uri: rowData.author.avatar_url}}
defaultSource={require('../public/defaultImg.png')}
/>
<View
style={styles.content}
Expand Down
4 changes: 3 additions & 1 deletion src/page/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ class Login extends Component {
<Image
style={[styles.userImg]}
source={{uri : User.data.avatar_url}}
defaultSource={require('../public/defaultImg.png')}
/> :
<Image
style={[styles.userImg]}
source={{uri : 'http://test.imgs.wn518.com/upimages/ys-sales/2016-03-29/87e08bb58a0a9b57bcd035fbf6bb4e02_1_0_0_420_420_1.jpg'}}
source={require('../public/defaultImg.png')}

/>
}
</View>
Expand Down
15 changes: 12 additions & 3 deletions src/page/Welfare.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Welfare extends Component {
this.loadList();
}

shouldComponentUpdate(nextProps){
if(nextProps.Welfare.videos == this.props.Welfare.videos){
return false
}
return true
}

loadList (){
const { actions , Welfare } = this.props;
actions.getVideo({
Expand All @@ -40,6 +47,7 @@ class Welfare extends Component {
}

_onEndReached (){
console.log(1)
const { actions , Welfare } = this.props;
actions.getVideo({
page : Welfare.page+1,
Expand Down Expand Up @@ -81,8 +89,8 @@ class Welfare extends Component {
<ListView
dataSource={ds.cloneWithRows(Welfare.videos || [])}
renderRow={this.renderVideoRow}
pageSize={3}
initialListSize={3}
pageSize={1}
initialListSize={1}
onEndReached={this._onEndReached}
onEndReachedThreshold={0}
removeClippedSubviews={true}
Expand Down Expand Up @@ -114,7 +122,8 @@ const styles = StyleSheet.create({
videoWrap : {
padding : 10,
borderBottomWidth : 1,
borderColor : '#eee'
borderColor : '#eee',
overflow:'hidden'
},
userImg : {
width : userImg,
Expand Down
Binary file added src/public/defaultImg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/public/favicon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion src/reducers/Acticle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as types from '../actions/actionTypes';


export default function Acticle (state={page:1,limit:10,photos:[]} , action={}){
export default function Acticle (state={page:1,limit:10,photos:[],getPhotosIsPending:true} , action={}){
const { payload ,error , meta={}} = action;
const { sequence ={} } = meta;
switch (action.type) {
Expand Down

0 comments on commit cf07aa8

Please sign in to comment.