diff --git a/app/src/main/java/com/mutualmobile/cardstack/sample/MyCardStackAdapter.java b/app/src/main/java/com/mutualmobile/cardstack/sample/MyCardStackAdapter.java index 050a4fd..b5d60b9 100644 --- a/app/src/main/java/com/mutualmobile/cardstack/sample/MyCardStackAdapter.java +++ b/app/src/main/java/com/mutualmobile/cardstack/sample/MyCardStackAdapter.java @@ -18,32 +18,32 @@ import com.tramsun.libs.prefcompat.Pref; public class MyCardStackAdapter extends CardStackAdapter implements CompoundButton.OnCheckedChangeListener { - private Logger log = new Logger(MyCardStackAdapter.class.getSimpleName()); - + private static int[] bgColorIds; private final LayoutInflater mInflater; - private static int[] bgColorIds = { - R.color.card1_bg, - R.color.card2_bg, - R.color.card3_bg, - R.color.card4_bg, - R.color.card5_bg, - R.color.card6_bg, - R.color.card7_bg - }; private final Context mContext; + private Logger log = new Logger(MyCardStackAdapter.class.getSimpleName()); private OnRestartRequest mCallback; private Runnable updateSettingsView; - @Override - public int getCount() { - return bgColorIds.length; - } - public MyCardStackAdapter(MainActivity activity) { super(activity); mContext = activity; mInflater = LayoutInflater.from(activity); mCallback = activity; + bgColorIds = new int[]{ + R.color.card1_bg, + R.color.card2_bg, + R.color.card3_bg, + R.color.card4_bg, + R.color.card5_bg, + R.color.card6_bg, + R.color.card7_bg, + }; + } + + @Override + public int getCount() { + return bgColorIds.length; } @Override diff --git a/build.gradle b/build.gradle index 733ff23..80aff2c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.0.0-beta4' + classpath 'com.android.tools.build:gradle:2.0.0-beta6' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' diff --git a/cardstack/build.gradle b/cardstack/build.gradle index 8987e8f..b88c2e4 100644 --- a/cardstack/build.gradle +++ b/cardstack/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'com.jfrog.bintray' def siteUrl = 'https://github.com/mutualmobile/CardStackUI' def gitUrl = 'https://github.com/mutualmobile/CardStackUI.git' group = "com.mutualmobile.android" -version = "0.2" +version = "0.3" android { compileSdkVersion 23 @@ -14,7 +14,7 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 23 - versionCode 2 + versionCode 3 versionName version } buildTypes { @@ -96,4 +96,4 @@ bintray { publicDownloadNumbers = true } } -apply plugin: 'maven'*/ +apply plugin: 'maven'*/ \ No newline at end of file diff --git a/cardstack/src/main/java/com/mutualmobile/cardstack/CardStackAdapter.java b/cardstack/src/main/java/com/mutualmobile/cardstack/CardStackAdapter.java index c2e0120..9cc581a 100644 --- a/cardstack/src/main/java/com/mutualmobile/cardstack/CardStackAdapter.java +++ b/cardstack/src/main/java/com/mutualmobile/cardstack/CardStackAdapter.java @@ -34,22 +34,17 @@ public abstract class CardStackAdapter implements View.OnTouchListener, View.OnC public static final int DECELERATION_FACTOR = 2; public static final int INVALID_CARD_POSITION = -1; - + private final int mScreenHeight; + private final int dp30; // Settings for the adapter from layout private float mCardGapBottom; private float mCardGap; private int mParallaxScale; private boolean mParallaxEnabled; private boolean mShowInitAnimation; - - private final int mScreenHeight; private int fullCardHeight; - private View[] mCardViews; - private float dp8; - private final int dp30; - private CardStackLayout mParent; private boolean mScreenTouchable = false; @@ -61,6 +56,16 @@ public abstract class CardStackAdapter implements View.OnTouchListener, View.OnC private int mParentPaddingTop = 0; private int mCardPaddingInternal = 0; + public CardStackAdapter(Context context) { + Resources resources = context.getResources(); + + DisplayMetrics dm = Resources.getSystem().getDisplayMetrics(); + mScreenHeight = dm.heightPixels; + dp30 = (int) resources.getDimension(R.dimen.dp30); + scaleFactorForElasticEffect = (int) resources.getDimension(R.dimen.dp8); + dp8 = (int) resources.getDimension(R.dimen.dp8); + } + /** * Defines and initializes the view to be shown in the {@link CardStackLayout} * Provides two parameters to the sub-class namely - @@ -79,10 +84,6 @@ public abstract class CardStackAdapter implements View.OnTouchListener, View.OnC */ public abstract int getCount(); - private void setScreenTouchable(boolean screenTouchable) { - this.mScreenTouchable = screenTouchable; - } - /** * Returns true if no animation is in progress currently. Can be used to disable any events * if they are not allowed during an animation. Returns false if an animation is in progress. @@ -93,16 +94,8 @@ public boolean isScreenTouchable() { return mScreenTouchable; } - public CardStackAdapter(Context context) { - Resources resources = context.getResources(); - - DisplayMetrics dm = Resources.getSystem().getDisplayMetrics(); - mScreenHeight = dm.heightPixels; - dp30 = (int) resources.getDimension(R.dimen.dp30); - scaleFactorForElasticEffect = (int) resources.getDimension(R.dimen.dp8); - dp8 = (int) resources.getDimension(R.dimen.dp8); - - mCardViews = new View[getCount()]; + private void setScreenTouchable(boolean screenTouchable) { + this.mScreenTouchable = screenTouchable; } void addView(final int position) { @@ -266,6 +259,7 @@ private void moveCards(int positionOfCardToMove, float diff) { */ void setAdapterParams(CardStackLayout cardStackLayout) { mParent = cardStackLayout; + mCardViews = new View[getCount()]; mCardGapBottom = cardStackLayout.getCardGapBottom(); mCardGap = cardStackLayout.getCardGap(); mParallaxScale = cardStackLayout.getParallaxScale();