From 553c80babfbaf42c32e4607371abae4df8f5de7d Mon Sep 17 00:00:00 2001 From: lsxiao Date: Wed, 24 May 2017 13:25:10 +0800 Subject: [PATCH] try to fix --- app/build.gradle | 5 +-- library/build.gradle | 1 + .../main/java/com/lsxiao/capa/CapaLayout.java | 31 ++++++++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 982595f..762332a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,13 +18,10 @@ android { } } dependencies { - - compile project(":library") compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:design:25.3.1' - compile project(":library") -// compile 'com.github.lsxiao:capa:87055ead38' + compile 'com.github.lsxiao:capa:68bd4e6545' compile parent.ext.libs.cardView } diff --git a/library/build.gradle b/library/build.gradle index 43130b1..dc01d8c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -15,4 +15,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) def libs = parent.ext.libs + compile libs.supportAnnotation } diff --git a/library/src/main/java/com/lsxiao/capa/CapaLayout.java b/library/src/main/java/com/lsxiao/capa/CapaLayout.java index 3714ad1..dcd8175 100644 --- a/library/src/main/java/com/lsxiao/capa/CapaLayout.java +++ b/library/src/main/java/com/lsxiao/capa/CapaLayout.java @@ -2,11 +2,18 @@ import android.content.Context; import android.content.res.TypedArray; +import android.support.annotation.AnimRes; +import android.support.annotation.IntDef; +import android.support.annotation.LayoutRes; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.ViewAnimator; +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + /** * write with Capa * author:lsxiao @@ -16,11 +23,11 @@ */ public class CapaLayout extends ViewAnimator { -// @Retention(SOURCE) -// @IntDef({LOAD, EMPTY, ERROR, CONTENT}) -// @interface StateMode { -// -// } + @Retention(SOURCE) + @IntDef({LOAD, EMPTY, ERROR, CONTENT}) + @interface StateMode { + + } public static final int LOAD = 0; public static final int EMPTY = 1; @@ -30,11 +37,11 @@ public class CapaLayout extends ViewAnimator { private int mState = CONTENT; - // @LayoutRes + @LayoutRes private int mLoadLayoutId; - // @LayoutRes + @LayoutRes private int mEmptyLayoutId; - // @LayoutRes + @LayoutRes private int mErrorLayoutId; @@ -153,11 +160,11 @@ public void animNone() { setOutAnimation(null); } - public void animIn(int in) { + public void animIn(@AnimRes int in) { setInAnimation(getContext(), in); } - public void animOut(int out) { + public void animOut(@AnimRes int out) { setOutAnimation(getContext(), out); } @@ -165,7 +172,7 @@ public int getState() { return mState; } - public boolean isState(int state) { + public boolean isState(@StateMode int state) { return mState == state; } @@ -181,7 +188,7 @@ public void toContent() { to(CONTENT); } - private int getViewIndexByState(int state) { + private int getViewIndexByState(@StateMode int state) { switch (state) { case LOAD: return indexOfChild(mLoadView);