Skip to content

Commit

Permalink
update lib
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujian1989 committed Sep 17, 2018
1 parent d54a705 commit 1b6e236
Show file tree
Hide file tree
Showing 14 changed files with 562 additions and 461 deletions.
244 changes: 130 additions & 114 deletions .idea/libraries/Dart_Packages.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .idea/libraries/Flutter_Plugins.xml

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

516 changes: 255 additions & 261 deletions .idea/workspace.xml

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions android/.idea/gradle.xml

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

2 changes: 1 addition & 1 deletion android/.idea/misc.xml

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

5 changes: 0 additions & 5 deletions android/.idea/modules.xml

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

4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
repositories {
maven { url 'https://jitpack.io' }
google()
jcenter()
maven { url 'https://jitpack.io' }
}

dependencies {
Expand All @@ -12,9 +12,9 @@ buildscript {

allprojects {
repositories {
maven { url 'https://jitpack.io' }
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/mvp/presenter/ai_presenter_impl.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter_study/mvp/presenter/ai_presenter.dart';
import 'package:flutter_study/mvp/repository/ai_repository_imlp.dart';
import 'package:flutter_study/mvp/repository/ai_repository_impl.dart';
import 'package:flutter_study/mvp/repository/ai_repository.dart';

class AIPresenterImpl implements AIPresenter {
Expand All @@ -25,6 +25,6 @@ class AIPresenterImpl implements AIPresenter {

@override
init() {
_repository = new AIRepositoryImlp();
_repository = new AIRepositoryImpl();
}
}
4 changes: 2 additions & 2 deletions lib/mvp/presenter/fl_presenter_impl.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter_study/mvp/presenter/fl_presenter.dart';
import 'package:flutter_study/mvp/repository/fl_repository_imlp.dart';
import 'package:flutter_study/mvp/repository/fl_repository_impl.dart';
import 'package:flutter_study/mvp/repository/fl_repository.dart';

class FLPresenterImpl implements FLPresenter {
Expand All @@ -25,6 +25,6 @@ class FLPresenterImpl implements FLPresenter {

@override
init() {
_repository = new FLRepositoryImlp();
_repository = new FLRepositoryImpl();
}
}
43 changes: 43 additions & 0 deletions lib/mvp/repository/ai_repository_impl.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:flutter_study/common/constant.dart';
import 'package:flutter_study/model/ai_model.dart';
import 'package:flutter_study/mvp/repository/ai_repository.dart';

class AIRepositoryImpl implements AIRepository {
@override
Future<List<AIModel>> fetch(String type, int pageNum, int pageSize) {
return _getData(type, pageNum, pageSize);
}
}

Future<List<AIModel>> _getData(String type, int pageNum, int pageSize) async {
var httpClient = new HttpClient();
var url = Constant.baseUrl + '$type/$pageSize/$pageNum';

print(url);

List aiModels;

try {
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
if (response.statusCode == HttpStatus.OK) {
var json = await response.transform(Utf8Decoder()).join();
aiModels = jsonDecode(json)['results'];

} else {
//todo
}
} catch (exception) {
//todo
}

return aiModels.map((model) {
return new AIModel.fromJson(model);
}).toList();
}


49 changes: 49 additions & 0 deletions lib/mvp/repository/fl_repository_impl.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'dart:async';
import 'package:flutter_study/model/fl_model.dart';
import 'dart:convert';
import 'dart:io';
import 'package:flutter_study/common/constant.dart';
import 'package:flutter_study/mvp/repository/fl_repository.dart';
//分类数据: http://gank.io/api/data/数据类型/请求个数/第几页
//数据类型: 福利 | Android | iOS | 休息视频 | 拓展资源 | 前端 | all
//请求个数: 数字,大于0
//第几页:数字,大于0
//@param rows
//@param pageNum
//@return


class FLRepositoryImpl implements FLRepository {
@override
Future<List<FLModel>> fetch(int pageNum,int pageSize) {
return _getData(pageNum,pageSize);
}
}

Future<List<FLModel>> _getData(int pageNum,int pageSize) async {
var httpClient = new HttpClient();
var url = Constant.baseUrl + '福利/$pageSize/$pageNum';

print(url);

List flModels;
try {
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
if (response.statusCode == HttpStatus.OK) {
var json = await response.transform(Utf8Decoder()).join();
flModels = jsonDecode(json)['results'];
} else {
//todo
}
} catch (exception) {
//todo
}

return flModels.map((model) {
return new FLModel.fromJson(model);
}).toList();
}



2 changes: 1 addition & 1 deletion lib/widget/demo_network/network_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _NetworkAppPageState extends State<NetworkAppPage> {
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
if (response.statusCode == HttpStatus.OK) {
_result = await response.transform(UTF8.decoder).join();
_result = await response.transform(Utf8Decoder()).join();
_decodeJson(_result, false);
} else {
_result = 'error code : ${response.statusCode}';
Expand Down
Loading

0 comments on commit 1b6e236

Please sign in to comment.