Skip to content

Commit

Permalink
Fix for #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar Acharya committed Apr 4, 2016
1 parent 23c258f commit d85d7b5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 3 additions & 3 deletions cardstack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,7 +14,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 2
versionCode 3
versionName version
}
buildTypes {
Expand Down Expand Up @@ -96,4 +96,4 @@ bintray {
publicDownloadNumbers = true
}
}
apply plugin: 'maven'*/
apply plugin: 'maven'*/
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 -
Expand All @@ -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.
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d85d7b5

Please sign in to comment.