Skip to content

Commit 9557ac0

Browse files
Merge pull request #13 from mutualmobile/development
Development
2 parents 9260c5e + 17ff93d commit 9557ac0

File tree

4 files changed

+35
-41
lines changed

4 files changed

+35
-41
lines changed

app/src/main/java/com/mutualmobile/cardstack/sample/MyCardStackAdapter.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@
1818
import com.tramsun.libs.prefcompat.Pref;
1919

2020
public class MyCardStackAdapter extends CardStackAdapter implements CompoundButton.OnCheckedChangeListener {
21-
private Logger log = new Logger(MyCardStackAdapter.class.getSimpleName());
22-
21+
private static int[] bgColorIds;
2322
private final LayoutInflater mInflater;
24-
private static int[] bgColorIds = {
25-
R.color.card1_bg,
26-
R.color.card2_bg,
27-
R.color.card3_bg,
28-
R.color.card4_bg,
29-
R.color.card5_bg,
30-
R.color.card6_bg,
31-
R.color.card7_bg
32-
};
3323
private final Context mContext;
24+
private Logger log = new Logger(MyCardStackAdapter.class.getSimpleName());
3425
private OnRestartRequest mCallback;
3526
private Runnable updateSettingsView;
3627

37-
@Override
38-
public int getCount() {
39-
return bgColorIds.length;
40-
}
41-
4228
public MyCardStackAdapter(MainActivity activity) {
4329
super(activity);
4430
mContext = activity;
4531
mInflater = LayoutInflater.from(activity);
4632
mCallback = activity;
33+
bgColorIds = new int[]{
34+
R.color.card1_bg,
35+
R.color.card2_bg,
36+
R.color.card3_bg,
37+
R.color.card4_bg,
38+
R.color.card5_bg,
39+
R.color.card6_bg,
40+
R.color.card7_bg,
41+
};
42+
}
43+
44+
@Override
45+
public int getCount() {
46+
return bgColorIds.length;
4747
}
4848

4949
@Override

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.0.0-beta4'
8+
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
99
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
1010
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
1111

cardstack/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'com.jfrog.bintray'
55
def siteUrl = 'https://github.com/mutualmobile/CardStackUI'
66
def gitUrl = 'https://github.com/mutualmobile/CardStackUI.git'
77
group = "com.mutualmobile.android"
8-
version = "0.2"
8+
version = "0.3"
99

1010
android {
1111
compileSdkVersion 23
@@ -14,7 +14,7 @@ android {
1414
defaultConfig {
1515
minSdkVersion 14
1616
targetSdkVersion 23
17-
versionCode 2
17+
versionCode 3
1818
versionName version
1919
}
2020
buildTypes {
@@ -96,4 +96,4 @@ bintray {
9696
publicDownloadNumbers = true
9797
}
9898
}
99-
apply plugin: 'maven'*/
99+
apply plugin: 'maven'*/

cardstack/src/main/java/com/mutualmobile/cardstack/CardStackAdapter.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,17 @@ public abstract class CardStackAdapter implements View.OnTouchListener, View.OnC
3434
public static final int DECELERATION_FACTOR = 2;
3535

3636
public static final int INVALID_CARD_POSITION = -1;
37-
37+
private final int mScreenHeight;
38+
private final int dp30;
3839
// Settings for the adapter from layout
3940
private float mCardGapBottom;
4041
private float mCardGap;
4142
private int mParallaxScale;
4243
private boolean mParallaxEnabled;
4344
private boolean mShowInitAnimation;
44-
45-
private final int mScreenHeight;
4645
private int fullCardHeight;
47-
4846
private View[] mCardViews;
49-
5047
private float dp8;
51-
private final int dp30;
52-
5348
private CardStackLayout mParent;
5449

5550
private boolean mScreenTouchable = false;
@@ -61,6 +56,16 @@ public abstract class CardStackAdapter implements View.OnTouchListener, View.OnC
6156
private int mParentPaddingTop = 0;
6257
private int mCardPaddingInternal = 0;
6358

59+
public CardStackAdapter(Context context) {
60+
Resources resources = context.getResources();
61+
62+
DisplayMetrics dm = Resources.getSystem().getDisplayMetrics();
63+
mScreenHeight = dm.heightPixels;
64+
dp30 = (int) resources.getDimension(R.dimen.dp30);
65+
scaleFactorForElasticEffect = (int) resources.getDimension(R.dimen.dp8);
66+
dp8 = (int) resources.getDimension(R.dimen.dp8);
67+
}
68+
6469
/**
6570
* Defines and initializes the view to be shown in the {@link CardStackLayout}
6671
* Provides two parameters to the sub-class namely -
@@ -79,10 +84,6 @@ public abstract class CardStackAdapter implements View.OnTouchListener, View.OnC
7984
*/
8085
public abstract int getCount();
8186

82-
private void setScreenTouchable(boolean screenTouchable) {
83-
this.mScreenTouchable = screenTouchable;
84-
}
85-
8687
/**
8788
* Returns true if no animation is in progress currently. Can be used to disable any events
8889
* if they are not allowed during an animation. Returns false if an animation is in progress.
@@ -93,16 +94,8 @@ public boolean isScreenTouchable() {
9394
return mScreenTouchable;
9495
}
9596

96-
public CardStackAdapter(Context context) {
97-
Resources resources = context.getResources();
98-
99-
DisplayMetrics dm = Resources.getSystem().getDisplayMetrics();
100-
mScreenHeight = dm.heightPixels;
101-
dp30 = (int) resources.getDimension(R.dimen.dp30);
102-
scaleFactorForElasticEffect = (int) resources.getDimension(R.dimen.dp8);
103-
dp8 = (int) resources.getDimension(R.dimen.dp8);
104-
105-
mCardViews = new View[getCount()];
97+
private void setScreenTouchable(boolean screenTouchable) {
98+
this.mScreenTouchable = screenTouchable;
10699
}
107100

108101
void addView(final int position) {
@@ -266,6 +259,7 @@ private void moveCards(int positionOfCardToMove, float diff) {
266259
*/
267260
void setAdapterParams(CardStackLayout cardStackLayout) {
268261
mParent = cardStackLayout;
262+
mCardViews = new View[getCount()];
269263
mCardGapBottom = cardStackLayout.getCardGapBottom();
270264
mCardGap = cardStackLayout.getCardGap();
271265
mParallaxScale = cardStackLayout.getParallaxScale();

0 commit comments

Comments
 (0)