Commit 7c4bf69f authored by Star Diao's avatar Star Diao

add nexus

parent 81bfdebd
# eros-nexus
Android基础框架
Android Base抽象层。
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'myliuyx'
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
def PROJECT_SUPPORTLIBV_NEXUS = "25.3.1"
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${PROJECT_SUPPORTLIBV_NEXUS}"
compile "com.android.support:support-v4:${PROJECT_SUPPORTLIBV_NEXUS}"
compile "com.android.support:recyclerview-v7:${PROJECT_SUPPORTLIBV_NEXUS}"
compile 'com.alibaba:fastjson:1.1.68.android'
// compile 'com.taobao.android:weex_sdk:0.18.0'
// implementation 'org.apache.weex:sdk:0.28.0'
compile project(':sdk')
// compile 'com.gsst.mobile:gsst-weex-base-sdk:0.0.02-SNAPSHOT'
// compile project(':weex-framework')
compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile files('libs/otto-1.3.5.jar')
compile 'com.lzy.widget:imagepicker:0.6.1'
compile('com.github.bumptech.glide:glide:4.7.1', {
exclude group: 'com.android.support'
})
annotationProcessor('com.github.bumptech.glide:compiler:4.8.0', {
exclude group: 'com.android.support'
})
compile('com.github.bumptech.glide:okhttp3-integration:4.7.1', {
exclude group: 'com.android.support'
})
compile 'org.weex.plugin:processor:1.0.2'
uploadArchives {
repositories {
mavenDeployer {
//maven address
repository(url: 'http://192.168.12.122:8090/nexus/repository/maven-snapshots/') {
authentication(userName: "deployment", password: "deployment123")
}
pom.project {
groupId 'com.gsst.mobile'
artifactId 'gsst-weex-base-plugin'
version '0.0.04-SNAPSHOT'
packaging 'jar'
}
}
}
}
}
repositories {
maven { url 'http://192.168.12.122:8090/nexus/repository/maven-snapshots/' }
jcenter()
mavenCentral()
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
## Unit Test
Unit test code is under 'src/test'. You can run unit test use command:
```bash
./gradlew clean testDebugUnitTest jacocoTestReportDebug
```
This task will run all unit test and produce both unit test report and jacoco test coverage report in 'build/reports'.
This source diff could not be displayed because it is too large. You can view the blob instead.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.5.0'
}
}
plugins {
id "com.github.hierynomus.license" version "0.14.0"
}
apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
apply plugin: 'com.github.dcendents.android-maven'
group='myliuyx'
ext.disableCov = project.hasProperty('disableCov') ? project.getProperty('disableCov') : 'false'
if(!disableCov.toBoolean()){
apply plugin: 'com.vanniktech.android.junit.jacoco'
junitJacoco {
excludes = ['com/taobao/weex/dom/flex/**','com/taobao/weex/ui/view/refresh/circlebar/**']
}
}
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/quality/checkstyle.xml") // Where my checkstyle config is...
// configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath // Where is my suppressions file for checkstyle is...
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/test/**'
exclude '**/com/taobao/weex/dom/flex/**'
classpath = files()
}
checkstyle {
toolVersion = '6.9'
}
version = "0.18.0"
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
resourcePrefix "weex"
useLibrary 'org.apache.http.legacy'
copy {
from '../../pre-build'
into new File(projectDir,"assets")
include 'native-bundle-main.js'
rename('native-bundle-main.js','main.js')
}
def line
new File(projectDir,"assets/main.js").withReader { line = it.readLine() }
def m = line =~ /[A-Z\s]+\s+([0-9\.]+),\s+Build\s+[0-9]+/;
def jsfmVersion = m[0][1]
println jsfmVersion
if(project.hasProperty('asfRelease')){
//download so file if not exist, when compile in source release
download{
src 'https://git-wip-us.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/armeabi/libweexjsc.so;hb=refs/heads/master'
dest "${projectDir}/libs/armeabi/libweexjsc.so"
overwrite false
}
download{
src 'https://git-wip-us.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/x86/libweexjsc.so;hb=refs/heads/master'
dest "${projectDir}/libs/x86/libweexjsc.so"
overwrite false
}
}
def ARMEABI_Size = new File(projectDir,"libs/armeabi/libweexjsc.so").length();
def X86_Size = new File(projectDir,"libs/x86/libweexjsc.so").length();
println "ARMEABI_Size: "+ARMEABI_Size;
println "X86_Size:" + X86_Size;
defaultConfig {
buildConfigField "long", "ARMEABI_Size", "${ARMEABI_Size}"
buildConfigField "long", "X86_Size", "${X86_Size}"
buildConfigField "String", "buildJavascriptFrameworkVersion", "\"${jsfmVersion}\""
buildConfigField "String", "buildVersion", "\"${version}\""
minSdkVersion 14
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName "1.0"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
ndk {
abiFilters "armeabi","x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "ENABLE_TRACE", "false"
}
debug {
testCoverageEnabled true
buildConfigField "boolean", "ENABLE_TRACE", "true"
}
}
sourceSets {
main {
assets.srcDirs = ['assets']
jniLibs.srcDir(['libs'])
java {
srcDirs = ["src/main/java"];
}
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions.encoding = "UTF-8"
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.all {
maxHeapSize = "1024m"
jvmArgs += ['-XX:-UseSplitVerifier', '-noverify','-Xverify:none']/* fix VerifyError */
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
provided "com.android.support:recyclerview-v7:${PROJECT_SUPPORTLIBVERSION}"
provided "com.android.support:support-v4:${PROJECT_SUPPORTLIBVERSION}"
provided "com.android.support:appcompat-v7:${PROJECT_SUPPORTLIBVERSION}"
provided "com.alibaba:fastjson:1.1.46.android"
testCompile "com.alibaba:fastjson:1.1.46.android"
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.javassist:javassist:3.20.0-GA'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.objenesis:objenesis:2.1'
testCompile 'org.powermock:powermock-core:1.6.4'
testCompile 'org.powermock:powermock-api-mockito:1.6.4'
testCompile 'org.powermock:powermock-module-junit4-common:1.6.4'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
testCompile 'org.powermock:powermock-module-junit4-legacy:1.6.4'
testCompile 'org.powermock:powermock-module-testng:1.6.4'
testCompile 'org.powermock:powermock-classloading-xstream:1.6.4'
testCompile "org.powermock:powermock-module-junit4-rule:1.6.4"
testCompile 'org.robolectric:robolectric:3.3.2'
testCompile "org.robolectric:shadows-httpclient:3.3.2"
testCompile 'org.json:json:20160212'
}
if(file('../license/LICENSE').exists()){
license {
header = file('../license/LICENSE')
excludes(["com/taobao/weex/dom/flex/*.java"])
}
preBuild.dependsOn licenseFormat
}
This diff is collapsed.
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useDeprecatedNdk=true
org.gradle.daemon=false
org.gradle.parallel=false
org.gradle.jvmargs=-Xmx2048M
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/ouy/Library/AndroidStudio/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class com.taobao.weex.bridge.** { *; }
-dontwarn com.taobao.weex.bridge.**
#!/usr/bin/env bash
./gradlew clean assemble publish
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.taobao.weappplus_sdk"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21"/>
<application>
<receiver
android:name="com.taobao.weex.WXGlobalEventReceiver"
android:enabled="true"
android:exported="false">
</receiver>
</application>
</manifest>
\ No newline at end of file
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.view.View;
import com.taobao.weex.ui.component.WXComponent;
/**
* Created by sospartan on 14/06/2017.
*/
public interface ComponentObserver {
/**
* Called after component is create.
* Notice: View is not created at this moment.
* @param component
*/
void onCreate(WXComponent component);
/**
* Called before component destroy.
* @param component
*/
void onPreDestory(WXComponent component);
/**
* Called when component's view is created
* @param component
* @param view
*/
void onViewCreated(WXComponent component,View view);
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
/**
* Listener class for activity lifecycle
*/
@Deprecated
public interface IWXActivityStateListener {
void onActivityCreate();
void onActivityStart();
void onActivityPause();
void onActivityResume();
void onActivityStop();
void onActivityDestroy();
boolean onActivityBack();
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.view.View;
public interface IWXRenderListener {
/**
* If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ASYNC} is applied, this method
* will be invoked when the rendering of first view is finish.
* If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ONCE} is applied, this method will
* be invoked when the rendering of the view tree is finished.
*/
void onViewCreated(WXSDKInstance instance, View view);
/**
* Called when the render view phase of weex has finished.
* It can be invoked at most once in the entire life of a {@link WXSDKInstance}
*/
void onRenderSuccess(WXSDKInstance instance, int width, int height);
/**
* Callback method, called when refresh is finished
*/
void onRefreshSuccess(WXSDKInstance instance, int width, int height);
/**
* Report exception occurred when weex instance is running. Exception <strong>may not</strong>
* cause user-noticeable failure of weex.
*/
void onException(WXSDKInstance instance, String errCode, String msg);
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
public interface IWXStatisticsListener {
/**
* Called when weex sdk engine begin to initialize.
*/
void onSDKEngineInitialize();
/**
* Called when begin to load js framework.
*/
void onJsFrameworkStart();
/**
* Called when finish loading js framework.
*/
void onJsFrameworkReady();
/**
* Called when the render view phase of first view reached.
*/
void onFirstView();
/**
* Called when the render view phase of first screen reached.
*/
void onFirstScreen();
/**
* Called when to start a http request.
*/
void onHttpStart();
/**
* Called when received a http response header data.
*/
void onHeadersReceived();
/**
* Called when to finish a http request.
*/
void onHttpFinish();
/**
* Called when an exception occured.
*/
void onException(String instanceid, String errCode, String msg);
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import com.taobao.weex.adapter.IDrawableLoader;
import com.taobao.weex.adapter.IWXDebugAdapter;
import com.taobao.weex.adapter.IWXHttpAdapter;
import com.taobao.weex.adapter.IWXImgLoaderAdapter;
import com.taobao.weex.adapter.IWXJSExceptionAdapter;
import com.taobao.weex.adapter.IWXSoLoaderAdapter;
import com.taobao.weex.adapter.IWXTypefaceAdapter;
import com.taobao.weex.adapter.IWXUserTrackAdapter;
import com.taobao.weex.adapter.URIAdapter;
import com.taobao.weex.appfram.storage.IWXStorageAdapter;
import com.taobao.weex.appfram.websocket.IWebSocketAdapterFactory;
/**
* Created by sospartan on 5/31/16.
*/
public class InitConfig {
private IWXHttpAdapter httpAdapter;
private IDrawableLoader drawableLoader;
private IWXImgLoaderAdapter imgAdapter;
private IWXUserTrackAdapter utAdapter;
private IWXDebugAdapter debugAdapter;
private IWXStorageAdapter storageAdapter;
private IWXSoLoaderAdapter soLoader;
private URIAdapter mURIAdapter;
private IWebSocketAdapterFactory webSocketAdapterFactory;
private IWXJSExceptionAdapter mJSExceptionAdapter;
private String framework;
//本木自定义adapter
private IWXTypefaceAdapter mTypefaceAdapter;
public IWXHttpAdapter getHttpAdapter() {
return httpAdapter;
}
public IWXImgLoaderAdapter getImgAdapter() {
return imgAdapter;
}
public IDrawableLoader getDrawableLoader() {
return drawableLoader;
}
public IWXUserTrackAdapter getUtAdapter() {
return utAdapter;
}
public IWXDebugAdapter getDebugAdapter() {
return debugAdapter;
}
public IWXSoLoaderAdapter getIWXSoLoaderAdapter() {
return soLoader;
}
public String getFramework() {
return framework;
}
public IWXStorageAdapter getStorageAdapter() {
return storageAdapter;
}
public URIAdapter getURIAdapter() {
return mURIAdapter;
}
public IWebSocketAdapterFactory getWebSocketAdapterFactory() {
return webSocketAdapterFactory;
}
public IWXJSExceptionAdapter getJSExceptionAdapter() {
return mJSExceptionAdapter;
}
public IWXTypefaceAdapter getTypefaceAdapter() {
return mTypefaceAdapter;
}
private InitConfig() {
}
public static class Builder {
IWXHttpAdapter httpAdapter;
IWXImgLoaderAdapter imgAdapter;
IDrawableLoader drawableLoader;
IWXUserTrackAdapter utAdapter;
IWXDebugAdapter debugAdapter;
IWXStorageAdapter storageAdapter;
IWXSoLoaderAdapter soLoader;
URIAdapter mURIAdapter;
IWXJSExceptionAdapter mJSExceptionAdapter;
String framework;
IWebSocketAdapterFactory webSocketAdapterFactory;
//本木自定义adapter
private IWXTypefaceAdapter typefaceAdapter;
public Builder() {
}
public Builder setHttpAdapter(IWXHttpAdapter httpAdapter) {
this.httpAdapter = httpAdapter;
return this;
}
public Builder setImgAdapter(IWXImgLoaderAdapter imgAdapter) {
this.imgAdapter = imgAdapter;
return this;
}
public Builder setDrawableLoader(IDrawableLoader drawableLoader) {
this.drawableLoader = drawableLoader;
return this;
}
public Builder setUtAdapter(IWXUserTrackAdapter utAdapter) {
this.utAdapter = utAdapter;
return this;
}
public Builder setDebugAdapter(IWXDebugAdapter debugAdapter) {
this.debugAdapter = debugAdapter;
return this;
}
public Builder setStorageAdapter(IWXStorageAdapter storageAdapter) {
this.storageAdapter = storageAdapter;
return this;
}
public Builder setURIAdapter(URIAdapter URIAdapter) {
mURIAdapter = URIAdapter;
return this;
}
public Builder setJSExceptionAdapter(IWXJSExceptionAdapter JSExceptionAdapter) {
mJSExceptionAdapter = JSExceptionAdapter;
return this;
}
public Builder setSoLoader(IWXSoLoaderAdapter loader) {
this.soLoader = loader;
return this;
}
public Builder setFramework(String framework) {
this.framework = framework;
return this;
}
public Builder setWebSocketAdapterFactory(IWebSocketAdapterFactory factory) {
this.webSocketAdapterFactory = factory;
return this;
}
public Builder setTypefaceAdapter(IWXTypefaceAdapter adapter) {
this.typefaceAdapter = adapter;
return this;
}
public InitConfig build() {
InitConfig config = new InitConfig();
config.httpAdapter = this.httpAdapter;
config.imgAdapter = this.imgAdapter;
config.drawableLoader = this.drawableLoader;
config.utAdapter = this.utAdapter;
config.debugAdapter = this.debugAdapter;
config.storageAdapter = this.storageAdapter;
config.soLoader = this.soLoader;
config.framework = this.framework;
config.mURIAdapter = this.mURIAdapter;
config.webSocketAdapterFactory = this.webSocketAdapterFactory;
config.mJSExceptionAdapter = this.mJSExceptionAdapter;
config.mTypefaceAdapter = this.typefaceAdapter;
return config;
}
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.support.annotation.NonNull;
public interface LayoutFinishListener {
void onLayoutFinish(@NonNull WXSDKInstance instance);
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import java.lang.ref.WeakReference;
/**
* Created by sospartan on 08/10/2016.
*/
public class RenderContainer extends FrameLayout {
private WeakReference<WXSDKInstance> mSDKInstance;
public RenderContainer(Context context) {
super(context);
}
public RenderContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public void setSDKInstance(WXSDKInstance instance) {
mSDKInstance = new WeakReference<>(instance);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WXSDKInstance instance;
if (mSDKInstance != null && (instance = mSDKInstance.get()) != null) {
//re-render instance
instance.setSize(w, h);
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.common.WXModule;
import java.util.Map;
/**
* Created by lixinke on 16/8/25.
*/
public class WXGlobalEventModule extends WXModule {
@JSMethod
public void addEventListener(String eventName, String callback) {
mWXSDKInstance.addEventListener(eventName,callback);
}
public void removeEventListener(String eventName, String callback) {
mWXSDKInstance.removeEventListener(eventName,callback);
}
@JSMethod
public void removeEventListener(String eventName){
mWXSDKInstance.removeEventListener(eventName);
}
@Override
public void addEventListener(String eventName, String callback, Map<String, Object> options) {
super.addEventListener(eventName, callback, options);
addEventListener(eventName,callback);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.taobao.weex.utils.WXLogUtils;
import java.util.HashMap;
public class WXGlobalEventReceiver extends BroadcastReceiver {
public static final String EVENT_NAME = "eventName";
public static final String EVENT_PARAMS = "eventParams";
public static final String EVENT_ACTION = "wx_global_action";
public static final String EVENT_WX_INSTANCEID = "wx_instanceid";
private WXSDKInstance mWXSDKInstance;
public WXGlobalEventReceiver() {
}
public WXGlobalEventReceiver(WXSDKInstance instance) {
mWXSDKInstance = instance;
}
@Override
public void onReceive(Context context, Intent intent) {
String eventName = intent.getStringExtra(EVENT_NAME);
String params = intent.getStringExtra(EVENT_PARAMS);
HashMap<String, Object> maps = null;
try {
maps = com.alibaba.fastjson.JSON.parseObject(params, HashMap.class);
mWXSDKInstance.fireGlobalEventCallback(eventName, maps);
} catch (Exception e) {
WXLogUtils.e("global-receive",e);
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
public class WXRenderErrorCode {
// public static final String WX_CREATE_INSTANCE_ERROR = "wx_create_instance_error";
//
// public static final String WX_NETWORK_ERROR = "wx_network_error";
//
// public static final String WX_USER_INTERCEPT_ERROR = "wx_user_intercept_error";
public enum DegradPassivityCode{
/**
* degrade code.
*/
WX_DEGRAD_ERR("-1000", "degradeToH5|Weex DegradPassivity \n"),
/**
* degrade for instance create failed, once this case occured,detail js stack and other specific
* cause need track into errmsg.
*/
WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED("-1001", "degradeToH5|createInstance fail|wx_create_instance_error"),
/**
* degrade for network failed download js bundle.once this case occured,network requist response header
* and statuscode need track into errmsg.
*/
WX_DEGRAD_ERR_NETWORK_BUNDLE_DOWNLOAD_FAILED("-1002", "|wx_network_error|js bundle download failed"),
/**
* degrade for network failed for bundlejs is unbroken , once this case occured,network requist response header
* and statuscode need track into errmsg.
*/
WX_DEGRAD_ERR_NETWORK_CHECK_CONTENT_LENGTH_FAILED("-1003", "degradeToH5|wx_network_error|js bundle content-length check failed"),
/**
* degrade for Response header Content-Type is null or not "application/javascript".
* once this case occured,network requist response header and statuscode need track into errmsg.
*/
WX_DEGRAD_ERR_BUNDLE_CONTENTTYPE_ERROR("-1004", "degradeToH5|wx_user_intercept_error |Content-Type is not application/javascript, " +
"Weex render template must be javascript, please check your request!"),
/**
* degrade for other reason. such as white screen which block error for some unknown reason.
* once this case occured,detail msg need track.
*/
WX_DEGRAD_ERR_OTHER_CAUSE_DEGRADTOH5("-1005", "degradeToH5|for other reason|");
private String degradCode;
private String degradMsg;
private String appendMsg = "";
private String args;
DegradPassivityCode(String degradCode, String degradMsg){
this.degradCode = degradCode;
this.degradMsg = degradMsg;
}
public String getDegradErrorCode() {
return degradCode;
}
public String getDegradErrorMsg() {
StringBuilder builder=new StringBuilder(degradMsg);
builder.append(appendMsg);
return builder.toString();
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex.adapter;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.taobao.weex.WXSDKInstance;
import java.util.List;
/**
* Default Uri adapter. Provide basic capability to handle relative path, local file path etc.
* Created by sospartan on 21/11/2016.
*/
public class DefaultUriAdapter implements URIAdapter {
@NonNull
@Override
public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
if (TextUtils.isEmpty(instance.getBundleUrl())) {
return uri;
}
Uri base = Uri.parse(instance.getBundleUrl());
Uri.Builder resultBuilder = uri.buildUpon();
if (uri.isRelative()) {
//When uri is empty, means use the base url instead. Web broswer behave this way.
if(uri.getEncodedPath().length() == 0){
if(URIAdapter.IMAGE.equals(type)){
if(TextUtils.isEmpty(uri.toString())){
return uri;
}
}
return base;
} else {
resultBuilder = buildRelativeURI(resultBuilder, base, uri);
return resultBuilder.build();
}
}
return uri;
}
private Uri.Builder buildRelativeURI(Uri.Builder resultBuilder, Uri base, Uri uri) {
if (uri.getAuthority() != null) {
return resultBuilder.scheme(base.getScheme());
} else {
resultBuilder
.encodedAuthority(base.getEncodedAuthority())
.scheme(base.getScheme())
.path(null);
if (uri.getPath().startsWith("/")) {
//relative to root
resultBuilder.appendEncodedPath(uri.getEncodedPath().substring(1));
} else {
List<String> segments = base.getPathSegments();
//ignore last segment if not end with /
int ignoreLast = 1;
if (base.getPath().endsWith("/")) {
ignoreLast = 0;
}
for (int i = 0, len = segments.size() - ignoreLast; i < len; i++) {
resultBuilder.appendEncodedPath(segments.get(i));
}
resultBuilder.appendEncodedPath(uri.getEncodedPath());
}
return resultBuilder;
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex.adapter;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.taobao.weex.common.WXRequest;
import com.taobao.weex.common.WXResponse;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class DefaultWXHttpAdapter implements IWXHttpAdapter {
private static final IEventReporterDelegate DEFAULT_DELEGATE = new NOPEventReportDelegate();
private ExecutorService mExecutorService;
private void execute(Runnable runnable){
if(mExecutorService==null){
mExecutorService = Executors.newFixedThreadPool(3);
}
mExecutorService.execute(runnable);
}
@Override
public void sendRequest(final WXRequest request, final OnHttpListener listener) {
if (listener != null) {
listener.onHttpStart();
}
execute(new Runnable() {
@Override
public void run() {
WXResponse response = new WXResponse();
IEventReporterDelegate reporter = getEventReporterDelegate();
try {
HttpURLConnection connection = openConnection(request, listener);
reporter.preConnect(connection, request.body);
Map<String,List<String>> headers = connection.getHeaderFields();
int responseCode = connection.getResponseCode();
if(listener != null){
listener.onHeadersReceived(responseCode,headers);
}
reporter.postConnect();
response.statusCode = String.valueOf(responseCode);
if (responseCode >= 200 && responseCode<=299) {
InputStream rawStream = connection.getInputStream();
rawStream = reporter.interpretResponseStream(rawStream);
response.originalData = readInputStreamAsBytes(rawStream, listener);
} else {
response.errorMsg = readInputStream(connection.getErrorStream(), listener);
}
if (listener != null) {
listener.onHttpFinish(response);
}
} catch (IOException|IllegalArgumentException e) {
e.printStackTrace();
response.statusCode = "-1";
response.errorCode="-1";
response.errorMsg=e.getMessage();
if(listener!=null){
listener.onHttpFinish(response);
}
if (e instanceof IOException) {
try {
reporter.httpExchangeFailed((IOException) e);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
});
}
/**
* Opens an {@link HttpURLConnection} with parameters.
*
* @param request
* @param listener
* @return an open connection
* @throws IOException
*/
private HttpURLConnection openConnection(WXRequest request, OnHttpListener listener) throws IOException {
URL url = new URL(request.url);
HttpURLConnection connection = createConnection(url);
connection.setConnectTimeout(request.timeoutMs);
connection.setReadTimeout(request.timeoutMs);
connection.setUseCaches(false);
connection.setDoInput(true);
if (request.paramMap != null) {
Set<String> keySets = request.paramMap.keySet();
for (String key : keySets) {
connection.addRequestProperty(key, request.paramMap.get(key));
}
}
if ("POST".equals(request.method) || "PUT".equals(request.method) || "PATCH".equals(request.method)) {
connection.setRequestMethod(request.method);
if (request.body != null) {
if (listener != null) {
listener.onHttpUploadProgress(0);
}
connection.setDoOutput(true);
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
//TODO big stream will cause OOM; Progress callback is meaningless
out.write(request.body.getBytes());
out.close();
if (listener != null) {
listener.onHttpUploadProgress(100);
}
}
} else if (!TextUtils.isEmpty(request.method)) {
connection.setRequestMethod(request.method);
} else {
connection.setRequestMethod("GET");
}
return connection;
}
private byte[] readInputStreamAsBytes(InputStream inputStream,OnHttpListener listener) throws IOException{
if(inputStream == null){
return null;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
int readCount = 0;
byte[] data = new byte[2048];
while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
readCount += nRead;
if (listener != null) {
listener.onHttpResponseProgress(readCount);
}
}
buffer.flush();
return buffer.toByteArray();
}
private String readInputStream(InputStream inputStream, OnHttpListener listener) throws IOException {
if(inputStream == null){
return null;
}
StringBuilder builder = new StringBuilder();
BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(inputStream));
char[] data = new char[2048];
int len;
while ((len = localBufferedReader.read(data)) != -1) {
builder.append(data, 0, len);
if (listener != null) {
listener.onHttpResponseProgress(builder.length());
}
}
localBufferedReader.close();
return builder.toString();
}
/**
* Create an {@link HttpURLConnection} for the specified {@code url}.
*/
protected HttpURLConnection createConnection(URL url) throws IOException {
return (HttpURLConnection) url.openConnection();
}
public @NonNull IEventReporterDelegate getEventReporterDelegate() {
return DEFAULT_DELEGATE;
}
public interface IEventReporterDelegate {
void preConnect(HttpURLConnection connection, @Nullable String body);
void postConnect();
InputStream interpretResponseStream(@Nullable InputStream inputStream);
void httpExchangeFailed(IOException e);
}
private static class NOPEventReportDelegate implements IEventReporterDelegate {
@Override
public void preConnect(HttpURLConnection connection, @Nullable String body) {
//do nothing
}
@Override
public void postConnect() {
//do nothing
}
@Override
public InputStream interpretResponseStream(@Nullable InputStream inputStream) {
return inputStream;
}
@Override
public void httpExchangeFailed(IOException e) {
//do nothing
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex.adapter;
public class DrawableStrategy {
public int width;
public int height;
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex.adapter;
/**
* Created by zhengshihan on 2017/5/23.
*/
public interface ICrashInfoReporter {
void addCrashInfo(String key ,String value);
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex.adapter;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
public interface IDrawableLoader {
interface DrawableTarget {
}
interface StaticTarget extends DrawableTarget{
void setDrawable(@Nullable Drawable drawable, boolean resetBounds);
}
interface AnimatedTarget extends DrawableTarget{
void setAnimatedDrawable(@Nullable Drawable drawable);
}
void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment