├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── arrays.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── me_image_man.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── layout │ │ │ │ ├── recommendcomponent.xml │ │ │ │ ├── recommendactivity.xml │ │ │ │ ├── activity_main.xml │ │ │ │ └── newactivity_main.xml │ │ │ └── values-w820dp │ │ │ │ └── dimens.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── android │ │ │ │ └── weexlist │ │ │ │ ├── module │ │ │ │ └── CommonModule.java │ │ │ │ ├── adapter │ │ │ │ └── WeexImageAdapter.java │ │ │ │ ├── activity │ │ │ │ ├── MainActivity.java │ │ │ │ ├── RecommendComponentActivity.java │ │ │ │ └── RecommendActivity.java │ │ │ │ ├── components │ │ │ │ ├── CircleImageView.java │ │ │ │ └── RefreshView.java │ │ │ │ ├── app │ │ │ │ └── WeexListApp.java │ │ │ │ ├── widgets │ │ │ │ ├── WeexPtrDefaultHandler.java │ │ │ │ ├── MaterialDesignPtrFrameLayout.java │ │ │ │ ├── WeexMaterialHeader.java │ │ │ │ └── WeexMaterialProgressDrawable.java │ │ │ │ └── glide │ │ │ │ └── GlideCircleTransform.java │ │ ├── AndroidManifest.xml │ │ ├── weex │ │ │ ├── recommend.vue │ │ │ └── recommend_component.vue │ │ └── assets │ │ │ ├── recommend.js │ │ │ └── recommendcomponent.js │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── android │ │ │ └── weexlist │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── android │ │ └── weexlist │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── liuzhao.xml ├── markdown-navigator │ └── profiles_settings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml ├── markdown-navigator.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | WeexList 3 | 4 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuzhao2007/WeexList/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/dictionaries/liuzhao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuzhao2007/WeexList/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuzhao2007/WeexList/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuzhao2007/WeexList/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/me_image_man.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuzhao2007/WeexList/HEAD/app/src/main/res/mipmap-xhdpi/me_image_man.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuzhao2007/WeexList/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuzhao2007/WeexList/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #FFFF5A5A> 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recommendcomponent.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @color/refresh_color 5 | @color/refresh_color 6 | @color/refresh_color 7 | @color/refresh_color 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/android/weexlist/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.android.weexlist; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/android/weexlist/module/CommonModule.java: -------------------------------------------------------------------------------- 1 | package com.android.weexlist.module; 2 | 3 | import android.widget.Toast; 4 | 5 | import com.android.weexlist.app.WeexListApp; 6 | import com.taobao.weex.annotation.JSMethod; 7 | import com.taobao.weex.common.WXModule; 8 | 9 | /** 10 | * Created by liuzhao on 2017/10/23. 11 | * 12 | * 展示自定义Module使用 13 | * 14 | */ 15 | public class CommonModule extends WXModule { 16 | 17 | @JSMethod(uiThread = true) 18 | public void toast(String message) { 19 | Toast.makeText(WeexListApp.getApp(), "" + message, 0).show(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/liuzhao/Downloads/adt-bundle-mac-x86_64-20140702/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/weexlist/adapter/WeexImageAdapter.java: -------------------------------------------------------------------------------- 1 | package com.android.weexlist.adapter; 2 | 3 | import android.widget.ImageView; 4 | 5 | import com.android.weexlist.R; 6 | import com.bumptech.glide.Glide; 7 | import com.taobao.weex.adapter.IWXImgLoaderAdapter; 8 | import com.taobao.weex.common.WXImageStrategy; 9 | import com.taobao.weex.dom.WXImageQuality; 10 | 11 | /** 12 | * Created by liuzhao on 17/3/8. 13 | */ 14 | 15 | public class WeexImageAdapter implements IWXImgLoaderAdapter { 16 | 17 | @Override 18 | public void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy) { 19 | Glide.with(view.getContext()) 20 | .load(url) 21 | .error(R.mipmap.me_image_man) 22 | .into(view); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/android/weexlist/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.android.weexlist; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.android.weexlist", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WeexList 2 | 3 | **关于Weex的探索记录:自定义Component、网络、下拉刷新,及问题解决的思考。** 4 | 5 | # 一、涉及技能 6 | 7 | 1. **Weex完整开发的一个列表页。两种实现方式;** 8 | 2. **自定义Component组件,自定义控件与Weex的结合,包括下拉刷新和圆角图片;** 9 | 3. **Weex与下拉刷新的冲突解决思考思路;** 10 | 4. **完整的网络请求示例:参数、Header、Post请求等;** 11 | 12 | # 二、项目展示 13 | ![项目展示](http://upload-images.jianshu.io/upload_images/4056837-6be5b0c6c344f13f?imageMogr2/auto-orient/strip) 14 | 15 | # 三、项目说明 16 | Clone项目之后可直接运行,两种下拉刷新的实现区别在于: 17 | 1. **下拉刷新写在Native,然后将Weex渲染出来的View加到下拉刷新里;** 18 | 2. **封装下拉刷新为Weex的一个组件,在Weex代码中调用,灵活性更高。** 19 | 20 | 代码目录: 21 | - components为自定义的组件; 22 | - adapter为基础功能的接口,此处为图片下载; 23 | - main/assets里是Weex源文件打包生成的Js文件; 24 | - main/weex里是Weex的源文件; 25 | 26 | # 四、文章说明 27 | 28 | **欢迎关注Weex系列文章,实战+源码分析!** 29 | 30 | - [《Weex系列(一)之Weex入门准备》](http://www.jianshu.com/p/657896f60706) 31 | - [《Weex系列(二)之列表页实战》](http://www.jianshu.com/p/64288751cfc3) 32 | - [《Weex系列(三)之列表页实战冲突解决》](http://www.jianshu.com/p/27420a612d55) 33 | - [《深入Weex系列(四)之Module组件源码解析》](http://www.jianshu.com/p/208abd91f54e) 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/weexlist/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.android.weexlist.activity; 2 | 3 | import android.content.Intent; 4 | import android.support.v4.app.FragmentActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | 8 | import com.android.weexlist.R; 9 | 10 | public class MainActivity extends FragmentActivity implements View.OnClickListener { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | findViewById(R.id.bt_native).setOnClickListener(this); 17 | findViewById(R.id.bt_component).setOnClickListener(this); 18 | } 19 | 20 | @Override 21 | public void onClick(View v) { 22 | switch (v.getId()) { 23 | case R.id.bt_native: 24 | startActivity(new Intent(MainActivity.this,RecommendActivity.class)); 25 | break; 26 | case R.id.bt_component: 27 | startActivity(new Intent(MainActivity.this,RecommendComponentActivity.class)); 28 | break; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/layout/recommendactivity.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 |