Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Nov 7, 2019
1 parent f475d13 commit 610030e
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 23 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eeui-template",
"version": "1.0.28",
"version": "1.0.29",
"description": "A weex project",
"eeuiclimin": "1.0.28",
"author": "",
Expand All @@ -24,6 +24,7 @@
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"inquirer": "^7.0.0",
"webpack": "^2.7.0",
"weex-loader": "^0.7.12",
"weex-bindingx": "^0.0.49",
Expand Down
4 changes: 2 additions & 2 deletions platforms/android/eeuiApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ subprojects {
versionCode = 1
versionName = "1.0"

eeuiVersionCode = 28
eeuiVersionName = "1.0.28"
eeuiVersionCode = 29
eeuiVersionName = "1.0.29"

compileSdkVersion = 29
appMinSdkVersion = 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;

import com.taobao.weex.WXSDKManager;
import com.taobao.weex.adapter.DrawableStrategy;
import com.taobao.weex.adapter.IDrawableLoader;

import org.apache.commons.lang3.math.NumberUtils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

Expand All @@ -39,7 +43,7 @@ public DrawableLoader(Context context) {
@Override
public void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy) {
WXSDKManager.getInstance().postOnUiThread(() -> {
String tempUrl = eeuiBase.config.verifyFile(eeuiPage.rewriteUrl(eeui.getActivityList().getLast(), url));
String tempUrl = eeuiBase.config.verifyFile(eeuiPage.rewriteUrl(eeui.getActivityList().getLast(), handCachePageUrl(eeui.getActivityList().getLast(), url)));
Log.d(TAG, "setDrawable: " + tempUrl);
try {
RequestBuilder<Drawable> myLoad;
Expand Down Expand Up @@ -77,4 +81,26 @@ private Bitmap getImageFromAssetsFile(Context context, String fileName) {
}
return image;
}

private String handCachePageUrl(Context context, String url) {
if (TextUtils.isEmpty(url)) {
return url;
}
File pageCache = context.getExternalFilesDir("page_cache");
if (pageCache == null) {
return url;
}
File updateFile = context.getExternalFilesDir("update");
if (updateFile == null) {
return url;
}
String cacheUrl = "file://" + pageCache.getPath() + updateFile.getPath() + "/";
if (url.startsWith(cacheUrl)) {
String tmpUrl = url.substring(cacheUrl.length());
if (tmpUrl.contains("/") && NumberUtils.isCreatable(tmpUrl.substring(0, tmpUrl.indexOf("/")))) {
url = "root:/" + tmpUrl.substring(tmpUrl.indexOf("/"));
}
}
return url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import com.taobao.weex.common.WXImageStrategy;
import com.taobao.weex.dom.WXImageQuality;

import org.apache.commons.lang3.math.NumberUtils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

Expand Down Expand Up @@ -78,7 +81,7 @@ private void loadImage(int loadNum, String url, ImageView view, WXImageStrategy
if (view.getContext() == null) {
return;
}
String tempUrl = eeuiBase.config.verifyFile(eeuiPage.rewriteUrl(view, url));
String tempUrl = eeuiBase.config.verifyFile(eeuiPage.rewriteUrl(view, handCachePageUrl(view.getContext(), url)));
Log.d(TAG, "loadImage: " + tempUrl);
try {
RequestBuilder<Drawable> myLoad;
Expand Down Expand Up @@ -127,4 +130,26 @@ private Bitmap getImageFromAssetsFile(Context context, String fileName)
}
return image;
}

private String handCachePageUrl(Context context, String url) {
if (TextUtils.isEmpty(url)) {
return url;
}
File pageCache = context.getExternalFilesDir("page_cache");
if (pageCache == null) {
return url;
}
File updateFile = context.getExternalFilesDir("update");
if (updateFile == null) {
return url;
}
String cacheUrl = "file://" + pageCache.getPath() + updateFile.getPath() + "/";
if (url.startsWith(cacheUrl)) {
String tmpUrl = url.substring(cacheUrl.length());
if (tmpUrl.contains("/") && NumberUtils.isCreatable(tmpUrl.substring(0, tmpUrl.indexOf("/")))) {
url = "root:/" + tmpUrl.substring(tmpUrl.indexOf("/"));
}
}
return url;
}
}
2 changes: 1 addition & 1 deletion plugins/ios/eeui/eeui.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pod::Spec.new do |s|


s.name = "eeui"
s.version = "1.0.28"
s.version = "1.0.29"
s.summary = "eeui plugin."
s.description = <<-DESC
eeui plugin.
Expand Down
37 changes: 36 additions & 1 deletion plugins/ios/eeui/eeui/Handler/WXImgLoaderDefaultImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ @implementation WXImgLoaderDefaultImpl
- (id<WXImageOperationProtocol>)downloadImageWithURL:(NSString *)url imageFrame:(CGRect)imageFrame userInfo:(NSDictionary *)userInfo completed:(void(^)(UIImage *image, NSError *error, BOOL finished))completedBlock
{
WXSDKInstance *instance = [WXSDKManager instanceForID:userInfo[@"instanceId"]];
url = [Config verifyFile:[DeviceUtil rewriteUrl:url mInstance:instance]];
url = [Config verifyFile:[DeviceUtil rewriteUrl:[self handCachePageUr:url] mInstance:instance]];
url = [DeviceUtil urlEncoder:url];

return (id<WXImageOperationProtocol>)[SDWebImageDownloader.sharedDownloader downloadImageWithURL:[NSURL URLWithString:url] options:SDWebImageDownloaderLowPriority progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
Expand All @@ -70,4 +70,39 @@ @implementation WXImgLoaderDefaultImpl
}];
}

- (NSString *)handCachePageUr:(NSString *)url
{
if (url.length == 0) {
return url;
}
NSString *cacheUrl = [NSString stringWithFormat:@"file://%@%@/", [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"page_cache"], [Config getSandPath:@"update"]];
if ([url hasPrefix:cacheUrl]) {
NSString *tmpUrl = [url substringFromIndex:cacheUrl.length];
if ([tmpUrl containsString:@"/"]) {
NSRange searchResult = [tmpUrl rangeOfString:@"/"];
if (searchResult.location != NSNotFound) {
NSString *dataId = [tmpUrl substringToIndex:searchResult.location];

if ([self judgeIsNumberByRegularExpressionWith:dataId]) {
return [NSString stringWithFormat:@"root:/%@", [tmpUrl substringFromIndex:dataId.length]];
}
}
}
}
return url;
}

- (BOOL)judgeIsNumberByRegularExpressionWith:(NSString *)str
{
if (str.length == 0) {
return NO;
}
NSString *regex = @"[0-9]*";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
if ([pred evaluateWithObject:str]) {
return YES;
}
return NO;
}

@end
4 changes: 2 additions & 2 deletions plugins/ios/eeui/eeui/eeuiVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ @implementation eeuiVersion

+ (NSString*)eeuiVersion
{
return @"28"; //versionCode
return @"29"; //versionCode
}

+ (NSString*)eeuiVersionName
{
return @"1.0.28"; //versionName
return @"1.0.29"; //versionName
}

@end
34 changes: 20 additions & 14 deletions plugins/ios/eeui/eeui/eeuiViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,15 @@ - (void)viewWillAppear:(BOOL)animated
[UIApplication sharedApplication].statusBarHidden = NO;
}

//状态栏样式
if ([_statusBarStyleCustom isEqualToString:@"1"]) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}else{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
if (!self.isChildSubview) {
//状态栏样式
if (!self.isChildSubview) {
if ([_statusBarStyleCustom isEqualToString:@"1"]) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}else{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
}
}
}

Expand Down Expand Up @@ -183,11 +187,13 @@ - (void)viewWillDisappear:(BOOL)animated
[self updateStatus:@"pause"];
[self liftCycleEvent:LifeCyclePause];

//状态栏样式
if ([_statusBarStyleCustom isEqualToString:@"1"]) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}else{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
if (!self.isChildSubview) {
//状态栏样式
if ([_statusBarStyleCustom isEqualToString:@"1"]) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}else{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
}
}

Expand Down Expand Up @@ -473,7 +479,7 @@ - (void)renderView

[weakSelf showErrorBox:[NSString stringWithFormat: @"%ld", (long)[error code]]];
weakSelf.errorContent = [error description];
});
});
};

_instance.renderFinish = ^(UIView *view) {
Expand Down Expand Up @@ -672,7 +678,7 @@ - (void)showFixedConsole
}];
}else{
[instance renderWithURL:[NSURL URLWithString:tempUrl] options:nil data:nil];
}
}
}else{
[self.view bringSubviewToFront:self.consoleView];
}
Expand Down Expand Up @@ -714,7 +720,7 @@ - (void)startLoading
{
if (_loading) {
[self.activityIndicatorView setHidden:NO];
[self.activityIndicatorView startAnimating];
[self.activityIndicatorView startAnimating];
}
}

Expand Down Expand Up @@ -841,7 +847,7 @@ - (void)refreshPageExecution
[self renderView];
[self updateStatus:@"restart"];
}
});
});
}

#pragma mark - notification
Expand Down

0 comments on commit 610030e

Please sign in to comment.