Skip to content

Commit

Permalink
fix(stats): 统计数据分块存储
Browse files Browse the repository at this point in the history
  • Loading branch information
smallpath committed Nov 13, 2017
1 parent 6e70c13 commit d8cc1b5
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 58 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Expand Up @@ -23,6 +23,7 @@
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
Expand Down
12 changes: 12 additions & 0 deletions psnine/component/DiskStorage/index.ts
Expand Up @@ -47,6 +47,18 @@ export default class DiskStorage {
}
}

async removeItem(key) {
const filePath = this.psnineFolder + `/${en(key)}.json`
try {
await fs.unlink(filePath)
// console.log(content)
return true
} catch (err) {
// console.log(err)
return false
}
}

async removeAll() {
await fs.unlink(this.psnineFolder).catch(() => {})
await fs.mkdir(this.psnineFolder)
Expand Down
2 changes: 1 addition & 1 deletion psnine/component/TrophyItem.tsx
Expand Up @@ -82,7 +82,7 @@ export default class extends React.PureComponent<ExtendedProp, {}> {
textAlign: 'center',
textAlignVertical: 'center',
fontSize: 10
}}>{rowData.rare ? '珍惜度' : ''}</Text>
}}>{rowData.rare ? '珍稀度' : ''}</Text>
{ rowData.time && (
<View style={{ flex: 1, justifyContent: 'center', padding: 2 }}>
<Text selectable={false} style={{
Expand Down
2 changes: 1 addition & 1 deletion psnine/container/game/Game.tsx
Expand Up @@ -366,7 +366,7 @@ export default class GamePage extends Component<any, any> {
textAlign: 'center',
textAlignVertical: 'center',
fontSize: 10
}}>{rowData.rare ? '珍惜度' : ''}</Text>
}}>{rowData.rare ? '珍稀度' : ''}</Text>
</View>
</View>
</TouchableNativeFeedback>
Expand Down
3 changes: 1 addition & 2 deletions psnine/container/game/NewGame.android.tsx
Expand Up @@ -67,7 +67,7 @@ export default class Home extends Component<any, any> {
onActionSelected: this._onActionSelected,
leftIcon: false,
rightIcon: false,
_scrollHeight: this.props.screenProps.modeInfo.height - (StatusBar.currentHeight || 0 ) - 56
_scrollHeight: this.props.screenProps.modeInfo.height - 74
}
}

Expand Down Expand Up @@ -311,7 +311,6 @@ export default class Home extends Component<any, any> {
_scrollHeight = (
ExtraDimensionsAndroid.getStatusBarHeight() +
ExtraDimensionsAndroid.getAppClientHeight() -
ExtraDimensionsAndroid.getStatusBarHeight() -
56
)

Expand Down
10 changes: 6 additions & 4 deletions psnine/container/statistics/Stats.android.tsx
Expand Up @@ -16,7 +16,7 @@ import {
import { connect } from 'react-redux'

import { getTrophyList } from '../../redux/action/stats'
import { removeAll } from '../../utils/statistics'
import { removeAll, removeItem } from '../../utils/statistics'

import Ionicons from 'react-native-vector-icons/Ionicons'
import {
Expand Down Expand Up @@ -79,7 +79,7 @@ class StatsHome extends Component<any, any> {
middleIcon: false,
statsInfo: {},
unearnedTrophyList: [],
_scrollHeight: this.props.screenProps.modeInfo.height - (StatusBar.currentHeight || 0) - 56 + 1
_scrollHeight: this.props.screenProps.modeInfo.height - 64
}
}

Expand Down Expand Up @@ -329,13 +329,15 @@ class StatsHome extends Component<any, any> {
)
}

_onActionSelected = (index) => {
_onActionSelected = async (index) => {
switch (index) {
case 0:
this.preFetch(true)
return
case 1:
return removeAll()
const { params } = this.props.navigation.state
const data = await getHomeAPI(params.URL)
return removeItem(data.playerInfo.psnid)
}
}

Expand Down
8 changes: 5 additions & 3 deletions psnine/container/statistics/Stats.ios.tsx
Expand Up @@ -15,7 +15,7 @@ import {
import { connect } from 'react-redux'

import { getTrophyList } from '../../redux/action/stats'
import { removeAll } from '../../utils/statistics'
import { removeAll, removeItem } from '../../utils/statistics'

import Interactable from 'react-native-interactable'

Expand Down Expand Up @@ -181,13 +181,15 @@ class StatsHome extends Component<any, any> {
]
})

_onActionSelected = (index) => {
_onActionSelected = async (index) => {
switch (index) {
case 0:
this.preFetch(true)
return
case 1:
return removeAll()
const { params } = this.props.navigation.state
const data = await getHomeAPI(params.URL)
return removeItem(data.playerInfo.psnid)
}
}

Expand Down
2 changes: 1 addition & 1 deletion psnine/container/user/Home.android.tsx
Expand Up @@ -77,7 +77,7 @@ export default class Home extends Component<any, any> {
leftIcon: false,
rightIcon: false,
middleIcon: false,
_scrollHeight: this.props.screenProps.modeInfo.height - (StatusBar.currentHeight || 0) - 56 + 1
_scrollHeight: this.props.screenProps.modeInfo.height - 64
}
}

Expand Down

0 comments on commit d8cc1b5

Please sign in to comment.