From 9c6ee2ea6f160f6f255ad75991fd56bec0915bec Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 26 Apr 2016 13:43:05 +0800 Subject: [PATCH 01/39] update the as gradle plugin version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5801588..7a83db5 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0-alpha3' + classpath 'com.android.tools.build:gradle:2.1.0-rc1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // NOTE: Do not place your application dependencies here; they belong From f0e627734a383c1848ce6bbb624d6af8ff94340f Mon Sep 17 00:00:00 2001 From: fengjian Date: Sat, 7 May 2016 16:47:59 +0800 Subject: [PATCH 02/39] update the gradle build plugin to 2.1.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7a83db5..b64644f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0-rc1' + classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // NOTE: Do not place your application dependencies here; they belong From 7fd5ac4cc405829c3c52f154692b6ac00e5cc77e Mon Sep 17 00:00:00 2001 From: fengjian Date: Sat, 7 May 2016 16:51:54 +0800 Subject: [PATCH 03/39] add weakhandler --- .../lesscode/core/other/WeakHandler.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/WeakHandler.java diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/WeakHandler.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/WeakHandler.java new file mode 100644 index 0000000..8256131 --- /dev/null +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/WeakHandler.java @@ -0,0 +1,17 @@ +package com.jayfeng.lesscode.core.other; + +import android.os.Handler; + +import java.lang.ref.WeakReference; + +public abstract class WeakHandler extends Handler { + private WeakReference mOwner; + + public WeakHandler(T owner) { + mOwner = new WeakReference<>(owner); + } + + public T getOwner() { + return mOwner.get(); + } +} From 8397fa7ce4c77e5f1ce2d6e7107e9ef306f1d62d Mon Sep 17 00:00:00 2001 From: fengjian Date: Sat, 7 May 2016 16:53:43 +0800 Subject: [PATCH 04/39] fix the ViewThrottleClickListener code style --- .../lesscode/core/other/ViewThrottleClickListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java index 0f838b3..daf412d 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java @@ -9,7 +9,7 @@ */ public abstract class ViewThrottleClickListener implements View.OnClickListener { private static final int THROTTLE_TIME_DEFAULT = 1000; // 1s - public long lastClickTime = 0; + private long mLastClickTime = 0; public long getThrottleTime() { return THROTTLE_TIME_DEFAULT; @@ -20,8 +20,8 @@ public long getThrottleTime() { @Override public void onClick(View v) { long currentTime = Calendar.getInstance().getTimeInMillis(); - if (currentTime - lastClickTime > getThrottleTime()) { - lastClickTime = currentTime; + if (currentTime - mLastClickTime > getThrottleTime()) { + mLastClickTime = currentTime; throttleClick(v); } } From 8bc8f73870c2fd0818eed8a87cd5cb5891d06276 Mon Sep 17 00:00:00 2001 From: fengjian Date: Sat, 7 May 2016 17:10:01 +0800 Subject: [PATCH 05/39] release the v0.9.2 version --- lesscode-core/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 0cbb471..a87657a 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.1" // #CONFIG# // project version +version = "0.9.2" // #CONFIG# // project version android { compileSdkVersion 23 @@ -24,8 +24,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:23.2.1' - compile 'com.android.support:recyclerview-v7:23.2.1' + compile 'com.android.support:support-v4:23.3.0' + compile 'com.android.support:recyclerview-v7:23.3.0' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage From 63dfa6fb27d0f9c53448fe5ce1801fadcd6b471b Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 8 May 2016 18:39:43 +0800 Subject: [PATCH 06/39] add basic travis config --- .travis.yml | 13 +++++++++++++ README-cn.md | 2 +- README.md | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b594fd4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: android +android: + components: + # Uncomment the lines below if you want to + # use the latest revision of Android SDK Tools + # - platform-tools + # - tools + + # The BuildTools version used by your project + - build-tools-23.0.2 + + # The SDK version used to compile your project + - android-21 diff --git a/README-cn.md b/README-cn.md index 9ec97d2..5c72db3 100644 --- a/README-cn.md +++ b/README-cn.md @@ -1,4 +1,4 @@ -# LessCode [![Jcenter Status](https://api.bintray.com/packages/openproject/maven/lesscode/images/download.svg)](https://bintray.com/openproject/maven/lesscode) +# LessCode [![Jcenter Status](https://api.bintray.com/packages/openproject/maven/lesscode/images/download.svg)](https://bintray.com/openproject/maven/lesscode) [![Build Status](https://travis-ci.org/openproject/LessCode.svg)](https://travis-ci.org/openproject/LessCode) 打造精简、高效的最好Android工具库! diff --git a/README.md b/README.md index 2b92b06..82a9c75 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #### [中文版文档](https://github.com/openproject/LessCode/blob/master/README-cn.md) -# LessCode [![Jcenter Status](https://api.bintray.com/packages/openproject/maven/lesscode/images/download.svg)](https://bintray.com/openproject/maven/lesscode) +# LessCode [![Jcenter Status](https://api.bintray.com/packages/openproject/maven/lesscode/images/download.svg)](https://bintray.com/openproject/maven/lesscode) [![Build Status](https://travis-ci.org/openproject/LessCode.svg)](https://travis-ci.org/openproject/LessCode) less code, more efficient for android, for the best android tools library! From 21a46449e3661e5f52664a1e90166410a69f36e5 Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 8 May 2016 22:24:45 +0800 Subject: [PATCH 07/39] clean useless app-ref-lesscode-core module --- app-ref-lesscode-core/.gitignore | 1 - app-ref-lesscode-core/build.gradle | 29 -------- app-ref-lesscode-core/proguard-rules.pro | 17 ----- .../app/ref/lesscodecore/ApplicationTest.java | 13 ---- .../src/main/AndroidManifest.xml | 21 ------ .../app/ref/lesscodecore/MainActivity.java | 66 ------------------ .../src/main/res/layout/activity_main.xml | 17 ----- .../src/main/res/menu/menu_main.xml | 6 -- .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3418 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2206 -> 0 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4842 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 7718 -> 0 bytes .../src/main/res/values-w820dp/dimens.xml | 6 -- .../src/main/res/values/dimens.xml | 5 -- .../src/main/res/values/strings.xml | 6 -- .../src/main/res/values/styles.xml | 8 --- settings.gradle | 2 +- 17 files changed, 1 insertion(+), 196 deletions(-) delete mode 100644 app-ref-lesscode-core/.gitignore delete mode 100644 app-ref-lesscode-core/build.gradle delete mode 100644 app-ref-lesscode-core/proguard-rules.pro delete mode 100644 app-ref-lesscode-core/src/androidTest/java/com/jayfeng/lesscode/app/ref/lesscodecore/ApplicationTest.java delete mode 100644 app-ref-lesscode-core/src/main/AndroidManifest.xml delete mode 100644 app-ref-lesscode-core/src/main/java/com/jayfeng/lesscode/app/ref/lesscodecore/MainActivity.java delete mode 100644 app-ref-lesscode-core/src/main/res/layout/activity_main.xml delete mode 100644 app-ref-lesscode-core/src/main/res/menu/menu_main.xml delete mode 100644 app-ref-lesscode-core/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 app-ref-lesscode-core/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 app-ref-lesscode-core/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 app-ref-lesscode-core/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 app-ref-lesscode-core/src/main/res/values-w820dp/dimens.xml delete mode 100644 app-ref-lesscode-core/src/main/res/values/dimens.xml delete mode 100644 app-ref-lesscode-core/src/main/res/values/strings.xml delete mode 100644 app-ref-lesscode-core/src/main/res/values/styles.xml diff --git a/app-ref-lesscode-core/.gitignore b/app-ref-lesscode-core/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/app-ref-lesscode-core/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app-ref-lesscode-core/build.gradle b/app-ref-lesscode-core/build.gradle deleted file mode 100644 index c26e719..0000000 --- a/app-ref-lesscode-core/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" - - defaultConfig { - applicationId "com.jayfeng.lesscode.app.ref.lesscodecore" - minSdkVersion 9 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.2.1' - compile('com.jayfeng:lesscode-core:0.7.8') { - exclude group: 'com.android.support', module: 'support-v4' - exclude group: 'com.android.support', module: 'appcompat-v7' - } -} diff --git a/app-ref-lesscode-core/proguard-rules.pro b/app-ref-lesscode-core/proguard-rules.pro deleted file mode 100644 index 3ffecd2..0000000 --- a/app-ref-lesscode-core/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /home/jay/tools/android-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 *; -#} diff --git a/app-ref-lesscode-core/src/androidTest/java/com/jayfeng/lesscode/app/ref/lesscodecore/ApplicationTest.java b/app-ref-lesscode-core/src/androidTest/java/com/jayfeng/lesscode/app/ref/lesscodecore/ApplicationTest.java deleted file mode 100644 index 2a9b149..0000000 --- a/app-ref-lesscode-core/src/androidTest/java/com/jayfeng/lesscode/app/ref/lesscodecore/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jayfeng.lesscode.app.ref.lesscodecore; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app-ref-lesscode-core/src/main/AndroidManifest.xml b/app-ref-lesscode-core/src/main/AndroidManifest.xml deleted file mode 100644 index b52f528..0000000 --- a/app-ref-lesscode-core/src/main/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app-ref-lesscode-core/src/main/java/com/jayfeng/lesscode/app/ref/lesscodecore/MainActivity.java b/app-ref-lesscode-core/src/main/java/com/jayfeng/lesscode/app/ref/lesscodecore/MainActivity.java deleted file mode 100644 index 6fcff14..0000000 --- a/app-ref-lesscode-core/src/main/java/com/jayfeng/lesscode/app/ref/lesscodecore/MainActivity.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.jayfeng.lesscode.app.ref.lesscodecore; - -import android.app.Activity; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.TextView; - -import com.jayfeng.lesscode.core.AdapterLess; -import com.jayfeng.lesscode.core.ToastLess; -import com.jayfeng.lesscode.core.ViewLess; - -import java.util.ArrayList; -import java.util.List; - - -public class MainActivity extends Activity { - - private TextView textView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - textView = ViewLess.$(this, R.id.text); - - ToastLess.$(this, textView.getText().toString()); - - List list = new ArrayList<>(); - list.add("A"); - list.add("B"); - - - AdapterLess.$pager(this, list, R.layout.activity_main, new AdapterLess.PageCallBack() { - @Override - public void instantiateItem(int i, View view, Object o) { - - } - }); - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_main, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - return true; - } - - return super.onOptionsItemSelected(item); - } -} diff --git a/app-ref-lesscode-core/src/main/res/layout/activity_main.xml b/app-ref-lesscode-core/src/main/res/layout/activity_main.xml deleted file mode 100644 index cb4b9cb..0000000 --- a/app-ref-lesscode-core/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - diff --git a/app-ref-lesscode-core/src/main/res/menu/menu_main.xml b/app-ref-lesscode-core/src/main/res/menu/menu_main.xml deleted file mode 100644 index c24a41e..0000000 --- a/app-ref-lesscode-core/src/main/res/menu/menu_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/app-ref-lesscode-core/src/main/res/mipmap-hdpi/ic_launcher.png b/app-ref-lesscode-core/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3418 zcmZ{nX*|@A^T0p5j$I+^%FVhdvMbgt%d+mG98ubwNv_tpITppba^GiieBBZGI>I89 zGgm8TA>_)DlEu&W;s3#ZUNiH4&CF{a%siTjzG;eOzQB6{003qKeT?}z_5U*{{kgZ; zdV@U&tqa-&4FGisjMN8o=P}$t-`oTM2oeB5d9mHPgTYJx4jup)+5a;Tke$m708DocFzDL>U$$}s6FGiy_I1?O zHXq`q884|^O4Q*%V#vwxqCz-#8i`Gu)2LeB0{%%VKunOF%9~JcFB9MM>N00M`E~;o zBU%)O5u-D6NF~OQV7TV#JAN;=Lylgxy0kncoQpGq<<_gxw`FC=C-cV#$L|(47Hatl ztq3Jngq00x#}HGW@_tj{&A?lwOwrVX4@d66vLVyj1H@i}VD2YXd)n03?U5?cKtFz4 zW#@+MLeDVP>fY0F2IzT;r5*MAJ2}P8Z{g3utX0<+ZdAC)Tvm-4uN!I7|BTw&G%RQn zR+A5VFx(}r<1q9^N40XzP=Jp?i=jlS7}T~tB4CsWx!XbiHSm zLu}yar%t>-3jlutK=wdZhES->*1X({YI;DN?6R=C*{1U6%wG`0>^?u}h0hhqns|SeTmV=s;Gxx5F9DtK>{>{f-`SpJ`dO26Ujk?^%ucsuCPe zIUk1(@I3D^7{@jmXO2@<84|}`tDjB}?S#k$ik;jC))BH8>8mQWmZ zF#V|$gW|Xc_wmmkoI-b5;4AWxkA>>0t4&&-eC-J_iP(tLT~c6*(ZnSFlhw%}0IbiJ ztgnrZwP{RBd(6Ds`dM~k;rNFgkbU&Yo$KR#q&%Kno^YXF5ONJwGwZ*wEr4wYkGiXs z$&?qX!H5sV*m%5t@3_>ijaS5hp#^P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ref-lesscode-core/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4842 zcmZ{oXE5C1x5t0WvTCfdv7&7fy$d2l*k#q|U5FAbL??P!61}%ovaIM)mL!5G(V|6J zAtDH(OY|Du^}l!K&fFLG%sJ2JIp@rG=9y>Ci)Wq~U2RobsvA@Q0MM$dq4lq5{hy#9 zzgp+B{O(-=?1<7r0l>Q?>N6X%s~lmgrmqD6fjj_!c?AF`S0&6U06Z51fWOuNAe#jM z%pSN#J-Mp}`ICpL=qp~?u~Jj$6(~K_%)9}Bn(;pY0&;M00H9x2N23h=CpR7kr8A9X zU%oh4-E@i!Ac}P+&%vOPQ3warO9l!SCN)ixGW54Jsh!`>*aU)#&Mg7;#O_6xd5%I6 zneGSZL3Kn-4B^>#T7pVaIHs3^PY-N^v1!W=%gzfioIWosZ!BN?_M)OOux&6HCyyMf z3ToZ@_h75A33KyC!T)-zYC-bp`@^1n;w3~N+vQ0#4V7!f|JPMlWWJ@+Tg~8>1$GzLlHGuxS)w&NAF*&Y;ef`T^w4HP7GK%6UA8( z{&ALM(%!w2U7WFWwq8v4H3|0cOjdt7$JLh(;U8VcTG;R-vmR7?21nA?@@b+XPgJbD z*Y@v&dTqo5Bcp-dIQQ4@?-m{=7>`LZ{g4jvo$CE&(+7(rp#WShT9&9y>V#ikmXFau03*^{&d(AId0Jg9G;tc7K_{ivzBjqHuJx08cx<8U`z2JjtOK3( zvtuduBHha>D&iu#))5RKXm>(|$m=_;e?7ZveYy=J$3wjL>xPCte-MDcVW<;ng`nf= z9);CVVZjI-&UcSAlhDB{%0v$wPd=w6MBwsVEaV!hw~8G(rs`lw@|#AAHbyA&(I-7Y zFE&1iIGORsaskMqSYfX33U%&17oTszdHPjr&Sx(`IQzoccST*}!cU!ZnJ+~duBM6f z{Lf8PITt%uWZ zTY09Jm5t<2+Un~yC-%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28oLS`Suf6OCp~f{0-aQ`t5YZ=!CAMc6-RZw#}A%;s44 znf2`6gcgm=0SezTH9h+JzeR3Lcm;8?*@+?FDfguK^9)z(Z`I!RKrSAI?H~4et6GTkz07Qgq4B6%Q*8Y0yPc4x z8(^YwtZjYIeOvVLey#>@$UzIciJ#x0pJLFg=8UaZv%-&?Yzp7gWNIo_x^(d75=x2c zv|LQ`HrKP(8TqFxTiP5gdT2>aTN0S7XW*pilASS$UkJ2*n+==D)0mgTGxv43t61fr z47GkfMnD-zSH@|mZ26r*d3WEtr+l-xH@L}BM)~ThoMvKqGw=Ifc}BdkL$^wC}=(XSf4YpG;sA9#OSJf)V=rs#Wq$?Wj+nTlu$YXn yn3SQon5>kvtkl(BT2@T#Mvca!|08g9w{vm``2PjZHg=b<1c17-HkzPl9sXa)&-Ts$ diff --git a/app-ref-lesscode-core/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app-ref-lesscode-core/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7718 zcmZ{JWl)?=u?hpbj?h-6mfK3P*Eck~k0Tzeg5-hkABxtZea0_k$f-mlF z0S@Qqtva`>x}TYzc}9LrO?P#qj+P1@HZ?W?0C;Muih9o&|G$cb@ocx1*PEUJ%~tM} z901hB;rx4#{@jOHs_MN00ADr$2n+#$yJuJ64gh!x0KlF(07#?(0ENrf7G3D`0EUHz zisCaq%dJ9dz%zhdRNuG*01nCjDhiPCl@b8xIMfv7^t~4jVRrSTGYyZUWqY@yW=)V_ z&3sUP1SK9v1f{4lDSN(agrKYULc;#EGDVeU*5b@#MOSY5JBn#QG8wqxQh+mdR638{mo5f>O zLUdZIPSjFk0~F26zDrM3y_#P^P91oWtLlPaZrhnM$NR%qsbHHK#?fN?cX?EvAhY1Sr9A(1;Kw4@87~|;2QP~ z(kKOGvCdB}qr4m#)1DwQFlh^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lN&8;0>!pq^f*Jlh=J%Rmaoed<=uf@$iKl+bieC83IT!09J&IF)9H)C?d!eW1UQ}BQwxaqQY47DpOk@`zZ zo>#SM@oI^|nrWm~Ol7=r`!Bp9lQNbBCeHcfN&X$kjj0R(@?f$OHHt|fWe6jDrYg3(mdEd$8P2Yzjt9*EM zLE|cp-Tzsdyt(dvLhU8}_IX&I?B=|yoZ!&<`9&H5PtApt=VUIB4l0a1NH v0SQqt3DM`an1p};^>=lX|A*k@Y-MNT^ZzF}9G-1G696?OEyXH%^Pv9$0dR%J diff --git a/app-ref-lesscode-core/src/main/res/values-w820dp/dimens.xml b/app-ref-lesscode-core/src/main/res/values-w820dp/dimens.xml deleted file mode 100644 index 63fc816..0000000 --- a/app-ref-lesscode-core/src/main/res/values-w820dp/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 64dp - diff --git a/app-ref-lesscode-core/src/main/res/values/dimens.xml b/app-ref-lesscode-core/src/main/res/values/dimens.xml deleted file mode 100644 index 47c8224..0000000 --- a/app-ref-lesscode-core/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 16dp - 16dp - diff --git a/app-ref-lesscode-core/src/main/res/values/strings.xml b/app-ref-lesscode-core/src/main/res/values/strings.xml deleted file mode 100644 index 8878ed6..0000000 --- a/app-ref-lesscode-core/src/main/res/values/strings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - AppRef-LesscodeCore - - Hello world! - Settings - diff --git a/app-ref-lesscode-core/src/main/res/values/styles.xml b/app-ref-lesscode-core/src/main/res/values/styles.xml deleted file mode 100644 index 9812b28..0000000 --- a/app-ref-lesscode-core/src/main/res/values/styles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/settings.gradle b/settings.gradle index 174e218..e414997 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':lesscode-core', ':app-ref-lesscode-core' +include ':app', ':lesscode-core' From 967ef247fdc0ece36600cdda0d7767372352c936 Mon Sep 17 00:00:00 2001 From: fengjian Date: Thu, 16 Jun 2016 20:29:57 +0800 Subject: [PATCH 08/39] support recyclerview gridlayoutmanager space divider (only space) --- .../adapterless/RecyclerAdapterActivity.java | 52 +++++++++++++++++-- .../res/layout/activity_main_list_item.xml | 5 +- lesscode-core/build.gradle | 6 +-- .../core/other/DividerItemDecoration.java | 37 ++++++++----- 4 files changed, 79 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java index 8362bbd..a9163ef 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java @@ -5,6 +5,7 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.GradientDrawable; import android.os.Bundle; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.widget.TextView; @@ -33,10 +34,12 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_adapter_recycler); recyclerView = ViewLess.$(this, R.id.recycler); - layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); +// layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); + layoutManager = new GridLayoutManager(this, 4); recyclerView.setLayoutManager(layoutManager); - dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL_LIST, getResources().getDrawable(R.drawable.list_divider)); - dividerItemDecoration.setWidth(DisplayLess.$dp2px(16) + 1); + dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.GRID_LIST, new ColorDrawable(Color.parseColor("#00000000"))); + dividerItemDecoration.setWidth(DisplayLess.$dp2px(4)); + dividerItemDecoration.setHeight(DisplayLess.$dp2px(4)); initData(); @@ -64,6 +67,49 @@ private void initData() { list.add(new Person("header")); list.add(new Person("chras")); list.add(new Person("nichid")); + list.add(new Person("header")); + list.add(new Person("jay")); + list.add(new Person("bee")); + list.add(new Person("header")); + list.add(new Person("chras")); + list.add(new Person("nichid")); + list.add(new Person("header")); + list.add(new Person("jay")); + list.add(new Person("bee")); + list.add(new Person("header")); + list.add(new Person("chras")); + list.add(new Person("nichid")); + list.add(new Person("header")); + list.add(new Person("jay")); + list.add(new Person("bee")); + list.add(new Person("header")); + list.add(new Person("chras")); + list.add(new Person("nichid")); + list.add(new Person("header")); + list.add(new Person("jay")); + list.add(new Person("bee")); + list.add(new Person("header")); + list.add(new Person("chras")); + list.add(new Person("nichid")); + list.add(new Person("header")); + list.add(new Person("jay")); + list.add(new Person("bee")); + list.add(new Person("header")); + list.add(new Person("chras")); + list.add(new Person("nichid")); + list.add(new Person("header")); + list.add(new Person("jay")); + list.add(new Person("bee")); + list.add(new Person("header")); + list.add(new Person("chras")); + list.add(new Person("nichid")); + list.add(new Person("header")); + list.add(new Person("jay")); + list.add(new Person("bee")); + list.add(new Person("header")); + list.add(new Person("chras")); + list.add(new Person("nichid")); + list.add(new Person("nichid")); } } diff --git a/app/src/main/res/layout/activity_main_list_item.xml b/app/src/main/res/layout/activity_main_list_item.xml index ca83f07..e36b1db 100644 --- a/app/src/main/res/layout/activity_main_list_item.xml +++ b/app/src/main/res/layout/activity_main_list_item.xml @@ -1,6 +1,7 @@ + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="#00ff00"> Date: Thu, 14 Jul 2016 13:49:17 +0800 Subject: [PATCH 09/39] updata AdapterLesse --- lesscode-core/build.gradle | 2 +- .../jayfeng/lesscode/core/AdapterLess.java | 149 ++++++++++++++++-- .../lesscode/core/other/SpaceDividerView.java | 2 + 3 files changed, 139 insertions(+), 14 deletions(-) diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 55b565d..6397634 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.4" // #CONFIG# // project version +version = "0.9.6" // #CONFIG# // project version android { compileSdkVersion 23 diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java index b13271a..217801b 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java @@ -13,6 +13,7 @@ import android.widget.BaseAdapter; import java.util.List; +import java.util.Objects; /** * 适配器简化相关的工具类 @@ -27,17 +28,18 @@ public final class AdapterLess { * 1. 抽象出重复代码,默认实现一些常规代码 * 2. 封装了RecyclerViewHolder * 3. 自动传递Model给getView + * * @param context - * @param list model的列表 - * @param layoutId 布局xml的id + * @param list model的列表 + * @param layoutId 布局xml的id * @param recyclerCallBack 包含nBindViewHolder方法的回调 * @param r * @return */ public static RecyclerView.Adapter $recycler(final Context context, - final List list, - final int layoutId, - final RecyclerCallBack recyclerCallBack) { + final List list, + final int layoutId, + final RecyclerCallBack recyclerCallBack) { RecyclerView.Adapter result = new RecyclerView.Adapter() { @Override public RecyclerViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { @@ -72,17 +74,18 @@ public int getItemCount() { * 面向: RecyclerView * 支持多布局,也多增加了两个回调方法,便于自定义: * 1. getViewType + * * @param context - * @param list model的列表 - * @param layoutIds 布局xml的id + * @param list model的列表 + * @param layoutIds 布局xml的id * @param fullRecyclerCallBack 包含nBindViewHolder方法的回调 * @param r * @return */ public static RecyclerView.Adapter $recycler(final Context context, - final List list, - final int[] layoutIds, - final FullRecyclerCallBack fullRecyclerCallBack) { + final List list, + final int[] layoutIds, + final FullRecyclerCallBack fullRecyclerCallBack) { RecyclerView.Adapter result = new RecyclerView.Adapter() { @Override public RecyclerViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { @@ -123,8 +126,9 @@ public int getItemViewType(int position) { * 1. 抽象出重复代码,默认实现一些常规代码 * 2. 封装了ViewHolder * 3. 自动传递Model给getView + * * @param context - * @param list model的列表 + * @param list model的列表 * @param layoutId 布局xml的id * @param callBack 包含getView方法的回调 * @param @@ -183,9 +187,10 @@ public View getView(int position, View convertView, ViewGroup parent) { * 支持多布局,也多增加了两个回调方法,便于自定义: * 1. getViewType * 2. isEnabled + * * @param context - * @param list model列表 - * @param layoutIds 布局xml的id数组 + * @param list model列表 + * @param layoutIds 布局xml的id数组 * @param fullCallBack 包含getView,getViewType,isEnabled方法的回调 * @param * @return @@ -259,6 +264,7 @@ public View getView(int position, View convertView, ViewGroup parent) { * 1. 抽象出重复代码,默认实现一些常规代码 * 2. 封装了instantiateItem * 3. 自动传递Model给getView + * * @param context * @param list * @param layoutId @@ -298,11 +304,108 @@ public void destroyItem(ViewGroup container, int position, Object object) { return result; } + /** + * 创建PagerAdapter + * 面向: ViewPager + * 主要是: + * 1. 增加destroyItem + * + * @param context + * @param list + * @param layoutId + * @param fullPageCallBack + * @param + * @return + */ + public static PagerAdapter $pager(final Context context, + final List list, + final int layoutId, + final FullPageCallBack fullPageCallBack) { + PagerAdapter result = new PagerAdapter() { + + @Override + public int getCount() { + return list.size(); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view == object; + } + + @Override + public Object instantiateItem(ViewGroup container, int position) { + View view = LayoutInflater.from(context).inflate(layoutId, null); + container.addView(view); + fullPageCallBack.instantiateItem(position, view, list.get(position)); + return view; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object object) { + container.removeView((View) object); + fullPageCallBack.destroyItem(container, position, object, list.get(position)); + } + }; + return result; + } + + public static PagerAdapter $pagerWithDataChanged(final Context context, + final List list, + final int layoutId, + final FullPageCallBack fullPageCallBack) { + PagerAdapter result = new PagerAdapter() { + + private int mChildCount = 0; + + @Override + public int getCount() { + return list.size(); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view == object; + } + + @Override + public Object instantiateItem(ViewGroup container, int position) { + View view = LayoutInflater.from(context).inflate(layoutId, null); + container.addView(view); + fullPageCallBack.instantiateItem(position, view, list.get(position)); + return view; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object object) { + container.removeView((View) object); + fullPageCallBack.destroyItem(container, position, object, list.get(position)); + } + + @Override + public int getItemPosition(Object object) { + if (mChildCount > 0) { + mChildCount--; + return POSITION_NONE; + } + return super.getItemPosition(object); + } + + @Override + public void notifyDataSetChanged() { + mChildCount = getCount(); + super.notifyDataSetChanged(); + } + }; + return result; + } + /** * 创建了FragmentPagerAdapter * 面向: ViewPager * 主要是: * 1. 抽象出重复代码,默认实现getCount方法 + * * @param fragmentManager * @param count * @param fragmentPagerCallBack @@ -332,6 +435,7 @@ public int getCount() { * 通过getPageTitle回调方法支持fragment标题定义 * 主要是: * 1. 抽象出重复代码,默认实现getCount方法 + * * @param fragmentManager * @param count * @param fullFragmentPagerCallBack @@ -362,6 +466,7 @@ public String getPageTitle(int position) { /** * RecyclerCallBack + * * @param */ public interface RecyclerCallBack { @@ -370,15 +475,18 @@ public interface RecyclerCallBack { /** * RecyclerCallBack + * * @param */ public interface FullRecyclerCallBack { void onBindViewHolder(int position, RecyclerViewHolder recyclerViewHolder, T t); + int getItemViewType(int position); } /** * 简化版本的$base的CallBack + * * @param */ public interface CallBack { @@ -387,6 +495,7 @@ public interface CallBack { /** * 增强版本的$base的CallBack + * * @param */ public interface FullCallBack { @@ -399,12 +508,24 @@ public interface FullCallBack { /** * 简化版本的$pager的CallBack + * * @param */ public interface PageCallBack { void instantiateItem(int position, View view, T t); } + /** + * 简化版本的$pager的CallBack + * + * @param + */ + public interface FullPageCallBack { + void instantiateItem(int position, View view, T t); + + void destroyItem(ViewGroup container, int position, Object object, T t); + } + /** * 简化版本的$pager的CallBack(针对fragment) */ @@ -417,6 +538,7 @@ public interface FragmentPagerCallBack { */ public interface FullFragmentPagerCallBack { Fragment getItem(int position); + String getPageTitle(int position); } @@ -432,6 +554,7 @@ public static class ViewHolder { /** * 从缓存里获取viewId对应的View + * * @param convertView * @param viewId * @param diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java index 589d83d..dfa1e01 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java @@ -63,4 +63,6 @@ protected void onDraw(Canvas canvas) { canvas.drawRect(0, getMeasuredHeight() - mSpaceBottom, getMeasuredWidth(), getMeasuredHeight(), mPaint); } } + + } From 5843c4240bde2dd851549f3af9f55309e1856206 Mon Sep 17 00:00:00 2001 From: fengjian Date: Thu, 14 Jul 2016 14:01:03 +0800 Subject: [PATCH 10/39] add ApplicationLess init --- .../lesscode/core/ApplicationLess.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java new file mode 100644 index 0000000..7c13710 --- /dev/null +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java @@ -0,0 +1,29 @@ +package com.jayfeng.lesscode.core; + +import android.app.ActivityManager; +import android.content.Context; +import android.os.Process; + +import java.util.List; + +public final class ApplicationLess { + + /** + * 根据进程名称判断第一次真正的初始化 + * + * @param context + * @return + */ + private static boolean $init(Context context) { + ActivityManager am = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)); + List processInfos = am.getRunningAppProcesses(); + String mainProcessName = context.getPackageName(); + int myPid = Process.myPid(); + for (ActivityManager.RunningAppProcessInfo info : processInfos) { + if (info.pid == myPid && mainProcessName.equals(info.processName)) { + return true; + } + } + return false; + } +} From 75089e693731f0e8f9184ee3d9f46e98c709cabc Mon Sep 17 00:00:00 2001 From: fengjian Date: Thu, 14 Jul 2016 14:13:48 +0800 Subject: [PATCH 11/39] fix the update notification title to app name --- .../src/main/java/com/jayfeng/lesscode/core/UpdateService.java | 1 + .../src/main/res/layout/less_app_update_notification.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java index 97da256..429b53d 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java @@ -156,6 +156,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { mNotification.icon = $.sUpdateIcon != 0 ? $.sUpdateIcon : R.drawable.less_app_update_icon; mNotification.tickerText = getText(R.string.less_app_download_notification_start); mNotification.contentIntent = mPendingIntent; + mNotification.contentView.setTextViewText(R.id.less_app_update_title, AppLess.$appname()); mNotification.contentView.setProgressBar(R.id.less_app_update_progressbar, 100, 0, false); mNotification.contentView.setTextViewText(R.id.less_app_update_progress_text, "0%"); if ($.sUpdateIcon != 0) { diff --git a/lesscode-core/src/main/res/layout/less_app_update_notification.xml b/lesscode-core/src/main/res/layout/less_app_update_notification.xml index 53ba61c..0e8bcae 100755 --- a/lesscode-core/src/main/res/layout/less_app_update_notification.xml +++ b/lesscode-core/src/main/res/layout/less_app_update_notification.xml @@ -28,7 +28,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> - Date: Sun, 17 Jul 2016 10:15:01 +0800 Subject: [PATCH 12/39] update travis target sdk --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b594fd4..6792daf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ android: - build-tools-23.0.2 # The SDK version used to compile your project - - android-21 + - android-23 From 8a48d73dd79c7a70fe9576eb465e2850cdda99d6 Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 17 Jul 2016 10:23:59 +0800 Subject: [PATCH 13/39] update travis and readme --- .travis.yml | 2 ++ README.md | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6792daf..78a0eaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,9 @@ android: # - tools # The BuildTools version used by your project + - tools - build-tools-23.0.2 # The SDK version used to compile your project - android-23 + - extra-android-m2repository diff --git a/README.md b/README.md index 82a9c75..1d8619b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ #### [中文版文档](https://github.com/openproject/LessCode/blob/master/README-cn.md) -# LessCode [![Jcenter Status](https://api.bintray.com/packages/openproject/maven/lesscode/images/download.svg)](https://bintray.com/openproject/maven/lesscode) [![Build Status](https://travis-ci.org/openproject/LessCode.svg)](https://travis-ci.org/openproject/LessCode) +# LessCode +[![Jcenter Status](https://api.bintray.com/packages/openproject/maven/lesscode/images/download.svg)](https://bintray.com/openproject/maven/lesscode) +[![Build Status](https://travis-ci.org/openproject/LessCode.svg)](https://travis-ci.org/openproject/LessCode) +[![MethodCount][methodcount-svg]][methodcount-link] less code, more efficient for android, for the best android tools library! @@ -128,3 +131,5 @@ 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. ``` +[methodcount-svg]: https://img.shields.io/badge/Methodscount-717-e91e63.svg +[methodcount-link]: http://www.methodscount.com/?lib=com.jayfeng%3Alesscode-core%3A0.9.6.1 From 295ca4d42a4506a329d00d9effaee5440dddefed Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 17 Jul 2016 10:43:13 +0800 Subject: [PATCH 14/39] fix the travis build error --- app/build.gradle | 4 ++++ .../jayfeng/lesscode/app/ApplicationTest.java | 13 ------------- lesscode-core/build.gradle | 16 ++++++++++++---- .../jayfeng/lesscode/core/ApplicationTest.java | 13 ------------- 4 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 app/src/androidTest/java/com/jayfeng/lesscode/app/ApplicationTest.java delete mode 100644 lesscode-core/src/androidTest/java/com/jayfeng/lesscode/core/ApplicationTest.java diff --git a/app/build.gradle b/app/build.gradle index f0b6b51..6b6502d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,6 +17,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + lintOptions { + abortOnError false + } } dependencies { diff --git a/app/src/androidTest/java/com/jayfeng/lesscode/app/ApplicationTest.java b/app/src/androidTest/java/com/jayfeng/lesscode/app/ApplicationTest.java deleted file mode 100644 index c8260ef..0000000 --- a/app/src/androidTest/java/com/jayfeng/lesscode/app/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jayfeng.lesscode.app; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 6397634..d4bded4 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -20,6 +20,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + lintOptions { + abortOnError false + } } dependencies { @@ -80,15 +84,19 @@ task javadocJar(type: Jar, dependsOn: javadoc) { } artifacts { - archives javadocJar + // archives javadocJar archives sourcesJar } Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) +boolean isHasFile = false +if (project.rootProject.findProject('local.properties') != null){ + isHasFile = true + properties.load(project.rootProject.file('local.properties').newDataInputStream()) +} bintray { - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") + user = isHasFile ? properties.getProperty("bintray.user") : System.getenv("bintray.user") + key = isHasFile ? properties.getProperty("bintray.apikey") : System.getenv("bintray.apikey") configurations = ['archives'] pkg { repo = "maven" diff --git a/lesscode-core/src/androidTest/java/com/jayfeng/lesscode/core/ApplicationTest.java b/lesscode-core/src/androidTest/java/com/jayfeng/lesscode/core/ApplicationTest.java deleted file mode 100644 index 896d6d6..0000000 --- a/lesscode-core/src/androidTest/java/com/jayfeng/lesscode/core/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jayfeng.lesscode.core; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file From 917d77d5c4635700b3d5c920bcaee5b2ec3139c6 Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 17 Jul 2016 11:13:54 +0800 Subject: [PATCH 15/39] update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1d8619b..af3484c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ #### [中文版文档](https://github.com/openproject/LessCode/blob/master/README-cn.md) -# LessCode [![Jcenter Status](https://api.bintray.com/packages/openproject/maven/lesscode/images/download.svg)](https://bintray.com/openproject/maven/lesscode) [![Build Status](https://travis-ci.org/openproject/LessCode.svg)](https://travis-ci.org/openproject/LessCode) [![MethodCount][methodcount-svg]][methodcount-link] +# LessCode less code, more efficient for android, for the best android tools library! ## Overview @@ -12,13 +12,13 @@ less code, more efficient for android, for the best android tools library! > * support more effective methods than android > * high performence > * easy integration -> * small size (less than 50k, only 45k+ by proguard) +> * small size (only 45k~ by proguard) > * open source ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:0.9.1') { +compile('com.jayfeng:lesscode-core:0.9.6.1') { // exclusion for update the android support jar // for example, you can use the appcompat-v7 in your project exclude group: 'com.android.support', module: 'support-v4' From cbe09fee83105d15a8e6a2b49c26552d07d2abfd Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 24 Jul 2016 00:51:29 +0800 Subject: [PATCH 16/39] fix the local.properties read error when bintrayUpload --- lesscode-core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index d4bded4..992874a 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -90,7 +90,7 @@ artifacts { Properties properties = new Properties() boolean isHasFile = false -if (project.rootProject.findProject('local.properties') != null){ +if (project.rootProject.file('local.properties') != null){ isHasFile = true properties.load(project.rootProject.file('local.properties').newDataInputStream()) } From a08d0571e3d9cfa734784a80107afd4f7fe3efce Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 2 Aug 2016 08:53:47 +0800 Subject: [PATCH 17/39] Revert "fix the local.properties read error when bintrayUpload" This reverts commit cbe09fee83105d15a8e6a2b49c26552d07d2abfd. --- lesscode-core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 992874a..d4bded4 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -90,7 +90,7 @@ artifacts { Properties properties = new Properties() boolean isHasFile = false -if (project.rootProject.file('local.properties') != null){ +if (project.rootProject.findProject('local.properties') != null){ isHasFile = true properties.load(project.rootProject.file('local.properties').newDataInputStream()) } From 431bde2298d00923122e9d308e6c0742fc59ee68 Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 23 Aug 2016 16:08:33 +0800 Subject: [PATCH 18/39] add set space method --- lesscode-core/build.gradle | 2 +- .../lesscode/core/other/SpaceDividerView.java | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index d4bded4..7a8db97 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.6" // #CONFIG# // project version +version = "0.9.6.1" // #CONFIG# // project version android { compileSdkVersion 23 diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java index dfa1e01..6a3492c 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/SpaceDividerView.java @@ -64,5 +64,28 @@ protected void onDraw(Canvas canvas) { } } + public void setSpaceLeft(int spaceLeft) { + this.mSpaceLeft = spaceLeft; + invalidate(); + } + + public void setSpaceTop(int spaceTop) { + this.mSpaceTop = spaceTop; + invalidate(); + } + + public void setSpaceRight(int spaceRight) { + this.mSpaceRight = spaceRight; + invalidate(); + } + + public void setSpaceBottom(int spaceBottom) { + this.mSpaceBottom = spaceBottom; + invalidate(); + } + public void setSpaceColor(int spaceColor) { + this.mSpaceColor = spaceColor; + invalidate(); + } } From 19f9f2b70d202779291acccda0a8855f2f961dda Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 23 Aug 2016 20:59:39 +0800 Subject: [PATCH 19/39] add $xxxhdpi and sp2px method --- lesscode-core/build.gradle | 2 +- .../jayfeng/lesscode/core/DisplayLess.java | 41 +++++++++++++++---- .../src/main/res/values-hdpi/bools.xml | 1 + .../src/main/res/values-ldpi/bools.xml | 1 + .../src/main/res/values-mdpi/bools.xml | 1 + .../src/main/res/values-tvdpi/bools.xml | 1 + .../src/main/res/values-xhdpi/bools.xml | 1 + .../src/main/res/values-xxhdpi/bools.xml | 1 + .../src/main/res/values-xxxhdpi/bools.xml | 10 +++++ 9 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 lesscode-core/src/main/res/values-xxxhdpi/bools.xml diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 7a8db97..853e2ca 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.6.1" // #CONFIG# // project version +version = "0.9.6.2" // #CONFIG# // project version android { compileSdkVersion 23 diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java index ba73365..969d054 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java @@ -18,6 +18,7 @@ public final class DisplayLess { /** * 屏幕宽度 + * * @param activity * @return */ @@ -29,6 +30,7 @@ public final class DisplayLess { /** * 屏幕高度 + * * @param activity * @return */ @@ -40,6 +42,7 @@ public final class DisplayLess { /** * dp转px + * * @param dp * @return */ @@ -47,9 +50,21 @@ public final class DisplayLess { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); } + /** + * sp转px + * + * @param sp + * @return + */ + public static int $sp2px(float sp) { + float scale = Resources.getSystem().getDisplayMetrics().scaledDensity; + return (int) (sp * scale + 0.5f); + } + /** * 获取状态栏高度 * 注: 该方法在onCreate中获取值为0 + * * @param activity * @return */ @@ -62,6 +77,7 @@ public final class DisplayLess { /** * 获取状态栏高度 * 注: 该方法在onCreate中获取值为0 + * * @param resources * @return */ @@ -77,7 +93,7 @@ public final class DisplayLess { field = c.getField("status_bar_height"); x = Integer.parseInt(field.get(obj).toString()); statusBarHeight = resources.getDimensionPixelSize(x); - } catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); } return statusBarHeight; @@ -85,6 +101,7 @@ public final class DisplayLess { /** * 获取标题栏高度 + * * @param activity * @return */ @@ -96,6 +113,7 @@ public final class DisplayLess { /** * 是否为平板 + * * @param context * @return */ @@ -111,22 +129,31 @@ public final class DisplayLess { * 各大设备密度判断 * **************************** */ - public static boolean isLdpi() { + public static boolean $ldpi() { return $.sAppContext.getResources().getBoolean(R.bool.less_ldpi); } - public static boolean isMdpi() { + + public static boolean $mdpi() { return $.sAppContext.getResources().getBoolean(R.bool.less_mdpi); } - public static boolean isTVdpi() { + + public static boolean $tvdpi() { return $.sAppContext.getResources().getBoolean(R.bool.less_tvdpi); } - public static boolean isHdpi() { + + public static boolean $hdpi() { return $.sAppContext.getResources().getBoolean(R.bool.less_hdpi); } - public static boolean isXHdpi() { + + public static boolean $xhdpi() { return $.sAppContext.getResources().getBoolean(R.bool.less_xhdpi); } - public static boolean isXXHdpi() { + + public static boolean $xxhdpi() { return $.sAppContext.getResources().getBoolean(R.bool.less_xxhdpi); } + + public static boolean $xxxhdpi() { + return $.sAppContext.getResources().getBoolean(R.bool.less_xxxhdpi); + } } diff --git a/lesscode-core/src/main/res/values-hdpi/bools.xml b/lesscode-core/src/main/res/values-hdpi/bools.xml index 9ee1bad..15e7bf1 100644 --- a/lesscode-core/src/main/res/values-hdpi/bools.xml +++ b/lesscode-core/src/main/res/values-hdpi/bools.xml @@ -6,4 +6,5 @@ true false false + false \ No newline at end of file diff --git a/lesscode-core/src/main/res/values-ldpi/bools.xml b/lesscode-core/src/main/res/values-ldpi/bools.xml index 9d45f0e..af66e2a 100644 --- a/lesscode-core/src/main/res/values-ldpi/bools.xml +++ b/lesscode-core/src/main/res/values-ldpi/bools.xml @@ -6,4 +6,5 @@ false false false + false \ No newline at end of file diff --git a/lesscode-core/src/main/res/values-mdpi/bools.xml b/lesscode-core/src/main/res/values-mdpi/bools.xml index e5d0e67..b6e468c 100644 --- a/lesscode-core/src/main/res/values-mdpi/bools.xml +++ b/lesscode-core/src/main/res/values-mdpi/bools.xml @@ -6,4 +6,5 @@ false false false + false \ No newline at end of file diff --git a/lesscode-core/src/main/res/values-tvdpi/bools.xml b/lesscode-core/src/main/res/values-tvdpi/bools.xml index 9214cf2..8bb3bf4 100644 --- a/lesscode-core/src/main/res/values-tvdpi/bools.xml +++ b/lesscode-core/src/main/res/values-tvdpi/bools.xml @@ -6,4 +6,5 @@ false false false + false \ No newline at end of file diff --git a/lesscode-core/src/main/res/values-xhdpi/bools.xml b/lesscode-core/src/main/res/values-xhdpi/bools.xml index f74fff0..2071961 100644 --- a/lesscode-core/src/main/res/values-xhdpi/bools.xml +++ b/lesscode-core/src/main/res/values-xhdpi/bools.xml @@ -6,4 +6,5 @@ false true false + false \ No newline at end of file diff --git a/lesscode-core/src/main/res/values-xxhdpi/bools.xml b/lesscode-core/src/main/res/values-xxhdpi/bools.xml index 1eb0eb7..7696bba 100644 --- a/lesscode-core/src/main/res/values-xxhdpi/bools.xml +++ b/lesscode-core/src/main/res/values-xxhdpi/bools.xml @@ -6,4 +6,5 @@ false false true + false \ No newline at end of file diff --git a/lesscode-core/src/main/res/values-xxxhdpi/bools.xml b/lesscode-core/src/main/res/values-xxxhdpi/bools.xml new file mode 100644 index 0000000..c6c675c --- /dev/null +++ b/lesscode-core/src/main/res/values-xxxhdpi/bools.xml @@ -0,0 +1,10 @@ + + + false + false + false + false + false + false + true + \ No newline at end of file From b0ac601acafc3e91a4c385bdc3ee9741558c85f7 Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 24 Aug 2016 11:00:59 +0800 Subject: [PATCH 20/39] split the update feature to lesscode-update aar --- app/src/main/AndroidManifest.xml | 4 - .../lesscode/app/activity/MainActivity.java | 5 - .../lesscode/app/activity/UpdateActivity.java | 24 -- build.gradle | 4 +- gradle/wrapper/gradle-wrapper.properties | 4 +- lesscode-core/build.gradle | 4 +- lesscode-core/src/main/AndroidManifest.xml | 5 +- .../com/jayfeng/lesscode/core/UpdateLess.java | 106 ------- .../jayfeng/lesscode/core/UpdateService.java | 269 ------------------ .../drawable-xhdpi/less_app_update_icon.png | Bin 588 -> 0 bytes .../layout/less_app_update_notification.xml | 59 ---- lesscode-core/src/main/res/values/strings.xml | 11 - 12 files changed, 7 insertions(+), 488 deletions(-) delete mode 100644 app/src/main/java/com/jayfeng/lesscode/app/activity/UpdateActivity.java delete mode 100644 lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateLess.java delete mode 100644 lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java delete mode 100644 lesscode-core/src/main/res/drawable-xhdpi/less_app_update_icon.png delete mode 100755 lesscode-core/src/main/res/layout/less_app_update_notification.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6023813..e62253b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,7 +6,6 @@ @@ -37,9 +36,6 @@ - diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java index b341140..b57dd9b 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java @@ -165,11 +165,6 @@ private void initData() { lessItem.setClassName("ToastActivity"); list.add(lessItem); - lessItem = new LessItem(); - lessItem.setName("UpdateLess的使用"); - lessItem.setClassName("UpdateActivity"); - list.add(lessItem); - lessItem = new LessItem(); lessItem.setName("ViewLess的使用"); lessItem.setClassName("ViewActivity"); diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/UpdateActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/UpdateActivity.java deleted file mode 100644 index 3dbb731..0000000 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/UpdateActivity.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.jayfeng.lesscode.app.activity; - -import android.app.Activity; -import android.os.Bundle; - -import com.jayfeng.lesscode.app.R; -import com.jayfeng.lesscode.core.UpdateLess; - -public class UpdateActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_update); - - String updateJson = "{\n" + - " \"vercode\":112,\n" + - " \"vername\":\"V1.1\",\n" + - " \"download\":\"http://www.apk.anzhi.com/data3/apk/201506/09/3a978f27369b4a8bf6de1270da9871ec_86281300.apk\",\n" + - " \"log\":\"upgrade content\"\n" + - " }"; - UpdateLess.$check(this, updateJson); - } -} diff --git a/build.gradle b/build.gradle index b64644f..068cb92 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:2.1.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d570517..0e65f82 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Wed Aug 24 08:51:21 CST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 853e2ca..fa35a12 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,11 +2,11 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.6.2" // #CONFIG# // project version +version = "0.9.7" // #CONFIG# // project version android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion "23.0.3" // resourcePrefix "less_" // #CONFIG# // please remove this if you don't known it defaultConfig { minSdkVersion 8 diff --git a/lesscode-core/src/main/AndroidManifest.xml b/lesscode-core/src/main/AndroidManifest.xml index a015d3a..25dc021 100644 --- a/lesscode-core/src/main/AndroidManifest.xml +++ b/lesscode-core/src/main/AndroidManifest.xml @@ -8,9 +8,6 @@ - - - - + diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateLess.java deleted file mode 100644 index 467426a..0000000 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateLess.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.jayfeng.lesscode.core; - -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * 检查更新工具类 - * { - * "vercode":1, - * "vername":"v1.1", - * "download":"http://www.jayfeng.com/lesscode-app.apk", - * "log":"upgrade content" - * } - */ -public final class UpdateLess { - - /** - * 解析json和本地信息比较,判断是否有更新 - * @return 有更新则返回true,否则返回false - */ - public static boolean $check(final Context context, String updateJson) { - int vercode = 0; - String vername = ""; - String log = ""; - String download; - - JSONObject jsonObject; - try { - jsonObject = new JSONObject(updateJson); - vercode = jsonObject.optInt("vercode"); - vername = jsonObject.optString("vername"); - download = jsonObject.optString("download"); - log = jsonObject.optString("log"); - } catch (JSONException e) { - e.printStackTrace(); - return false; - } - - return $check(context, vercode, vername, download, log); - } - - /** - * 根据解析的结果来比较是否有更新 - * @param context - * @param vercode - * @param vername - * @param download - * @param log - * @return - */ - public static boolean $check(final Context context, - int vercode, - String vername, - final String download, - String log) { - // 无更新 - if (!$hasUpdate(vercode)) { - return false; - } - - // 有更新,则弹出对话框告知用户 - new AlertDialog.Builder(context) - .setTitle(context.getString(R.string.less_app_download_dialog_title) + vername) - .setMessage(log) - .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(context, UpdateService.class); - intent.putExtra($.KEY_DOWNLOAD_URL, download); - context.startService(intent); - } - }).show(); - - return true; - } - - /** - * 根据版本判断是否有更新 - * @param vercode - * @return - */ - public static boolean $hasUpdate(int vercode) { - if (vercode <= AppLess.$vercode()) { - return false; - } - return true; - } - - /** - * 启动下载服务,开始下载APK文件 - * @param context - * @param download - */ - public static void $download(Context context, String download) { - Intent intent = new Intent(context, UpdateService.class); - intent.putExtra($.KEY_DOWNLOAD_URL, download); - context.startService(intent); - } -} diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java deleted file mode 100644 index 429b53d..0000000 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/UpdateService.java +++ /dev/null @@ -1,269 +0,0 @@ -package com.jayfeng.lesscode.core; - -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.app.Service; -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Environment; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; -import android.text.TextUtils; -import android.view.View; -import android.widget.RemoteViews; -import android.widget.Toast; - -import java.io.File; -import java.net.URLEncoder; - -/** - * 检查更新后台下载服务 - */ -public class UpdateService extends Service { - - private static final int DOWNLOAD_STATE_FAILURE = -1; - private static final int DOWNLOAD_STATE_SUCCESS = 0; - private static final int DOWNLOAD_STATE_START = 1; - private static final int DOWNLOAD_STATE_INSTALL = 2; - private static final int DOWNLOAD_STATE_ERROR_SDCARD = 3; - private static final int DOWNLOAD_STATE_ERROR_URL = 4; - - private static final int NOTIFICATION_ID = 3956; - private NotificationManager mNotificationManager = null; - private Notification mNotification = null; - private PendingIntent mPendingIntent = null; - - private String mDownloadSDPath; - private String mDownloadUrl; - private File mDestDir; - private File mDestFile; - - private boolean mIsDownloading = false; - - private Handler.Callback mHandlerCallBack = new Handler.Callback() { - @Override - public boolean handleMessage(Message msg) { - switch (msg.what) { - case DOWNLOAD_STATE_SUCCESS: - Toast.makeText(getApplicationContext(), R.string.less_app_download_success, Toast.LENGTH_LONG).show(); - install(mDestFile); - break; - case DOWNLOAD_STATE_FAILURE: - Toast.makeText(getApplicationContext(), R.string.less_app_download_failure, Toast.LENGTH_LONG).show(); - mNotificationManager.cancel(NOTIFICATION_ID); - break; - case DOWNLOAD_STATE_START: - Toast.makeText(getApplicationContext(), R.string.less_app_download_start, Toast.LENGTH_LONG).show(); - break; - case DOWNLOAD_STATE_INSTALL: - Toast.makeText(getApplicationContext(), R.string.less_app_download_install, Toast.LENGTH_LONG).show(); - break; - case DOWNLOAD_STATE_ERROR_SDCARD: - Toast.makeText(getApplicationContext(), R.string.less_app_download_error_sdcard, Toast.LENGTH_LONG).show(); - break; - case DOWNLOAD_STATE_ERROR_URL: - Toast.makeText(getApplicationContext(), R.string.less_app_download_error_url, Toast.LENGTH_LONG).show(); - break; - default: - break; - } - return true; - } - }; - private Handler mHandler = new Handler(mHandlerCallBack); - - private HttpLess.DownloadCallBack mDownloadCallBack = new HttpLess.DownloadCallBack() { - - @Override - public void onDownloading(int progress) { - if (progress % $.sNotificationFrequent == 0 || progress == 1 || progress == 100) { - mNotification.contentView.setProgressBar(R.id.less_app_update_progressbar, 100, progress, false); - mNotification.contentView.setTextViewText(R.id.less_app_update_progress_text, progress + "%"); - mNotificationManager.notify(NOTIFICATION_ID, mNotification); - } - } - - @Override - public void onDownloaded() { - mNotification.contentView.setViewVisibility(R.id.less_app_update_progress_block, View.GONE); - mNotification.defaults = Notification.DEFAULT_SOUND; - mNotification.contentIntent = mPendingIntent; - mNotification.contentView.setTextViewText(R.id.less_app_update_progress_text, getText(R.string.less_app_download_notification_success)); - mNotificationManager.notify(NOTIFICATION_ID, mNotification); - if (mDestFile.exists() && mDestFile.isFile() && checkApkFile(mDestFile.getPath())) { - Message msg = mHandler.obtainMessage(); - msg.what = DOWNLOAD_STATE_SUCCESS; - mHandler.sendMessage(msg); - } - mNotificationManager.cancel(NOTIFICATION_ID); - } - }; - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - - // check downloading state - if (mIsDownloading) { - ToastLess.$(this, R.string.less_app_download_downloading); - return super.onStartCommand(intent, flags, startId); - } - - mDownloadUrl = intent.getStringExtra($.KEY_DOWNLOAD_URL); - if (TextUtils.isEmpty($.sDownloadSDPath)) { - mDownloadSDPath = getPackageName() + "/download"; - } else { - mDownloadSDPath = $.sDownloadSDPath; - } - - if (TextUtils.isEmpty(mDownloadUrl)) { - sendMessage(DOWNLOAD_STATE_ERROR_URL); - return super.onStartCommand(intent, flags, startId); - } - - if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - mDestDir = new File(Environment.getExternalStorageDirectory().getPath() - + "/" + mDownloadSDPath); - if (mDestDir.exists()) { - File destFile = new File(mDestDir.getPath() + "/" + URLEncoder.encode(mDownloadUrl)); - if (destFile.exists() && destFile.isFile() && checkApkFile(destFile.getPath())) { - - sendMessage(DOWNLOAD_STATE_INSTALL); - install(destFile); - stopSelf(); - return super.onStartCommand(intent, flags, startId); - } - } - } else { - sendMessage(DOWNLOAD_STATE_ERROR_SDCARD); - return super.onStartCommand(intent, flags, startId); - } - - mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - mNotification = new Notification(); - - mNotification.contentView = new RemoteViews(getApplication().getPackageName(), R.layout.less_app_update_notification); - - Intent completingIntent = new Intent(); - completingIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); - completingIntent.setClass(getApplicationContext(), UpdateService.class); - - mPendingIntent = PendingIntent.getActivity(UpdateService.this, R.string.less_app_name, completingIntent, PendingIntent.FLAG_UPDATE_CURRENT); - - mNotification.icon = $.sUpdateIcon != 0 ? $.sUpdateIcon : R.drawable.less_app_update_icon; - mNotification.tickerText = getText(R.string.less_app_download_notification_start); - mNotification.contentIntent = mPendingIntent; - mNotification.contentView.setTextViewText(R.id.less_app_update_title, AppLess.$appname()); - mNotification.contentView.setProgressBar(R.id.less_app_update_progressbar, 100, 0, false); - mNotification.contentView.setTextViewText(R.id.less_app_update_progress_text, "0%"); - if ($.sUpdateIcon != 0) { - mNotification.contentView.setImageViewResource(R.id.less_app_update_progress_icon, $.sUpdateIcon); - } - mNotificationManager.cancel(NOTIFICATION_ID); - mNotificationManager.notify(NOTIFICATION_ID, mNotification); - - // 启动线程开始下载 - new UpdateThread().start(); - - return super.onStartCommand(intent, flags, startId); - } - - /** - * 检查apk文件是否有效(是正确下载,没有损坏的) - * @param apkFilePath - * @return - */ - public boolean checkApkFile(String apkFilePath) { - boolean result; - try { - PackageManager pManager = getPackageManager(); - PackageInfo pInfo = pManager.getPackageArchiveInfo(apkFilePath, PackageManager.GET_ACTIVITIES); - if (pInfo == null) { - result = false; - } else { - result = true; - } - } catch (Exception e) { - result = false; - e.printStackTrace(); - } - return result; - } - - /** - * 调用系统Intent安装apk包 - * @param apkFile - */ - private void install(File apkFile) { - Uri uri = Uri.fromFile(apkFile); - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.setDataAndType(uri, "application/vnd.android.package-archive"); - startActivity(intent); - } - - private void sendMessage(int what) { - Message msg = mHandler.obtainMessage(); - msg.what = what; - mHandler.sendMessage(msg); - } - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mHandler.removeCallbacksAndMessages(null); - } - - /** - * 下载线程 - */ - class UpdateThread extends Thread { - - @Override - public void run() { - if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - if (mDestDir == null) { - mDestDir = new File(Environment.getExternalStorageDirectory().getPath() - + "/" + mDownloadSDPath); - } - - if (mDestDir.exists() && !mDestDir.isDirectory()) { - mDestDir.delete(); - } - - if (mDestDir.exists() || mDestDir.mkdirs()) { - mDestFile = new File(mDestDir.getPath() - + "/" + URLEncoder.encode(mDownloadUrl)); - - if (mDestFile.exists() - && mDestFile.isFile() - && checkApkFile(mDestFile.getPath())) { - sendMessage(DOWNLOAD_STATE_INSTALL); - install(mDestFile); - } else { - try { - sendMessage(DOWNLOAD_STATE_START); - mIsDownloading = true; - HttpLess.$download(mDownloadUrl, mDestFile, false, mDownloadCallBack); - } catch (Exception e) { - sendMessage(DOWNLOAD_STATE_FAILURE); - e.printStackTrace(); - } - } - } - } else { - sendMessage(DOWNLOAD_STATE_ERROR_SDCARD); - } - mIsDownloading = false; - stopSelf(); - } - } -} diff --git a/lesscode-core/src/main/res/drawable-xhdpi/less_app_update_icon.png b/lesscode-core/src/main/res/drawable-xhdpi/less_app_update_icon.png deleted file mode 100644 index cf16b95c7d481b011496e1d02824f20d85ff4600..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 588 zcmV-S0<-;zP)#V4I5=YAI}v#?o+sVN)rTE&rktj(NrF)hg4=;{@7@hq|_mj9jm&k!YnEF9=LwGa~z) z=*n>w*)P8Tpa*M0q*-3;9SUM%?`W2lG&xaWOHcT%uZiWFe3ETz{*I@%2vHAD)J(;2 zAtReRt_?+^j~^T9`(EmS$rJG#2$#Qk0;>9_v9o-k?ZC - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lesscode-core/src/main/res/values/strings.xml b/lesscode-core/src/main/res/values/strings.xml index f22b5d3..26de80e 100644 --- a/lesscode-core/src/main/res/values/strings.xml +++ b/lesscode-core/src/main/res/values/strings.xml @@ -1,14 +1,3 @@ LessCode Core - - 发现新版本: - 开始下载 - 下载完成。 - 新版本下载成功,开始安装。 - 新版本下载失败,请稍后再试。 - 已经在下载中 - 开始下载 - 准备安装 - 未找到SD卡,无法下载。 - 下载地址错误,无法下载。 \ No newline at end of file From e6f375e2ef4c8da5bd65e19b09f4f8319699efef Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 27 Sep 2016 10:30:39 +0800 Subject: [PATCH 21/39] fix the project build in android studio 2.2 --- app/build.gradle | 2 +- build.gradle | 6 +++--- lesscode-core/build.gradle | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6b6502d..d73afcd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion "24.0.2" defaultConfig { applicationId "com.jayfeng.lesscode.app" diff --git a/build.gradle b/build.gradle index 068cb92..f723421 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.3' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4' + classpath 'com.android.tools.build:gradle:2.2.0' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index fa35a12..d5bda35 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -6,7 +6,7 @@ version = "0.9.7" / android { compileSdkVersion 23 - buildToolsVersion "23.0.3" + buildToolsVersion "24.0.2" // resourcePrefix "less_" // #CONFIG# // please remove this if you don't known it defaultConfig { minSdkVersion 8 From 98cfb43f3a1905c02b1a1f0cab20788d8cbe5f47 Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 27 Sep 2016 12:15:43 +0800 Subject: [PATCH 22/39] release 0.9.8: optimize the DisplayLess width and height, ToastLess show --- .../lesscode/app/activity/DisplayActivity.java | 1 + .../lesscode/app/activity/ToastActivity.java | 4 ++++ lesscode-core/build.gradle | 2 +- .../com/jayfeng/lesscode/core/DisplayLess.java | 15 +++++++++------ .../java/com/jayfeng/lesscode/core/ToastLess.java | 9 +++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/DisplayActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/DisplayActivity.java index 27f0b24..6470ea4 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/DisplayActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/DisplayActivity.java @@ -15,6 +15,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display); + ToastLess.$(this, DisplayLess.$width(this) + "x" + DisplayLess.$height(this)); new Handler().postDelayed(new Runnable() { @Override diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/ToastActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/ToastActivity.java index e830192..71721b8 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/ToastActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/ToastActivity.java @@ -4,6 +4,7 @@ import android.os.Bundle; import com.jayfeng.lesscode.app.R; +import com.jayfeng.lesscode.core.ToastLess; public class ToastActivity extends Activity { @@ -11,5 +12,8 @@ public class ToastActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_toast); + + + ToastLess.$("xxxxx"); } } diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index d5bda35..ff7a443 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.7" // #CONFIG# // project version +version = "0.9.8" // #CONFIG# // project version android { compileSdkVersion 23 diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java index 969d054..561a340 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DisplayLess.java @@ -8,6 +8,7 @@ import android.graphics.Rect; import android.util.DisplayMetrics; import android.view.Window; +import android.view.WindowManager; import java.lang.reflect.Field; @@ -19,24 +20,26 @@ public final class DisplayLess { /** * 屏幕宽度 * - * @param activity + * @param context * @return */ - public static int $width(Activity activity) { + public static int $width(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); - activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); + WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + windowManager.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; } /** * 屏幕高度 * - * @param activity + * @param context * @return */ - public static int $height(Activity activity) { + public static int $height(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); - activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); + WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + windowManager.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.heightPixels; } diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ToastLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ToastLess.java index 31e5005..c28d5b9 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ToastLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ToastLess.java @@ -8,12 +8,21 @@ */ public final class ToastLess { + @Deprecated public static void $(Context context, String message) { Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_SHORT).show(); } + @Deprecated public static void $(Context context, int stringId) { Toast.makeText(context.getApplicationContext(), stringId, Toast.LENGTH_SHORT).show(); } + public static void $(String message) { + Toast.makeText($.sAppContext, message, Toast.LENGTH_SHORT).show(); + } + + public static void $(int stringId) { + Toast.makeText($.sAppContext, stringId, Toast.LENGTH_SHORT).show(); + } } From f96c243bbadc86726abe502ddf066c7b3a2a24fe Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 27 Sep 2016 12:21:09 +0800 Subject: [PATCH 23/39] update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index af3484c..defedba 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ less code, more efficient for android, for the best android tools library! ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:0.9.6.1') { +compile('com.jayfeng:lesscode-core:0.9.8') { // exclusion for update the android support jar // for example, you can use the appcompat-v7 in your project exclude group: 'com.android.support', module: 'support-v4' @@ -50,7 +50,7 @@ compile('com.jayfeng:lesscode-core:0.9.6.1') { |SharedPreferenceLess|简化和增强SharedPreference的操作| |StorageLess|手机存储相关,包括:手机内存,内置存储卡(Sdcard),外置存储卡(ExtSdcard)| |ToastLess|简化Toast的使用| -|UpdateLess/UpdateService|简单但完整的自动更新实现,无缝对接| +|UpdateLess/UpdateService|简单但完整的自动更新实现,无缝对接(已分离到LessCode-Update项目)| |ViewLess|简化繁琐的findViewById和强制转换| ## Usage From 04d6d7779586648215597554db15f9ca44b00bf7 Mon Sep 17 00:00:00 2001 From: fengjian Date: Thu, 13 Oct 2016 14:18:01 +0800 Subject: [PATCH 24/39] fix the get mac method's file inputstream not close leak --- build.gradle | 2 +- lesscode-core/build.gradle | 2 +- .../com/jayfeng/lesscode/core/DeviceLess.java | 41 ++++++++++++++----- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index f723421..f846ce1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0' + classpath 'com.android.tools.build:gradle:2.2.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index ff7a443..876c187 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.8" // #CONFIG# // project version +version = "0.9.8.1" // #CONFIG# // project version android { compileSdkVersion 23 diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DeviceLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DeviceLess.java index b99a9ba..c226f7e 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DeviceLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/DeviceLess.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.FileInputStream; +import java.io.IOException; /** * 设备相关的工具类 @@ -24,21 +25,41 @@ public final class DeviceLess { try { String path = "sys/class/net/wlan0/address"; if ((new File(path)).exists()) { - FileInputStream fis = new FileInputStream(path); - byte[] buffer = new byte[8192]; - int byteCount = fis.read(buffer); - if (byteCount > 0) { - result = new String(buffer, 0, byteCount, "utf-8"); + FileInputStream fis = null; + try { + fis = new FileInputStream(path); + byte[] buffer = new byte[8192]; + int byteCount = fis.read(buffer); + if (byteCount > 0) { + result = new String(buffer, 0, byteCount, "utf-8"); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fis != null) { + fis.close(); + } } + } if (TextUtils.isEmpty(result)) { path = "sys/class/net/eth0/address"; - FileInputStream fis_name = new FileInputStream(path); - byte[] buffer_name = new byte[8192]; - int byteCount_name = fis_name.read(buffer_name); - if (byteCount_name > 0) { - result = new String(buffer_name, 0, byteCount_name, "utf-8"); + FileInputStream fis_name = null; + try { + fis_name = new FileInputStream(path); + byte[] buffer_name = new byte[8192]; + int byteCount_name = fis_name.read(buffer_name); + if (byteCount_name > 0) { + result = new String(buffer_name, 0, byteCount_name, "utf-8"); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fis_name != null) { + fis_name.close(); + } } + } if (TextUtils.isEmpty(result)) { From 83384781d3b0b88493b2ee0622c5388e4b25b4bd Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 15 Nov 2016 14:22:38 +0800 Subject: [PATCH 25/39] fix the HttpLess and some build configs --- README.md | 7 +------ build.gradle | 2 +- lesscode-core/build.gradle | 14 +++++++------- .../java/com/jayfeng/lesscode/core/HttpLess.java | 4 +--- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index defedba..c6cd109 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,7 @@ less code, more efficient for android, for the best android tools library! ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:0.9.8') { - // exclusion for update the android support jar - // for example, you can use the appcompat-v7 in your project - exclude group: 'com.android.support', module: 'support-v4' - exclude group: 'com.android.support', module: 'appcompat-v7' -} +compile('com.jayfeng:lesscode-core:0.9.9') ``` ## Features diff --git a/build.gradle b/build.gradle index f846ce1..064f558 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 876c187..4624c18 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,15 +2,15 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "0.9.8.1" // #CONFIG# // project version +version = "0.9.9" // #CONFIG# // project version android { - compileSdkVersion 23 - buildToolsVersion "24.0.2" + compileSdkVersion 25 + buildToolsVersion "25.0.0" // resourcePrefix "less_" // #CONFIG# // please remove this if you don't known it defaultConfig { - minSdkVersion 8 - targetSdkVersion 23 + minSdkVersion 9 + targetSdkVersion 25 versionCode 1 versionName "1.0" } @@ -28,8 +28,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:23.4.0' - compile 'com.android.support:recyclerview-v7:23.4.0' + compile 'com.android.support:support-v4:25.0.0' + compile 'com.android.support:recyclerview-v7:25.0.0' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java index f0759ac..c782d31 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java @@ -293,10 +293,8 @@ public void run() { totalSize = 0; } } - } catch (IOException e) { - e.printStackTrace(); } catch (Exception e) { - e.printStackTrace(); + throw e; } finally { if (os != null) { os.close(); From 9847511d715024326ab8a092a60a672c0911bee3 Mon Sep 17 00:00:00 2001 From: fengjian Date: Tue, 15 Nov 2016 14:34:44 +0800 Subject: [PATCH 26/39] BOOM 1.0: fix the sp context with application context and release the version 1.0 --- README-cn.md | 9 ++---- README.md | 2 +- .../activity/SharedPreferenceActivity.java | 22 ++++++------- .../res/layout/activity_main_list_item.xml | 3 +- lesscode-core/build.gradle | 2 +- .../lesscode/core/SharedPreferenceLess.java | 32 +++++++++---------- 6 files changed, 32 insertions(+), 38 deletions(-) diff --git a/README-cn.md b/README-cn.md index 5c72db3..861e90b 100644 --- a/README-cn.md +++ b/README-cn.md @@ -13,12 +13,7 @@ ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:0.9.1') { - // exclusion for update the android support jar - // for example, you can use the appcompat-v7 in your project - exclude group: 'com.android.support', module: 'support-v4' - exclude group: 'com.android.support', module: 'appcompat-v7' -} +compile('com.jayfeng:lesscode-core:1.0') ``` ## Features @@ -45,7 +40,7 @@ compile('com.jayfeng:lesscode-core:0.9.1') { |SharedPreferenceLess|简化和增强SharedPreference的操作| |StorageLess|手机存储相关,包括:手机内存,内置存储卡(Sdcard),外置存储卡(ExtSdcard)| |ToastLess|简化Toast的使用| -|UpdateLess/UpdateService|简单但完整的自动更新实现,无缝对接| +|UpdateLess/UpdateService|简单但完整的自动更新实现,无缝对接(已分离到LessCode-Update项目)| |ViewLess|简化繁琐的findViewById和强制转换| ## Usage diff --git a/README.md b/README.md index c6cd109..c9f08da 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ less code, more efficient for android, for the best android tools library! ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:0.9.9') +compile('com.jayfeng:lesscode-core:1.0') ``` ## Features diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/SharedPreferenceActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/SharedPreferenceActivity.java index 92fe23e..7156472 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/SharedPreferenceActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/SharedPreferenceActivity.java @@ -15,17 +15,17 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_shared_preference); - SharedPreferenceLess.$put(this, "key1", 333); - SharedPreferenceLess.$put(this, "key2", 0.5f); - SharedPreferenceLess.$put(this, "key3", true); - SharedPreferenceLess.$put(this, "key4", 100000L); - SharedPreferenceLess.$put(this, "key5", "i am a string"); - SharedPreferenceLess.$put(this, "key5", null); + SharedPreferenceLess.$put("key1", 333); + SharedPreferenceLess.$put("key2", 0.5f); + SharedPreferenceLess.$put("key3", true); + SharedPreferenceLess.$put("key4", 100000L); + SharedPreferenceLess.$put("key5", "i am a string"); + SharedPreferenceLess.$put("key5", null); - LogLess.$d(SharedPreferenceLess.$get(this, "key1", 0) + ""); - LogLess.$d(SharedPreferenceLess.$get(this, "key2", 0f) + ""); - LogLess.$d(SharedPreferenceLess.$get(this, "key3", false) + ""); - LogLess.$d(SharedPreferenceLess.$get(this, "key4", 0L) + ""); - LogLess.$d(SharedPreferenceLess.$get(this, "key5", "")); + LogLess.$d(SharedPreferenceLess.$get("key1", 0) + ""); + LogLess.$d(SharedPreferenceLess.$get("key2", 0f) + ""); + LogLess.$d(SharedPreferenceLess.$get("key3", false) + ""); + LogLess.$d(SharedPreferenceLess.$get("key4", 0L) + ""); + LogLess.$d(SharedPreferenceLess.$get("key5", "")); } } diff --git a/app/src/main/res/layout/activity_main_list_item.xml b/app/src/main/res/layout/activity_main_list_item.xml index e36b1db..847d0ee 100644 --- a/app/src/main/res/layout/activity_main_list_item.xml +++ b/app/src/main/res/layout/activity_main_list_item.xml @@ -1,7 +1,6 @@ + android:layout_height="wrap_content"> void $put(Context context, String key, T value) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static void $put(String key, T value) { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); @@ -37,46 +37,46 @@ public final class SharedPreferenceLess { SharedPreferencesCompat.apply(editor); } - public static String $get(Context context, String key, String defaultValue) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static String $get(String key, String defaultValue) { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); return sp.getString(key, defaultValue); } - public static boolean $get(Context context, String key, boolean defaultValue) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static boolean $get(String key, boolean defaultValue) { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); return sp.getBoolean(key, defaultValue); } - public static float $get(Context context, String key, float defaultValue) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static float $get(String key, float defaultValue) { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); return sp.getFloat(key, defaultValue); } - public static int $get(Context context, String key, int defaultValue) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static int $get(String key, int defaultValue) { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); return sp.getInt(key, defaultValue); } - public static long $get(Context context, String key, long defaultValue) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static long $get(String key, long defaultValue) { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); return sp.getLong(key, defaultValue); } - public static void $remove(Context context, String key) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static void $remove(String key) { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.remove(key); SharedPreferencesCompat.apply(editor); } - public static void $clear(Context context) { - SharedPreferences sp = context.getSharedPreferences(SHARED_NAME, + public static void $clear() { + SharedPreferences sp = $.sAppContext.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.clear(); From d3720097a8a86ee386f0335a21223cb810387cc0 Mon Sep 17 00:00:00 2001 From: fengjian Date: Fri, 23 Dec 2016 14:02:15 +0800 Subject: [PATCH 27/39] add discardClick to ViewThrottleClickListener and release 1.1 --- build.gradle | 2 +- lesscode-core/build.gradle | 10 +++++----- .../lesscode/core/other/ViewThrottleClickListener.java | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 064f558..47804e3 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:2.2.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 074c1e7..d48786a 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,11 +2,11 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "1.0" // #CONFIG# // project version +version = "1.1" // #CONFIG# // project version android { compileSdkVersion 25 - buildToolsVersion "25.0.0" + buildToolsVersion "25.0.2" // resourcePrefix "less_" // #CONFIG# // please remove this if you don't known it defaultConfig { minSdkVersion 9 @@ -28,8 +28,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:25.0.0' - compile 'com.android.support:recyclerview-v7:25.0.0' + compile 'com.android.support:support-v4:25.1.0' + compile 'com.android.support:recyclerview-v7:25.1.0' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage @@ -90,7 +90,7 @@ artifacts { Properties properties = new Properties() boolean isHasFile = false -if (project.rootProject.findProject('local.properties') != null){ +if (project.rootProject.file('local.properties') != null){ isHasFile = true properties.load(project.rootProject.file('local.properties').newDataInputStream()) } diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java index daf412d..98a1cb9 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/other/ViewThrottleClickListener.java @@ -14,6 +14,7 @@ public abstract class ViewThrottleClickListener implements View.OnClickListener public long getThrottleTime() { return THROTTLE_TIME_DEFAULT; } + public void discardClick() {} public abstract void throttleClick(View view); @@ -23,6 +24,8 @@ public void onClick(View v) { if (currentTime - mLastClickTime > getThrottleTime()) { mLastClickTime = currentTime; throttleClick(v); + } else { + discardClick(); } } } From 6c744831b74b876c19d7753c30d4587a07e82f11 Mon Sep 17 00:00:00 2001 From: fengjian Date: Thu, 19 Jan 2017 17:02:44 +0800 Subject: [PATCH 28/39] add AdapterViewTypeRecyclerCallBack and release v1.2 --- app/build.gradle | 6 +- .../adapterless/BaseAdapterActivity.java | 4 +- .../adapterless/RecyclerAdapterActivity.java | 51 ++++++++++++---- .../res/layout/adapter_list_item_header.xml | 2 +- lesscode-core/build.gradle | 2 +- .../jayfeng/lesscode/core/AdapterLess.java | 6 +- .../core/AdapterViewTypeRecyclerCallBack.java | 58 +++++++++++++++++++ 7 files changed, 108 insertions(+), 21 deletions(-) create mode 100644 lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java diff --git a/app/build.gradle b/app/build.gradle index d73afcd..ec60648 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "24.0.2" + compileSdkVersion 25 + buildToolsVersion "25.0.2" defaultConfig { applicationId "com.jayfeng.lesscode.app" minSdkVersion 9 - targetSdkVersion 21 + targetSdkVersion 25 versionCode 1 versionName "1.0" } diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java index d4deedd..140d2e5 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java @@ -10,6 +10,7 @@ import com.jayfeng.lesscode.app.R; import com.jayfeng.lesscode.app.model.Person; import com.jayfeng.lesscode.core.AdapterLess; +import com.jayfeng.lesscode.core.AdapterViewTypeRecyclerCallBack; import com.jayfeng.lesscode.core.ViewLess; import java.util.ArrayList; @@ -40,6 +41,7 @@ public View getView(int position, View convertView, AdapterLess.ViewHolder holde } }); */ + // full callback adapter = AdapterLess.$base(this, list, new int[] { R.layout.activity_main_list_item, R.layout.adapter_list_item_header}, new AdapterLess.FullCallBack() { @@ -69,7 +71,7 @@ public boolean isEnabled(int position) { return true; } }); - // full callback + listView.setAdapter(adapter); } diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java index a9163ef..e999789 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java @@ -13,6 +13,7 @@ import com.jayfeng.lesscode.app.R; import com.jayfeng.lesscode.app.model.Person; import com.jayfeng.lesscode.core.AdapterLess; +import com.jayfeng.lesscode.core.AdapterViewTypeRecyclerCallBack; import com.jayfeng.lesscode.core.DisplayLess; import com.jayfeng.lesscode.core.ViewLess; import com.jayfeng.lesscode.core.other.DividerItemDecoration; @@ -34,8 +35,8 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_adapter_recycler); recyclerView = ViewLess.$(this, R.id.recycler); -// layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); - layoutManager = new GridLayoutManager(this, 4); + layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); +// layoutManager = new GridLayoutManager(this, 4); recyclerView.setLayoutManager(layoutManager); dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.GRID_LIST, new ColorDrawable(Color.parseColor("#00000000"))); dividerItemDecoration.setWidth(DisplayLess.$dp2px(4)); @@ -43,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) { initData(); + /* adapter = AdapterLess.$recycler(this, list, R.layout.activity_main_list_item, new AdapterLess.RecyclerCallBack() { @@ -53,6 +55,33 @@ public void onBindViewHolder(int position, AdapterLess.RecyclerViewHolder recycl nameView.setText(person.getName()); } }); + */ + + adapter = AdapterLess.$recycler(this, list, + new int[] { R.layout.activity_main_list_item, R.layout.adapter_list_item_header}, + new AdapterViewTypeRecyclerCallBack() { + @Override + public int getItemViewType(int position) { + Person person = list.get(position); + if ("header".equals(person.getName())) { + return 1; + } else { + return 0; + } + } + + @Override + public void onViewType0(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, Person person) { + TextView nameView = recyclerViewHolder.$view(R.id.name); + nameView.setText(person.getName()); + } + + @Override + public void onViewType1(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, Person person) { + TextView nameView = recyclerViewHolder.$view(R.id.name); + nameView.setText(person.getName() + " >>"); + } + }); recyclerView.setAdapter(adapter); @@ -98,18 +127,18 @@ private void initData() { list.add(new Person("chras")); list.add(new Person("nichid")); list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); + list.add(new Person("gggggg")); + list.add(new Person("ggxxx")); + list.add(new Person("gewewewe")); + list.add(new Person("gtyyyy")); + list.add(new Person("guugyyyy")); list.add(new Person("header")); list.add(new Person("jay")); - list.add(new Person("bee")); + list.add(new Person("zzzzzzzzzz")); list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - list.add(new Person("nichid")); + list.add(new Person("yyyyyyyyyyyyyy")); + list.add(new Person("etrtertret")); + list.add(new Person("zsssss")); } } diff --git a/app/src/main/res/layout/adapter_list_item_header.xml b/app/src/main/res/layout/adapter_list_item_header.xml index 33c19af..0b70684 100644 --- a/app/src/main/res/layout/adapter_list_item_header.xml +++ b/app/src/main/res/layout/adapter_list_item_header.xml @@ -1,6 +1,6 @@ * @return */ - public static FragmentPagerAdapter $pager(FragmentManager fragmentManager, + public static FragmentPagerAdapter $pager(FragmentManager fragmentManager, final int count, final FragmentPagerCallBack fragmentPagerCallBack) { FragmentPagerAdapter result = new FragmentPagerAdapter(fragmentManager) { @@ -439,10 +438,9 @@ public int getCount() { * @param fragmentManager * @param count * @param fullFragmentPagerCallBack - * @param * @return */ - public static FragmentPagerAdapter $pager(final FragmentManager fragmentManager, + public static FragmentPagerAdapter $pager(final FragmentManager fragmentManager, final int count, final FullFragmentPagerCallBack fullFragmentPagerCallBack) { FragmentPagerAdapter result = new FragmentPagerAdapter(fragmentManager) { diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java new file mode 100644 index 0000000..a5d3938 --- /dev/null +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java @@ -0,0 +1,58 @@ +package com.jayfeng.lesscode.core; + +/** + * 进一步分发多种类型的FullRecyclerCallBack + * @param + */ +public abstract class AdapterViewTypeRecyclerCallBack implements AdapterLess.FullRecyclerCallBack { + + @Override + public void onBindViewHolder(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + onViewCommon(position, recyclerViewHolder, t); + + if (getItemViewType(position) == 0) { + onViewType0(position, recyclerViewHolder, t); + } else if (getItemViewType(position) == 1) { + onViewType1(position, recyclerViewHolder, t); + } else if (getItemViewType(position) == 2) { + onViewType2(position, recyclerViewHolder, t); + } else if (getItemViewType(position) == 3) { + onViewType3(position, recyclerViewHolder, t); + } else if (getItemViewType(position) == 4) { + onViewType4(position, recyclerViewHolder, t); + } else if (getItemViewType(position) == 5) { + onViewType5(position, recyclerViewHolder, t); + } + } + + public void onViewCommon(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + + } + + public void onViewType0(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + + } + + public void onViewType1(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + + } + + public void onViewType2(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + + } + + public void onViewType3(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + + } + + public void onViewType4(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + + } + + public void onViewType5(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { + + } + + @Override + public abstract int getItemViewType(int position); +} From fc67baacc60a9c1ca0f94e98e15d18eda3c55001 Mon Sep 17 00:00:00 2001 From: fengjian Date: Fri, 20 Jan 2017 20:52:47 +0800 Subject: [PATCH 29/39] clean AdapterLess and AdapterViewTypeRecyclerCallBack and release v2.0 --- app/src/main/AndroidManifest.xml | 3 - .../app/activity/AdapterActivity.java | 74 --- .../app/activity/DrawableActivity.java | 5 - .../lesscode/app/activity/MainActivity.java | 68 +- .../adapterless/BaseAdapterActivity.java | 89 --- .../adapterless/PagerAdapterActivity.java | 56 -- .../adapterless/RecyclerAdapterActivity.java | 144 ----- lesscode-core/build.gradle | 2 +- .../jayfeng/lesscode/core/AdapterLess.java | 583 ------------------ .../core/AdapterViewTypeRecyclerCallBack.java | 58 -- 10 files changed, 27 insertions(+), 1055 deletions(-) delete mode 100644 app/src/main/java/com/jayfeng/lesscode/app/activity/AdapterActivity.java delete mode 100644 app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java delete mode 100644 app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/PagerAdapterActivity.java delete mode 100644 app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java delete mode 100644 lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java delete mode 100644 lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e62253b..dfbd8b5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,9 +24,6 @@ - diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/AdapterActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/AdapterActivity.java deleted file mode 100644 index b581a68..0000000 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/AdapterActivity.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.jayfeng.lesscode.app.activity; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.ListView; -import android.widget.TextView; - -import com.jayfeng.lesscode.app.R; -import com.jayfeng.lesscode.app.model.LessItem; -import com.jayfeng.lesscode.core.AdapterLess; -import com.jayfeng.lesscode.core.ViewLess; - -import java.util.ArrayList; -import java.util.List; - -public class AdapterActivity extends Activity { - - List list; - ListView listView; - BaseAdapter adapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_adapter); - - listView = ViewLess.$(this, R.id.listview); - - initData(); - - adapter = AdapterLess.$base(this, list, R.layout.activity_main_list_item, - new AdapterLess.CallBack() { - @Override - public View getView(int position, View convertView, AdapterLess.ViewHolder holder, LessItem lessItem) { - TextView nameView = holder.$view(convertView, R.id.name); - nameView.setText(lessItem.getName()); - return convertView; - } - }); - listView.setAdapter(adapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - Intent intent = new Intent(); - intent.setClassName(AdapterActivity.this, "com.jayfeng.lesscode.app.activity.adapterless." + list.get(position).getClassName()); - startActivity(intent); - } - }); - } - - private void initData() { - list = new ArrayList<>(); - - LessItem lessItem = new LessItem(); - lessItem.setName("AdapterLess.$base的使用"); - lessItem.setClassName("BaseAdapterActivity"); - list.add(lessItem); - - lessItem = new LessItem(); - lessItem.setName("AdapterLess.$pager的使用"); - lessItem.setClassName("PagerAdapterActivity"); - list.add(lessItem); - - lessItem = new LessItem(); - lessItem.setName("AdapterLess.$recycler的使用"); - lessItem.setClassName("RecyclerAdapterActivity"); - list.add(lessItem); - } - -} diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/DrawableActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/DrawableActivity.java index 800cc86..b04f197 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/DrawableActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/DrawableActivity.java @@ -6,18 +6,13 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.v4.graphics.drawable.DrawableCompat; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; -import android.widget.BaseAdapter; -import android.widget.Button; import android.widget.ImageView; import android.widget.Spinner; import com.jayfeng.lesscode.app.R; -import com.jayfeng.lesscode.core.AdapterLess; -import com.jayfeng.lesscode.core.AppLess; import com.jayfeng.lesscode.core.DrawableLess; import com.jayfeng.lesscode.core.ToastLess; import com.jayfeng.lesscode.core.ViewLess; diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java index b57dd9b..d14f98a 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java @@ -1,27 +1,16 @@ package com.jayfeng.lesscode.app.activity; import android.app.Activity; -import android.content.Intent; import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.ListView; -import android.widget.TextView; import com.jayfeng.lesscode.app.R; import com.jayfeng.lesscode.app.model.LessItem; -import com.jayfeng.lesscode.app.model.Person; import com.jayfeng.lesscode.core.ActivityLess; -import com.jayfeng.lesscode.core.AdapterLess; -import com.jayfeng.lesscode.core.LogLess; -import com.jayfeng.lesscode.core.NetworkLess; -import com.jayfeng.lesscode.core.SerializeLess; -import com.jayfeng.lesscode.core.SharedPreferenceLess; import com.jayfeng.lesscode.core.ToastLess; import com.jayfeng.lesscode.core.ViewLess; -import java.io.File; import java.util.ArrayList; import java.util.List; @@ -43,32 +32,32 @@ protected void onCreate(Bundle savedInstanceState) { initData(); - adapter = AdapterLess.$base(this, list, R.layout.activity_main_list_item, - new AdapterLess.CallBack() { - @Override - public View getView(int position, View convertView, AdapterLess.ViewHolder holder, LessItem lessItem) { - TextView nameView = holder.$view(convertView, R.id.name); - nameView.setText(lessItem.getName()); - return convertView; - } - }); - listView.setAdapter(adapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - Intent intent = new Intent(); - intent.setClassName(MainActivity.this, "com.jayfeng.lesscode.app.activity." + list.get(position).getClassName()); - startActivity(intent); - } - }); - - LogLess.$d("network: %s, type: %s", NetworkLess.$online(), NetworkLess.$type()); - - Person person = new Person("fengj"); - SerializeLess.$se(new File(getCacheDir(), "person").getAbsolutePath(), person); - - Person person1 = SerializeLess.$de(new File(getCacheDir(), "person").getAbsolutePath()); - ToastLess.$(this, person1.getName()); +// adapter = AdapterLess.$base(this, list, R.layout.activity_main_list_item, +// new AdapterLess.CallBack() { +// @Override +// public View getView(int position, View convertView, AdapterLess.ViewHolder holder, LessItem lessItem) { +// TextView nameView = holder.$view(convertView, R.id.name); +// nameView.setText(lessItem.getName()); +// return convertView; +// } +// }); +// listView.setAdapter(adapter); +// listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { +// @Override +// public void onItemClick(AdapterView parent, View view, int position, long id) { +// Intent intent = new Intent(); +// intent.setClassName(MainActivity.this, "com.jayfeng.lesscode.app.activity." + list.get(position).getClassName()); +// startActivity(intent); +// } +// }); +// +// LogLess.$d("network: %s, type: %s", NetworkLess.$online(), NetworkLess.$type()); +// +// Person person = new Person("fengj"); +// SerializeLess.$se(new File(getCacheDir(), "person").getAbsolutePath(), person); +// +// Person person1 = SerializeLess.$de(new File(getCacheDir(), "person").getAbsolutePath()); +// ToastLess.$(this, person1.getName()); } @@ -80,11 +69,6 @@ private void initData() { lessItem.setClassName("ActivityActivity"); list.add(lessItem); - lessItem = new LessItem(); - lessItem.setName("AdapterLess的使用"); - lessItem.setClassName("AdapterActivity"); - list.add(lessItem); - lessItem = new LessItem(); lessItem.setName("AppLess的使用"); lessItem.setClassName("AppActivity"); diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java deleted file mode 100644 index 140d2e5..0000000 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/BaseAdapterActivity.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.jayfeng.lesscode.app.activity.adapterless; - -import android.app.Activity; -import android.os.Bundle; -import android.view.View; -import android.widget.BaseAdapter; -import android.widget.ListView; -import android.widget.TextView; - -import com.jayfeng.lesscode.app.R; -import com.jayfeng.lesscode.app.model.Person; -import com.jayfeng.lesscode.core.AdapterLess; -import com.jayfeng.lesscode.core.AdapterViewTypeRecyclerCallBack; -import com.jayfeng.lesscode.core.ViewLess; - -import java.util.ArrayList; -import java.util.List; - -public class BaseAdapterActivity extends Activity { - - List list; - ListView listView; - BaseAdapter adapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_adapter_base); - listView = ViewLess.$(this, R.id.listview); - initData(); - - // simple callback - /* - adapter = AdapterLess.$base(this, list, R.layout.activity_main_list_item, - new AdapterLess.CallBack() { - @Override - public View getView(int position, View convertView, AdapterLess.ViewHolder holder, Person person) { - TextView nameView = holder.$view(convertView, R.id.name); - nameView.setText(person.getName()); - return convertView; - } - }); - */ - // full callback - adapter = AdapterLess.$base(this, list, - new int[] { R.layout.activity_main_list_item, R.layout.adapter_list_item_header}, - new AdapterLess.FullCallBack() { - @Override - public View getView(int position, View convertView, AdapterLess.ViewHolder holder, Person person) { - TextView nameView = holder.$view(convertView, R.id.name); - nameView.setText(person.getName()); - return convertView; - } - - @Override - public int getItemViewType(int position) { - Person person = list.get(position); - if ("header".equals(person.getName())) { - return 1; - } else { - return 0; - } - } - - @Override - public boolean isEnabled(int position) { - Person person = list.get(position); - if ("header".equals(person.getName())) { - return false; - } - return true; - } - }); - - - listView.setAdapter(adapter); - } - - private void initData() { - list = new ArrayList<>(); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - } - -} diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/PagerAdapterActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/PagerAdapterActivity.java deleted file mode 100644 index ea3ca7a..0000000 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/PagerAdapterActivity.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.jayfeng.lesscode.app.activity.adapterless; - -import android.app.Activity; -import android.os.Bundle; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.view.View; -import android.widget.BaseAdapter; -import android.widget.ListView; -import android.widget.TextView; - -import com.jayfeng.lesscode.app.R; -import com.jayfeng.lesscode.app.model.Person; -import com.jayfeng.lesscode.core.AdapterLess; -import com.jayfeng.lesscode.core.ViewLess; - -import java.util.ArrayList; -import java.util.List; - -public class PagerAdapterActivity extends Activity { - - List list; - ViewPager viewPager; - PagerAdapter adapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_adapter_pager); - viewPager = ViewLess.$(this, R.id.viewpager); - initData(); - - adapter = AdapterLess.$pager(this, list, - R.layout.activity_main_list_item, - new AdapterLess.PageCallBack() { - @Override - public void instantiateItem(int position, View view, Person person) { - TextView nameView = ViewLess.$(view, R.id.name); - nameView.setText("page " + position + ":" + person.getName()); - } - }); - - viewPager.setAdapter(adapter); - } - - private void initData() { - list = new ArrayList<>(); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - } - -} diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java deleted file mode 100644 index e999789..0000000 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/adapterless/RecyclerAdapterActivity.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.jayfeng.lesscode.app.activity.adapterless; - -import android.app.Activity; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.graphics.drawable.GradientDrawable; -import android.os.Bundle; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.widget.TextView; - -import com.jayfeng.lesscode.app.R; -import com.jayfeng.lesscode.app.model.Person; -import com.jayfeng.lesscode.core.AdapterLess; -import com.jayfeng.lesscode.core.AdapterViewTypeRecyclerCallBack; -import com.jayfeng.lesscode.core.DisplayLess; -import com.jayfeng.lesscode.core.ViewLess; -import com.jayfeng.lesscode.core.other.DividerItemDecoration; - -import java.util.ArrayList; -import java.util.List; - -public class RecyclerAdapterActivity extends Activity { - - List list; - RecyclerView recyclerView; - RecyclerView.LayoutManager layoutManager; - RecyclerView.Adapter adapter; - DividerItemDecoration dividerItemDecoration; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_adapter_recycler); - recyclerView = ViewLess.$(this, R.id.recycler); - - layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); -// layoutManager = new GridLayoutManager(this, 4); - recyclerView.setLayoutManager(layoutManager); - dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.GRID_LIST, new ColorDrawable(Color.parseColor("#00000000"))); - dividerItemDecoration.setWidth(DisplayLess.$dp2px(4)); - dividerItemDecoration.setHeight(DisplayLess.$dp2px(4)); - - initData(); - - /* - adapter = AdapterLess.$recycler(this, list, - R.layout.activity_main_list_item, - new AdapterLess.RecyclerCallBack() { - - @Override - public void onBindViewHolder(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, Person person) { - TextView nameView = recyclerViewHolder.$view(R.id.name); - nameView.setText(person.getName()); - } - }); - */ - - adapter = AdapterLess.$recycler(this, list, - new int[] { R.layout.activity_main_list_item, R.layout.adapter_list_item_header}, - new AdapterViewTypeRecyclerCallBack() { - @Override - public int getItemViewType(int position) { - Person person = list.get(position); - if ("header".equals(person.getName())) { - return 1; - } else { - return 0; - } - } - - @Override - public void onViewType0(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, Person person) { - TextView nameView = recyclerViewHolder.$view(R.id.name); - nameView.setText(person.getName()); - } - - @Override - public void onViewType1(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, Person person) { - TextView nameView = recyclerViewHolder.$view(R.id.name); - nameView.setText(person.getName() + " >>"); - } - }); - - recyclerView.setAdapter(adapter); - - recyclerView.addItemDecoration(dividerItemDecoration); - } - - private void initData() { - list = new ArrayList<>(); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("bee")); - list.add(new Person("header")); - list.add(new Person("chras")); - list.add(new Person("nichid")); - list.add(new Person("header")); - list.add(new Person("gggggg")); - list.add(new Person("ggxxx")); - list.add(new Person("gewewewe")); - list.add(new Person("gtyyyy")); - list.add(new Person("guugyyyy")); - list.add(new Person("header")); - list.add(new Person("jay")); - list.add(new Person("zzzzzzzzzz")); - list.add(new Person("header")); - list.add(new Person("yyyyyyyyyyyyyy")); - list.add(new Person("etrtertret")); - list.add(new Person("zsssss")); - } - -} diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 83e59bd..c6efd03 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "1.2" // #CONFIG# // project version +version = "2.0" // #CONFIG# // project version android { compileSdkVersion 25 diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java deleted file mode 100644 index f6cfcbf..0000000 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterLess.java +++ /dev/null @@ -1,583 +0,0 @@ -package com.jayfeng.lesscode.core; - -import android.content.Context; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.PagerAdapter; -import android.support.v7.widget.RecyclerView; -import android.util.SparseArray; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; - -import java.util.List; -import java.util.Objects; - -/** - * 适配器简化相关的工具类 - * 常用于:ListView,ViewPager,RecyclerView - */ -public final class AdapterLess { - - /** - * 创建一个RecyclerView.Adapter - * 面向: RecyclerView - * 主要是: - * 1. 抽象出重复代码,默认实现一些常规代码 - * 2. 封装了RecyclerViewHolder - * 3. 自动传递Model给getView - * - * @param context - * @param list model的列表 - * @param layoutId 布局xml的id - * @param recyclerCallBack 包含nBindViewHolder方法的回调 - * @param r - * @return - */ - public static RecyclerView.Adapter $recycler(final Context context, - final List list, - final int layoutId, - final RecyclerCallBack recyclerCallBack) { - RecyclerView.Adapter result = new RecyclerView.Adapter() { - @Override - public RecyclerViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { - View view = LayoutInflater.from(context) - .inflate(layoutId, viewGroup, false); - RecyclerViewHolder recyclerViewHolder = new RecyclerViewHolder(view); - return recyclerViewHolder; - } - - @Override - public void onBindViewHolder(RecyclerViewHolder viewHolder, int position) { - T t = null; - if (position < list.size()) { - t = list.get(position); - } - recyclerCallBack.onBindViewHolder(position, viewHolder, t); - } - - @Override - public int getItemCount() { - if (list != null) { - return list.size(); - } - return 0; - } - }; - return result; - } - - /** - * 创建一个RecyclerView.Adapter - * 面向: RecyclerView - * 支持多布局,也多增加了两个回调方法,便于自定义: - * 1. getViewType - * - * @param context - * @param list model的列表 - * @param layoutIds 布局xml的id - * @param fullRecyclerCallBack 包含nBindViewHolder方法的回调 - * @param r - * @return - */ - public static RecyclerView.Adapter $recycler(final Context context, - final List list, - final int[] layoutIds, - final FullRecyclerCallBack fullRecyclerCallBack) { - RecyclerView.Adapter result = new RecyclerView.Adapter() { - @Override - public RecyclerViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { - View view = LayoutInflater.from(context) - .inflate(layoutIds[viewType], viewGroup, false); - RecyclerViewHolder recyclerViewHolder = new RecyclerViewHolder(view); - return recyclerViewHolder; - } - - @Override - public void onBindViewHolder(RecyclerViewHolder viewHolder, int position) { - T t = null; - if (position < list.size()) { - t = list.get(position); - } - fullRecyclerCallBack.onBindViewHolder(position, viewHolder, t); - } - - @Override - public int getItemCount() { - if (list != null) { - return list.size(); - } - return 0; - } - - @Override - public int getItemViewType(int position) { - return fullRecyclerCallBack.getItemViewType(position); - } - }; - return result; - } - - /** - * 创建BaseAdapter - * 面向: AbsListView - * 1. 抽象出重复代码,默认实现一些常规代码 - * 2. 封装了ViewHolder - * 3. 自动传递Model给getView - * - * @param context - * @param list model的列表 - * @param layoutId 布局xml的id - * @param callBack 包含getView方法的回调 - * @param - * @return - */ - public static BaseAdapter $base(final Context context, - final List list, - final int layoutId, - final CallBack callBack) { - - BaseAdapter result = new BaseAdapter() { - - @Override - public int getCount() { - if (list != null) { - return list.size(); - } - return 0; - } - - @Override - public T getItem(int position) { - return list.get(position); - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder holder; - if (null == convertView) { - holder = new ViewHolder(); - convertView = LayoutInflater.from(context).inflate(layoutId, null); - convertView.setTag(holder); - } else { - holder = (ViewHolder) convertView.getTag(); - } - T t = null; - if (position < list.size()) { - t = getItem(position); - } - return callBack.getView(position, convertView, holder, t); - } - - }; - return result; - } - - - /** - * 同上,也是创建了BaseAdapter - * 面向: AbsListView - * 支持多布局,也多增加了两个回调方法,便于自定义: - * 1. getViewType - * 2. isEnabled - * - * @param context - * @param list model列表 - * @param layoutIds 布局xml的id数组 - * @param fullCallBack 包含getView,getViewType,isEnabled方法的回调 - * @param - * @return - */ - public static BaseAdapter $base(final Context context, - final List list, - final int[] layoutIds, - final FullCallBack fullCallBack) { - - BaseAdapter result = new BaseAdapter() { - - @Override - public int getCount() { - if (list != null) { - return list.size(); - } - return 0; - } - - @Override - public T getItem(int position) { - return list.get(position); - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public int getItemViewType(int position) { - return fullCallBack.getItemViewType(position); - } - - @Override - public int getViewTypeCount() { - return layoutIds.length; - } - - @Override - public boolean isEnabled(int position) { - return fullCallBack.isEnabled(position); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder[] holders = new ViewHolder[layoutIds.length]; - int i = getItemViewType(position); - if (null == convertView) { - holders[i] = new ViewHolder(); - convertView = LayoutInflater.from(context).inflate(layoutIds[i], null); - convertView.setTag(holders[i]); - } else { - holders[i] = (ViewHolder) convertView.getTag(); - } - T t = null; - if (position < list.size()) { - t = getItem(position); - } - return fullCallBack.getView(position, convertView, holders[i], t); - } - - }; - return result; - } - - /** - * 创建PagerAdapter - * 面向: ViewPager - * 主要是: - * 1. 抽象出重复代码,默认实现一些常规代码 - * 2. 封装了instantiateItem - * 3. 自动传递Model给getView - * - * @param context - * @param list - * @param layoutId - * @param pageCallBack - * @param - * @return - */ - public static PagerAdapter $pager(final Context context, - final List list, - final int layoutId, - final PageCallBack pageCallBack) { - PagerAdapter result = new PagerAdapter() { - - @Override - public int getCount() { - return list.size(); - } - - @Override - public boolean isViewFromObject(View view, Object object) { - return view == object; - } - - @Override - public Object instantiateItem(ViewGroup container, int position) { - View view = LayoutInflater.from(context).inflate(layoutId, null); - container.addView(view); - pageCallBack.instantiateItem(position, view, list.get(position)); - return view; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object object) { - container.removeView((View) object); - } - }; - return result; - } - - /** - * 创建PagerAdapter - * 面向: ViewPager - * 主要是: - * 1. 增加destroyItem - * - * @param context - * @param list - * @param layoutId - * @param fullPageCallBack - * @param - * @return - */ - public static PagerAdapter $pager(final Context context, - final List list, - final int layoutId, - final FullPageCallBack fullPageCallBack) { - PagerAdapter result = new PagerAdapter() { - - @Override - public int getCount() { - return list.size(); - } - - @Override - public boolean isViewFromObject(View view, Object object) { - return view == object; - } - - @Override - public Object instantiateItem(ViewGroup container, int position) { - View view = LayoutInflater.from(context).inflate(layoutId, null); - container.addView(view); - fullPageCallBack.instantiateItem(position, view, list.get(position)); - return view; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object object) { - container.removeView((View) object); - fullPageCallBack.destroyItem(container, position, object, list.get(position)); - } - }; - return result; - } - - public static PagerAdapter $pagerWithDataChanged(final Context context, - final List list, - final int layoutId, - final FullPageCallBack fullPageCallBack) { - PagerAdapter result = new PagerAdapter() { - - private int mChildCount = 0; - - @Override - public int getCount() { - return list.size(); - } - - @Override - public boolean isViewFromObject(View view, Object object) { - return view == object; - } - - @Override - public Object instantiateItem(ViewGroup container, int position) { - View view = LayoutInflater.from(context).inflate(layoutId, null); - container.addView(view); - fullPageCallBack.instantiateItem(position, view, list.get(position)); - return view; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object object) { - container.removeView((View) object); - fullPageCallBack.destroyItem(container, position, object, list.get(position)); - } - - @Override - public int getItemPosition(Object object) { - if (mChildCount > 0) { - mChildCount--; - return POSITION_NONE; - } - return super.getItemPosition(object); - } - - @Override - public void notifyDataSetChanged() { - mChildCount = getCount(); - super.notifyDataSetChanged(); - } - }; - return result; - } - - /** - * 创建了FragmentPagerAdapter - * 面向: ViewPager - * 主要是: - * 1. 抽象出重复代码,默认实现getCount方法 - * - * @param fragmentManager - * @param count - * @param fragmentPagerCallBack - * @return - */ - public static FragmentPagerAdapter $pager(FragmentManager fragmentManager, - final int count, - final FragmentPagerCallBack fragmentPagerCallBack) { - FragmentPagerAdapter result = new FragmentPagerAdapter(fragmentManager) { - @Override - public Fragment getItem(int position) { - return fragmentPagerCallBack.getItem(position); - } - - @Override - public int getCount() { - return count; - } - }; - return result; - } - - /** - * 同上,创建了FragmentPagerAdapter - * 面向: ViewPager - * 通过getPageTitle回调方法支持fragment标题定义 - * 主要是: - * 1. 抽象出重复代码,默认实现getCount方法 - * - * @param fragmentManager - * @param count - * @param fullFragmentPagerCallBack - * @return - */ - public static FragmentPagerAdapter $pager(final FragmentManager fragmentManager, - final int count, - final FullFragmentPagerCallBack fullFragmentPagerCallBack) { - FragmentPagerAdapter result = new FragmentPagerAdapter(fragmentManager) { - @Override - public Fragment getItem(int position) { - return fullFragmentPagerCallBack.getItem(position); - } - - @Override - public int getCount() { - return count; - } - - @Override - public String getPageTitle(int position) { - return fullFragmentPagerCallBack.getPageTitle(position); - } - }; - return result; - } - - /** - * RecyclerCallBack - * - * @param - */ - public interface RecyclerCallBack { - void onBindViewHolder(int position, RecyclerViewHolder recyclerViewHolder, T t); - } - - /** - * RecyclerCallBack - * - * @param - */ - public interface FullRecyclerCallBack { - void onBindViewHolder(int position, RecyclerViewHolder recyclerViewHolder, T t); - - int getItemViewType(int position); - } - - /** - * 简化版本的$base的CallBack - * - * @param - */ - public interface CallBack { - View getView(int position, View convertView, ViewHolder holder, T t); - } - - /** - * 增强版本的$base的CallBack - * - * @param - */ - public interface FullCallBack { - View getView(int position, View convertView, ViewHolder holder, T t); - - int getItemViewType(int position); - - boolean isEnabled(int position); - } - - /** - * 简化版本的$pager的CallBack - * - * @param - */ - public interface PageCallBack { - void instantiateItem(int position, View view, T t); - } - - /** - * 简化版本的$pager的CallBack - * - * @param - */ - public interface FullPageCallBack { - void instantiateItem(int position, View view, T t); - - void destroyItem(ViewGroup container, int position, Object object, T t); - } - - /** - * 简化版本的$pager的CallBack(针对fragment) - */ - public interface FragmentPagerCallBack { - Fragment getItem(int position); - } - - /** - * 增强版本的$pager的CallBack(针对fragment) - */ - public interface FullFragmentPagerCallBack { - Fragment getItem(int position); - - String getPageTitle(int position); - } - - - /** - * ViewHolder类相当于一个享元模式的工厂类 - * 主要用了以下优化点: - * 1. 缓存了findViewById的view,如果已经创建,则直接返回,提高了性能 - * 2. 用SparseArray代替HashMap优化性能 - */ - public static class ViewHolder { - public SparseArray views = new SparseArray<>(); - - /** - * 从缓存里获取viewId对应的View - * - * @param convertView - * @param viewId - * @param - * @return - */ - public T $view(View convertView, int viewId) { - View v = views.get(viewId); - if (null == v) { - v = ViewLess.$(convertView, viewId); - views.put(viewId, v); - } - return (T) v; - } - } - - /** - * 单独封装了RecyclerView的ViewHolder - */ - public static class RecyclerViewHolder extends RecyclerView.ViewHolder { - public RecyclerViewHolder(View itemView) { - super(itemView); - } - - public T $view(int viewId) { - return ViewLess.$(itemView, viewId); - } - } -} diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java deleted file mode 100644 index a5d3938..0000000 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/AdapterViewTypeRecyclerCallBack.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.jayfeng.lesscode.core; - -/** - * 进一步分发多种类型的FullRecyclerCallBack - * @param - */ -public abstract class AdapterViewTypeRecyclerCallBack implements AdapterLess.FullRecyclerCallBack { - - @Override - public void onBindViewHolder(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - onViewCommon(position, recyclerViewHolder, t); - - if (getItemViewType(position) == 0) { - onViewType0(position, recyclerViewHolder, t); - } else if (getItemViewType(position) == 1) { - onViewType1(position, recyclerViewHolder, t); - } else if (getItemViewType(position) == 2) { - onViewType2(position, recyclerViewHolder, t); - } else if (getItemViewType(position) == 3) { - onViewType3(position, recyclerViewHolder, t); - } else if (getItemViewType(position) == 4) { - onViewType4(position, recyclerViewHolder, t); - } else if (getItemViewType(position) == 5) { - onViewType5(position, recyclerViewHolder, t); - } - } - - public void onViewCommon(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - - } - - public void onViewType0(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - - } - - public void onViewType1(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - - } - - public void onViewType2(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - - } - - public void onViewType3(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - - } - - public void onViewType4(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - - } - - public void onViewType5(int position, AdapterLess.RecyclerViewHolder recyclerViewHolder, T t) { - - } - - @Override - public abstract int getItemViewType(int position); -} From a8b7d0a929bbe71ef8cea992fa6961bea69e528e Mon Sep 17 00:00:00 2001 From: fengjian Date: Mon, 20 Feb 2017 11:12:26 +0800 Subject: [PATCH 30/39] fix(http): support http download redirect url --- .../src/main/java/com/jayfeng/lesscode/core/HttpLess.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java index c782d31..d573c8e 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java @@ -264,7 +264,12 @@ public void run() { String value = entry.getValue().toString(); conn.setRequestProperty(key, value); } - if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { + if (conn.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM + || conn.getResponseCode()== HttpURLConnection.HTTP_MOVED_TEMP) { + // 重定向地址下载 + String redirectDownloadUrl = conn.getHeaderField("location"); + return $download(redirectDownloadUrl, dest, append, header, callBack); + } else if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { is = conn.getInputStream(); remoteSize = conn.getContentLength(); String contentEndcoding = conn.getHeaderField("Content-Encoding"); From 61ab7ef6757ff03a70a582b5c5655f5a22ddd165 Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 22 Feb 2017 14:08:43 +0800 Subject: [PATCH 31/39] release v2.1 --- README-cn.md | 2 +- README.md | 2 +- .../lesscode/app/activity/MainActivity.java | 36 +++++++++++++++++++ lesscode-core/build.gradle | 6 ++-- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/README-cn.md b/README-cn.md index 861e90b..7d6ba70 100644 --- a/README-cn.md +++ b/README-cn.md @@ -13,7 +13,7 @@ ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:1.0') +compile('com.jayfeng:lesscode-core:2.1') ``` ## Features diff --git a/README.md b/README.md index c9f08da..245fbf2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ less code, more efficient for android, for the best android tools library! ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:1.0') +compile('com.jayfeng:lesscode-core:2.1') ``` ## Features diff --git a/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java b/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java index d14f98a..8e12900 100644 --- a/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java +++ b/app/src/main/java/com/jayfeng/lesscode/app/activity/MainActivity.java @@ -2,15 +2,20 @@ import android.app.Activity; import android.os.Bundle; +import android.os.Environment; import android.widget.BaseAdapter; import android.widget.ListView; import com.jayfeng.lesscode.app.R; import com.jayfeng.lesscode.app.model.LessItem; import com.jayfeng.lesscode.core.ActivityLess; +import com.jayfeng.lesscode.core.HttpLess; +import com.jayfeng.lesscode.core.LogLess; import com.jayfeng.lesscode.core.ToastLess; import com.jayfeng.lesscode.core.ViewLess; +import java.io.File; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; @@ -32,6 +37,37 @@ protected void onCreate(Bundle savedInstanceState) { initData(); + final File mDestDir = new File(Environment.getExternalStorageDirectory().getPath() + "/lesscode-download"); + if (mDestDir.exists() && !mDestDir.isDirectory()) { + mDestDir.delete(); + } + if (mDestDir.exists() || mDestDir.mkdirs()) { + + } + final File mDestFile = new File(mDestDir.getPath() + "/" + URLEncoder.encode("http://www.vpngo.com/download/vpngo-release-v1.3.1-46.apk")); + new Thread() { + @Override + public void run() { + try { + HttpLess.$download("http://www.vpngo.com/download/vpngo-release-v1.3.1-46.apk", mDestFile, false, new HttpLess.DownloadCallBack() { + @Override + public void onDownloading(int progress) { + + } + + @Override + public void onDownloaded() { + LogLess.$d("下载完成"); + } + }); + } catch (Exception e) { + e.printStackTrace(); + LogLess.$d(e.getMessage()); + } + } + }.start(); + + // adapter = AdapterLess.$base(this, list, R.layout.activity_main_list_item, // new AdapterLess.CallBack() { // @Override diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index c6efd03..95db3bb 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "2.0" // #CONFIG# // project version +version = "2.1" // #CONFIG# // project version android { compileSdkVersion 25 @@ -28,8 +28,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:25.1.0' - compile 'com.android.support:recyclerview-v7:25.1.0' + compile 'com.android.support:support-v4:25.1.1' + compile 'com.android.support:recyclerview-v7:25.1.1' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage From 145d0c8a54e3cc61ee389a1a719557e178746aff Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 22 Feb 2017 14:12:28 +0800 Subject: [PATCH 32/39] support http get redirect url --- .../src/main/java/com/jayfeng/lesscode/core/HttpLess.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java index d573c8e..d0936f3 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/HttpLess.java @@ -52,7 +52,12 @@ public final class HttpLess { String value = entry.getValue().toString(); conn.setRequestProperty(key, value); } - if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { + if (conn.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM + || conn.getResponseCode()== HttpURLConnection.HTTP_MOVED_TEMP) { + // 重定向地址下载 + String redirectDownloadUrl = conn.getHeaderField("location"); + return $get(redirectDownloadUrl, header); + } else if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { is = conn.getInputStream(); return FileLess.$read(is); } From d3224e9e3f374e2f4bbbaacd4be334f8c81e6944 Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 22 Mar 2017 15:14:17 +0800 Subject: [PATCH 33/39] release v2.2 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- lesscode-core/build.gradle | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 47804e3..746515f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0e65f82..1cfdd86 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Aug 24 08:51:21 CST 2016 +#Wed Mar 22 15:12:10 CST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 95db3bb..73a435c 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "2.1" // #CONFIG# // project version +version = "2.2" // #CONFIG# // project version android { compileSdkVersion 25 @@ -28,8 +28,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:25.1.1' - compile 'com.android.support:recyclerview-v7:25.1.1' + compile 'com.android.support:support-v4:25.3.0' + compile 'com.android.support:recyclerview-v7:25.3.0' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage From ace6435a91b3e0ed614d487179e02572d21440ae Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 18 Jun 2017 21:01:40 +0800 Subject: [PATCH 34/39] upgrade the build config --- build.gradle | 2 +- lesscode-core/build.gradle | 6 +++--- .../java/com/jayfeng/lesscode/core/ApplicationLess.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 746515f..1319315 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:2.3.2' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 73a435c..101e278 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -6,7 +6,7 @@ version = "2.2" // android { compileSdkVersion 25 - buildToolsVersion "25.0.2" + buildToolsVersion "25.0.3" // resourcePrefix "less_" // #CONFIG# // please remove this if you don't known it defaultConfig { minSdkVersion 9 @@ -28,8 +28,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:25.3.0' - compile 'com.android.support:recyclerview-v7:25.3.0' + compile 'com.android.support:support-v4:25.3.1' + compile 'com.android.support:recyclerview-v7:25.3.1' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java index 7c13710..4a521bb 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/ApplicationLess.java @@ -14,7 +14,7 @@ public final class ApplicationLess { * @param context * @return */ - private static boolean $init(Context context) { + public static boolean $init(Context context) { ActivityManager am = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)); List processInfos = am.getRunningAppProcesses(); String mainProcessName = context.getPackageName(); From 77fd89266570f68f5e02230b692ace0daf7453e7 Mon Sep 17 00:00:00 2001 From: fengjian Date: Sun, 18 Jun 2017 21:18:13 +0800 Subject: [PATCH 35/39] release v2.3 --- lesscode-core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 101e278..1f500dc 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "2.2" // #CONFIG# // project version +version = "2.3" // #CONFIG# // project version android { compileSdkVersion 25 From d4cd01884431c77a1384659bc69b64ed7ed9fe95 Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 28 Mar 2018 16:11:39 +0800 Subject: [PATCH 36/39] upgrade the as to 3.0 --- app/build.gradle | 8 ++++---- build.gradle | 4 +++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- lesscode-core/build.gradle | 12 ++++++------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ec60648..3384bef 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 27 + buildToolsVersion '27.0.3' defaultConfig { applicationId "com.jayfeng.lesscode.app" - minSdkVersion 9 - targetSdkVersion 25 + minSdkVersion 14 + targetSdkVersion 27 versionCode 1 versionName "1.0" } diff --git a/build.gradle b/build.gradle index 1319315..9987d03 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.2' + classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong @@ -16,5 +17,6 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1cfdd86..cb24766 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Mar 22 15:12:10 CST 2017 +#Wed Mar 28 16:07:08 CST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 1f500dc..6c087b7 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -5,12 +5,12 @@ apply plugin: 'com.jfrog.bintray' version = "2.3" // #CONFIG# // project version android { - compileSdkVersion 25 - buildToolsVersion "25.0.3" + compileSdkVersion 27 + buildToolsVersion "27.0.3" // resourcePrefix "less_" // #CONFIG# // please remove this if you don't known it defaultConfig { - minSdkVersion 9 - targetSdkVersion 25 + minSdkVersion 14 + targetSdkVersion 27 versionCode 1 versionName "1.0" } @@ -28,8 +28,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:25.3.1' - compile 'com.android.support:recyclerview-v7:25.3.1' + compile 'com.android.support:support-v4:27.1.0' + compile 'com.android.support:recyclerview-v7:27.1.0' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage From b07ccfc8fde18014b3b0bec43288139345348477 Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 28 Mar 2018 16:18:50 +0800 Subject: [PATCH 37/39] fix(storage): fix the sdcard StatFs no permission error --- .../jayfeng/lesscode/core/StorageLess.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/StorageLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/StorageLess.java index 8b046e9..d881dc2 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/StorageLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/StorageLess.java @@ -186,17 +186,29 @@ public static class ExtSdcard { } private static long total(File path) { - StatFs stat = new StatFs(path.getPath()); - long blockSize = stat.getBlockSize(); - long totalBlocks = stat.getBlockCount(); - return blockSize * totalBlocks; + try { + StatFs stat = new StatFs(path.getPath()); + long blockSize = stat.getBlockSize(); + long totalBlocks = stat.getBlockCount(); + return blockSize * totalBlocks; + } catch (Exception e) { + e.printStackTrace(); + } + + return 0; } private static long free(File path) { - StatFs stat = new StatFs(path.getPath()); - long blockSize = stat.getBlockSize(); - long freeBlocks = stat.getAvailableBlocks(); - return blockSize * freeBlocks; + try { + StatFs stat = new StatFs(path.getPath()); + long blockSize = stat.getBlockSize(); + long freeBlocks = stat.getAvailableBlocks(); + return blockSize * freeBlocks; + } catch (Exception e) { + e.printStackTrace(); + } + + return 0; } private static long used(File path) { From 7bb2431e34b30b738a4143158ce96342c9ec00de Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 28 Mar 2018 16:27:18 +0800 Subject: [PATCH 38/39] fix(network): add more network type --- .../main/java/com/jayfeng/lesscode/core/NetworkLess.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/NetworkLess.java b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/NetworkLess.java index 7024c49..c532f5a 100644 --- a/lesscode-core/src/main/java/com/jayfeng/lesscode/core/NetworkLess.java +++ b/lesscode-core/src/main/java/com/jayfeng/lesscode/core/NetworkLess.java @@ -60,6 +60,7 @@ public static enum NetworkType { if (type == ConnectivityManager.TYPE_MOBILE) { switch (subType) { case TelephonyManager.NETWORK_TYPE_GPRS: + case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: @@ -75,10 +76,15 @@ public static enum NetworkType { case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: + case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return NetworkType.MOBILE_MIDDLE;// 3G case TelephonyManager.NETWORK_TYPE_LTE: + case TelephonyManager.NETWORK_TYPE_IWLAN: + case 19: // TelephonyManager.NETWORK_TYPE_LTE_CA return NetworkType.MOBILE_FAST; // 4G + default: // we think the network will be more and more better + return NetworkType.MOBILE_FAST; } } From a4829f8643bcd6b22eae1bd625a4bc7597b052d7 Mon Sep 17 00:00:00 2001 From: fengjian Date: Wed, 28 Mar 2018 17:46:31 +0800 Subject: [PATCH 39/39] release v2.4.2 --- README-cn.md | 2 +- README.md | 2 +- lesscode-core/build.gradle | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README-cn.md b/README-cn.md index 7d6ba70..2b151f5 100644 --- a/README-cn.md +++ b/README-cn.md @@ -13,7 +13,7 @@ ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:2.1') +implementation 'com.jayfeng:lesscode-core:2.4.2' ``` ## Features diff --git a/README.md b/README.md index 245fbf2..c5f87c8 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ less code, more efficient for android, for the best android tools library! ## Gradle ```groovy -compile('com.jayfeng:lesscode-core:2.1') +implementation 'com.jayfeng:lesscode-core:2.4.2' ``` ## Features diff --git a/lesscode-core/build.gradle b/lesscode-core/build.gradle index 6c087b7..55d9bb4 100644 --- a/lesscode-core/build.gradle +++ b/lesscode-core/build.gradle @@ -2,11 +2,11 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "2.3" // #CONFIG# // project version +version = "2.4.2" // #CONFIG# // project version android { compileSdkVersion 27 - buildToolsVersion "27.0.3" + buildToolsVersion "27.0.2" // resourcePrefix "less_" // #CONFIG# // please remove this if you don't known it defaultConfig { minSdkVersion 14 @@ -28,8 +28,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:27.1.0' - compile 'com.android.support:recyclerview-v7:27.1.0' + compile 'com.android.support:support-v4:27.0.2' + compile 'com.android.support:recyclerview-v7:27.0.2' } def siteUrl = 'https://github.com/openproject/LessCode' // #CONFIG# // project homepage