Skip to content

Commit

Permalink
✨ add season bangumi list.
Browse files Browse the repository at this point in the history
  • Loading branch information
iota9star committed Nov 21, 2020
1 parent 7e77d77 commit 625798d
Show file tree
Hide file tree
Showing 39 changed files with 1,373 additions and 611 deletions.
35 changes: 35 additions & 0 deletions lib/internal/extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@ extension IterableExt<T> on Iterable<T> {
if (this.isNullOrEmpty) return null;
return this.elementAt(index);
}

bool eq(Iterable<T> other) {
if (this == null) return other == null;
if (other == null || this.length != other.length) return false;
if (!identical(this, other)) return false;
for (int index = 0; index < this.length; index += 1) {
if (this.elementAt(index) != other.elementAt(index)) return false;
}
return true;
}

bool ne(Iterable<T> other) => !this.eq(other);
}

extension ListExt<T> on List<T> {
bool get isNullOrEmpty => this == null || this.isEmpty;

bool get isSafeNotEmpty => !this.isNullOrEmpty;

T getOrNull(final int index) {
if (this.isNullOrEmpty) return null;
return this[index];
}

bool eq(List<T> other) {
if (this == null) return other == null;
if (other == null || this.length != other.length) return false;
if (!identical(this, other)) return false;
for (int index = 0; index < this.length; index += 1) {
if (this[index] != other[index]) return false;
}
return true;
}

bool ne(List<T> other) => !this.eq(other);
}

extension MapExt<K, V> on Map<K, V> {
Expand Down
6 changes: 5 additions & 1 deletion lib/internal/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ class _Http extends DioForNative {
logPrint: (obj) => logd(obj),
),
)
..add(CookieManager(PersistCookieJar(dir: cacheDir + "/cookies")));
..add(
CookieManager(
PersistCookieJar(dir: cacheDir + "/cookies"),
),
);

this.transformer = MikanTransformer();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class Resolver {
return SearchResult(
bangumis: bangumis,
subgroups: subgroups,
searchs: searchs,
records: searchs,
);
}

Expand Down
17 changes: 16 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,27 @@ import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

main() async {
WidgetsFlutterBinding.ensureInitialized();
CustomWidgetsFlutterBinding.ensureInitialized();
await _initFirebase();
await Store.init();
runApp(MyApp());
}

class CustomWidgetsFlutterBinding extends WidgetsFlutterBinding {
@override
ImageCache createImageCache() {
final ImageCache imageCache = super.createImageCache();
imageCache.maximumSize = 72;
imageCache.maximumSizeBytes = 72 * 1024 * 1024; // 72MB
return imageCache;
}

static WidgetsBinding ensureInitialized() {
if (WidgetsBinding.instance == null) CustomWidgetsFlutterBinding();
return WidgetsBinding.instance;
}
}

Future _initFirebase() async {
await Firebase.initializeApp();

Expand Down
13 changes: 11 additions & 2 deletions lib/mikan_flutter_route.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions lib/mikan_flutter_routes.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/model/bangumi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,15 @@ class Location {
final int row;

const Location(this.srow, this.row);

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Location &&
runtimeType == other.runtimeType &&
srow == other.srow &&
row == other.row;

@override
int get hashCode => srow.hashCode ^ row.hashCode;
}
23 changes: 23 additions & 0 deletions lib/model/bangumi_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,27 @@ class BangumiDetails {
Map<String, String> more;
String intro;
List<SubgroupBangumi> subgroupBangumis;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BangumiDetails &&
runtimeType == other.runtimeType &&
id == other.id &&
cover == other.cover &&
name == other.name &&
subscribed == other.subscribed &&
more == other.more &&
intro == other.intro &&
subgroupBangumis == other.subgroupBangumis;

@override
int get hashCode =>
id.hashCode ^
cover.hashCode ^
name.hashCode ^
subscribed.hashCode ^
more.hashCode ^
intro.hashCode ^
subgroupBangumis.hashCode;
}
10 changes: 10 additions & 0 deletions lib/model/bangumi_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@ class BangumiRow {
this.subscribedUpdatedNum,
this.bangumis,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BangumiRow &&
runtimeType == other.runtimeType &&
name == other.name;

@override
int get hashCode => name.hashCode;
}
11 changes: 11 additions & 0 deletions lib/model/carousel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ class Carousel {
this.id,
this.cover,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Carousel &&
runtimeType == other.runtimeType &&
id == other.id &&
cover == other.cover;

@override
int get hashCode => id.hashCode ^ cover.hashCode;
}
19 changes: 19 additions & 0 deletions lib/model/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,23 @@ class Index {
this.carousels,
this.user,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Index &&
runtimeType == other.runtimeType &&
years == other.years &&
bangumiRows == other.bangumiRows &&
rss == other.rss &&
carousels == other.carousels &&
user == other.user;

@override
int get hashCode =>
years.hashCode ^
bangumiRows.hashCode ^
rss.hashCode ^
carousels.hashCode ^
user.hashCode;
}
31 changes: 31 additions & 0 deletions lib/model/record_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,35 @@ class RecordDetails {
// 种子下载地址
String torrent;
List<String> tags;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RecordDetails &&
runtimeType == other.runtimeType &&
id == other.id &&
cover == other.cover &&
name == other.name &&
subscribed == other.subscribed &&
more == other.more &&
intro == other.intro &&
url == other.url &&
title == other.title &&
magnet == other.magnet &&
torrent == other.torrent &&
tags == other.tags;

@override
int get hashCode =>
id.hashCode ^
cover.hashCode ^
name.hashCode ^
subscribed.hashCode ^
more.hashCode ^
intro.hashCode ^
url.hashCode ^
title.hashCode ^
magnet.hashCode ^
torrent.hashCode ^
tags.hashCode;
}
16 changes: 14 additions & 2 deletions lib/model/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ import 'package:mikan_flutter/model/subgroup.dart';
class SearchResult {
List<Bangumi> bangumis;
List<Subgroup> subgroups;
List<RecordItem> searchs;
List<RecordItem> records;

SearchResult({
this.bangumis,
this.subgroups,
this.searchs,
this.records,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is SearchResult &&
runtimeType == other.runtimeType &&
bangumis == other.bangumis &&
subgroups == other.subgroups &&
records == other.records;

@override
int get hashCode => bangumis.hashCode ^ subgroups.hashCode ^ records.hashCode;
}
19 changes: 19 additions & 0 deletions lib/model/season_bangumi_rows.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:mikan_flutter/model/bangumi_row.dart';
import 'package:mikan_flutter/model/season.dart';

class SeasonBangumis{
Season season;
List<BangumiRow> bangumiRows;

SeasonBangumis({this.season, this.bangumiRows});

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is SeasonBangumis &&
runtimeType == other.runtimeType &&
season == other.season;

@override
int get hashCode => season.hashCode;
}
17 changes: 17 additions & 0 deletions lib/model/season_gallery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,21 @@ class SeasonGallery {
this.isCurrentSeason,
this.bangumis,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is SeasonGallery &&
runtimeType == other.runtimeType &&
date == other.date &&
season == other.season &&
isCurrentSeason == other.isCurrentSeason &&
bangumis == other.bangumis;

@override
int get hashCode =>
date.hashCode ^
season.hashCode ^
isCurrentSeason.hashCode ^
bangumis.hashCode;
}
11 changes: 11 additions & 0 deletions lib/model/subgroup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ class Subgroup {
this.id,
this.name,
});

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Subgroup &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name;

@override
int get hashCode => id.hashCode ^ name.hashCode;
}
Loading

0 comments on commit 625798d

Please sign in to comment.