diff --git a/AnimeGo/android/app/build.gradle b/AnimeGo/android/app/build.gradle index 14940b9..a4adf86 100644 --- a/AnimeGo/android/app/build.gradle +++ b/AnimeGo/android/app/build.gradle @@ -98,11 +98,11 @@ android { buildToolsVersion "23.0.3" defaultConfig { - applicationId "com.yihengquan.gogoanime" + applicationId "com.yihengquan.gogoanime.debug" minSdkVersion 16 targetSdkVersion 25 - versionCode 8 - versionName "1.0.747" + versionCode 9 + versionName "1.0.77777" ndk { abiFilters "armeabi-v7a", "x86" } diff --git a/AnimeGo/src/app/App.android.js b/AnimeGo/src/app/App.android.js index bd4f5a0..498a9bc 100644 --- a/AnimeGo/src/app/App.android.js +++ b/AnimeGo/src/app/App.android.js @@ -9,7 +9,7 @@ import { ScrollView, View, Image, Text, StatusBar, DrawerLayoutAndroid, ToastAnd import { Router, Scene, Actions } from 'react-native-router-flux'; import { DrawerCell, SmartTouchable } from '../component'; import { Divider, Button, Icon } from 'react-native-elements'; -import { NewRelease, NewSeason, Movie, Popular, Genre, Setting, GenreInfo, WatchAnime, AnimeDetail, SearchAnime, SubCategory, ToWatch } from '../screen'; +import { NewRelease, NewSeason, Movie, Popular, Genre, Setting, GenreInfo, WatchAnime, AnimeDetail, SearchAnime, SubCategory, ToWatch, Schedule } from '../screen'; import { AnimeGoColour, StatusBarColour, ScreenIndex } from '../value'; import { styles } from './AppStyle'; import { DataManager } from '../helper/'; @@ -33,6 +33,8 @@ export default class App extends Component { + + @@ -62,7 +64,7 @@ export default class App extends Component { this.onChangingScreen(ScreenIndex.NewRelease)}/> this.onChangingScreen(ScreenIndex.NewSeason)}/> - + this.onChangingScreen(ScreenIndex.Schedule)}/> this.onChangingScreen(ScreenIndex.Movie)}/> this.onChangingScreen(ScreenIndex.Popular)}/> @@ -112,6 +114,8 @@ export default class App extends Component { Actions.Setting(); break; case ScreenIndex.ToWatch: Actions.ToWatch(); break; + case ScreenIndex.Schedule: + Actions.Schedule(); break; } this.refs['Drawer'].closeDrawer(); } diff --git a/AnimeGo/src/helper/core/AnimeSchedule.js b/AnimeGo/src/helper/core/AnimeSchedule.js new file mode 100644 index 0000000..22bb0cd --- /dev/null +++ b/AnimeGo/src/helper/core/AnimeSchedule.js @@ -0,0 +1,45 @@ +import { MajorLink } from '../../value'; +import { Alert } from 'react-native'; + +export default class AnimeSchedule { + getScheduleForToday() { + return new Promise((success, failure) => { + // Loading data here + let weekdays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; + fetch(MajorLink.Schedule).then((html) => html.text()).then((htmlText) => { + var HTMLParser = require('fast-html-parser'); + let weekdayClass = '.js-seasonal-anime-list-key-' + weekdays[new Date().getDay() - 1]; + var root = HTMLParser.parse(htmlText).querySelector(weekdayClass); + // Somehow, nothing is found + if (root == null) success([]); + + var animeSchedule = []; + for (var i = 0; i < root.childNodes.length; i++) { + var curr = root.childNodes[i]; + // Ignore whitespaces and header + if (curr.isWhitespace || curr.classNames[0] == 'anime-header') continue; + curr = curr.childNodes; + console.log(curr); + let name = this.cleanText(curr[2].text); + var link = ''; let linkPath = curr[0].childNodes[1].childNodes; + if (linkPath[1].isWhitespace) link = linkPath[0].childNodes[1].attributes.href; + else link = linkPath[1].childNodes[1].attributes.href; + let time = this.cleanText(curr[6].childNodes[1].text).split(' -')[1]; + let rating = '⭐️ ' + this.cleanText(curr[6].childNodes[3].childNodes[3].text); + animeSchedule.push({name: name, link: link, time: time, rating: rating}); + } + console.log(animeSchedule); + success(animeSchedule); + }).catch((error) => { + // console.error(error); + Alert.alert('Error', 'Schedule not found'); + failure(error); + }); + }) + } + + cleanText(input) { + var noNextLine = input.split('\n').join(' '); + return noNextLine.split(' ').join(''); + } +} \ No newline at end of file diff --git a/AnimeGo/src/screen/Schedule.js b/AnimeGo/src/screen/Schedule.js new file mode 100644 index 0000000..c45c7a3 --- /dev/null +++ b/AnimeGo/src/screen/Schedule.js @@ -0,0 +1,57 @@ +import React, { Component } from 'react'; +import { View, FlatList, Text, Linking } from 'react-native'; +import { styles } from './ScheduleStyles'; +import AnimeSchedule from '../helper/core/AnimeSchedule'; +import { LoadingIndicator, SmartTouchable } from '../component'; + +class Schedule extends Component { + constructor() { + super(); + this.state = { + data: [], isReady: false, noAnime: false + } + } + + componentWillMount() { + let schedule = new AnimeSchedule(); + schedule.getScheduleForToday().then((scheduleList) => { + if (scheduleList == []) { + this.setState({noAnime: true, isReady: true}) + } else { + this.setState({data: scheduleList, isReady: true}) + } + }) + } + + scheduleKey = (data) => data.name; + render() { + const { data, isReady, noAnime } = this.state; + const { mainViewStyle, noAnimeStyle, textStyle, cellViewStyle, titleStyle, infoStyle, timeStyle } = styles; + if (isReady == false) return + else if (noAnime) { + return ( + + No Anime today 0_0 + + ) + } else return ( + + { + return ( + + Linking.openURL(item.link)}> + + {item.name} + {item.time + ' ' + item.rating } + + + + ) + }} automaticallyAdjustContentInsets={false} showsVerticalScrollIndicator={false} + ListHeaderComponent={Data are from MyAnimeList} /> + + ) + } +} + +export {Schedule}; \ No newline at end of file diff --git a/AnimeGo/src/screen/ScheduleStyles.js b/AnimeGo/src/screen/ScheduleStyles.js new file mode 100644 index 0000000..aac6c8f --- /dev/null +++ b/AnimeGo/src/screen/ScheduleStyles.js @@ -0,0 +1,32 @@ +import { StyleSheet } from 'react-native'; +import { BlueColour } from '../value'; + +export const styles = StyleSheet.create({ + noAnimeStyle: { + flex: 1, + justifyContent: 'center' + }, + mainViewStyle: { + flex: 1 + }, + textStyle: { + textAlign: 'center', + color: BlueColour, + fontSize: 16 + }, + cellViewStyle: { + flex: 1, + padding: 8 + }, + titleStyle: { + textAlign: 'center', + color: 'black', + fontSize: 20 + }, + infoStyle: { + textAlign: 'center' + }, + timeStyle: { + textAlign: 'center' + } +}) \ No newline at end of file diff --git a/AnimeGo/src/screen/ToWatch.js b/AnimeGo/src/screen/ToWatch.js index 7b8f508..6ff2a80 100644 --- a/AnimeGo/src/screen/ToWatch.js +++ b/AnimeGo/src/screen/ToWatch.js @@ -26,7 +26,7 @@ class ToWatch extends Component { ) - }} automaticallyAdjustContentInsets={false}/> + }} automaticallyAdjustContentInsets={false} showsVerticalScrollIndicator={false}/>