Skip to content

Commit

Permalink
upgrade lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed May 1, 2021
1 parent cdb7308 commit da12cd3
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 105 deletions.
13 changes: 3 additions & 10 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ println(packageName)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 30
Expand Down Expand Up @@ -116,19 +115,13 @@ flutter {
}

dependencies {
implementation project(":weiss")
implementation 'androidx.webkit:webkit:1.3.0'

// implementation project(":weiss")
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

implementation "androidx.browser:browser:1.3.0"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
implementation('com.waynejo:androidndkgif:0.3.3')
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.google.android.play:core:1.9.1'
implementation 'com.google.android.gms:play-services-wallet:18.1.2'
implementation 'com.google.android.play:core:1.10.0'
}
9 changes: 0 additions & 9 deletions android/app/src/main/kotlin/com/perol/pixez/CardAppWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.graphics.Bitmap
import android.util.Log
import android.widget.RemoteViews
import com.bumptech.glide.Glide
import com.bumptech.glide.load.model.GlideUrl
Expand All @@ -32,15 +30,8 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.dart.DartExecutor
import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterCallbackInformation
import io.flutter.view.FlutterMain
import org.json.JSONArray
import org.json.JSONObject


/**
* Implementation of App Widget functionality.
*/
Expand Down
Binary file not shown.
10 changes: 0 additions & 10 deletions android/app/src/main/res/drawable/ic_search.xml

This file was deleted.

6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

buildscript {
ext.kotlin_version = '1.4.21'
ext.kotlin_version = '1.4.32'

repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
Expand All @@ -27,8 +27,8 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.google.gms:google-services:4.3.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Jul 22 20:02:16 CST 2020
#Sat May 01 17:18:32 CST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
48 changes: 14 additions & 34 deletions lib/models/error_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,38 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import 'dart:convert' show json;
import 'package:json_annotation/json_annotation.dart';
part 'error_message.g.dart';

@JsonSerializable()
class ErrorMessage {
Error error;

ErrorMessage({
required this.error,
});

factory ErrorMessage.fromJson(jsonRes) => ErrorMessage(
error: Error.fromJson(jsonRes['error']),
);
factory ErrorMessage.fromJson(Map<String, dynamic> json) =>
_$ErrorMessageFromJson(json);

Map<String, dynamic> toJson() => {
'error': error,
};

@override
String toString() {
return json.encode(this);
}
Map<String, dynamic> toJson() => _$ErrorMessageToJson(this);
}

@JsonSerializable()
class Error {
String user_message;
String message;
String reason;
Object user_message_details;
String? user_message;
String? message;
String? reason;
Object? user_message_details;

Error({
required this.user_message,
required this.message,
required this.reason,
required this.user_message_details,
this.user_message_details,
});

factory Error.fromJson(jsonRes) => Error(
user_message: jsonRes['user_message'],
message: jsonRes['message'],
reason: jsonRes['reason'],
user_message_details: jsonRes['user_message_details'],
);

Map<String, dynamic> toJson() => {
'user_message': user_message,
'message': message,
'reason': reason,
'user_message_details': user_message_details,
};
factory Error.fromJson(Map<String, dynamic> json) => _$ErrorFromJson(json);

@override
String toString() {
return json.encode(this);
}
Map<String, dynamic> toJson() => _$ErrorToJson(this);
}
2 changes: 1 addition & 1 deletion lib/network/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ApiClient {
String time = getIsoDate();
if (isBookmark) {
httpClient = Dio(apiClient.httpClient.options)
// ..interceptors.add(LogInterceptor(responseBody: true, requestBody: true))
..interceptors.add(LogInterceptor(responseBody: true, requestBody: true))
..interceptors.add(RefreshTokenInterceptor());
(httpClient.httpClientAdapter as DefaultHttpClientAdapter)
.onHttpClientCreate = (client) {
Expand Down
77 changes: 43 additions & 34 deletions lib/network/refresh_token_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
*/

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pixez/main.dart';
import 'package:pixez/models/account.dart';
import 'package:pixez/models/error_message.dart';
Expand Down Expand Up @@ -72,39 +69,51 @@ class RefreshTokenInterceptor extends InterceptorsWrapper {
if (err.response != null && err.response!.statusCode == 400) {
DateTime dateTime = DateTime.now();
if ((dateTime.millisecondsSinceEpoch - lastRefreshTime) > 200000) {
apiClient.httpClient.interceptors.errorLock.lock();
print("lock start ========================");
try {
ErrorMessage errorMessage = ErrorMessage.fromJson(err.response!.data);
if (errorMessage.error.message.contains("OAuth") &&
accountStore.now != null) {
final client = OAuthClient();
AccountPersist accountPersist = accountStore.now!;
Response response1 = await client.postRefreshAuthToken(
refreshToken: accountPersist.refreshToken,
deviceToken: accountPersist.deviceToken);
AccountResponse accountResponse =
Account.fromJson(response1.data).response;
final user = accountResponse.user;
accountStore.updateSingle(AccountPersist(
userId: user.id,
userImage: user.profileImageUrls.px170x170,
accessToken: accountResponse.accessToken,
refreshToken: accountResponse.refreshToken,
deviceToken: "",
passWord: "no more",
name: user.name,
account: user.account,
mailAddress: user.mailAddress,
isPremium: bti(user.isPremium),
xRestrict: user.xRestrict,
isMailAuthorized: bti(user.isMailAuthorized),
id: accountPersist.id));
lastRefreshTime = DateTime.now().millisecondsSinceEpoch;
if (err.response!.statusCode == HttpStatus.badRequest) {
apiClient.httpClient.interceptors.errorLock.lock();
print("lock start ========================");
ErrorMessage errorMessage =
ErrorMessage.fromJson(err.response!.data);
if (errorMessage.error.message!.contains("OAuth") &&
accountStore.now != null) {
final client = OAuthClient();
AccountPersist accountPersist = accountStore.now!;
Response response1 = await client.postRefreshAuthToken(
refreshToken: accountPersist.refreshToken,
deviceToken: accountPersist.deviceToken);
AccountResponse accountResponse =
Account.fromJson(response1.data).response;
final user = accountResponse.user;
accountStore.updateSingle(AccountPersist(
userId: user.id,
userImage: user.profileImageUrls.px170x170,
accessToken: accountResponse.accessToken,
refreshToken: accountResponse.refreshToken,
deviceToken: "",
passWord: "no more",
name: user.name,
account: user.account,
mailAddress: user.mailAddress,
isPremium: bti(user.isPremium),
xRestrict: user.xRestrict,
isMailAuthorized: bti(user.isMailAuthorized),
id: accountPersist.id));
lastRefreshTime = DateTime.now().millisecondsSinceEpoch;
apiClient.httpClient.interceptors.errorLock.unlock();
print("unlock ========================");
} else if (errorMessage.error.message!.contains("Limit")) {
lastRefreshTime = 0;
apiClient.httpClient.interceptors.errorLock.unlock();
print("unlock ========================");
return handler.reject(err);
} else {
lastRefreshTime = 0;
apiClient.httpClient.interceptors.errorLock.unlock();
print("unlock ========================");
return handler.reject(err);
}
}
if (errorMessage.error.message.contains("Limit")) {}
apiClient.httpClient.interceptors.errorLock.unlock();
print("unlock ========================");
} catch (e) {
print(e);
lastRefreshTime = 0;
Expand Down
2 changes: 0 additions & 2 deletions lib/page/splash/splash_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*
*/

import 'dart:math';

import 'package:mobx/mobx.dart';
import 'package:pixez/component/pixiv_image.dart';
import 'package:pixez/er/hoster.dart';
Expand Down

0 comments on commit da12cd3

Please sign in to comment.