Skip to content

Commit

Permalink
try to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lsxiao committed May 24, 2017
1 parent 68bd4e6 commit 553c80b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
5 changes: 1 addition & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
def libs = parent.ext.libs
compile libs.supportAnnotation
}
31 changes: 19 additions & 12 deletions library/src/main/java/com/lsxiao/capa/CapaLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;


Expand Down Expand Up @@ -153,19 +160,19 @@ 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);
}

public int getState() {
return mState;
}

public boolean isState(int state) {
public boolean isState(@StateMode int state) {
return mState == state;
}

Expand All @@ -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);
Expand Down

0 comments on commit 553c80b

Please sign in to comment.