Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build tool version #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.android.tools.build:gradle:1.1.0'
}
}

apply plugin: 'android-library'

android {
compileSdkVersion 19
buildToolsVersion = '19.0.1'
buildToolsVersion = '19.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public abstract class AbstractSlideExpandableListAdapter extends WrapperListAdap
*/
private ViewGroup parent;

private boolean accordionMode;

public AbstractSlideExpandableListAdapter(ListAdapter wrapped) {
super(wrapped);
}
Expand Down Expand Up @@ -199,13 +201,25 @@ public boolean isAnyItemExpanded() {
return (lastOpenPosition != -1) ? true : false;
}

public void setAccordionMode(final boolean accordionMode) {
this.accordionMode = accordionMode;
}

public boolean isAccordionMode() {
return accordionMode;
}

public void enableFor(View parent, int position) {
View more = getExpandToggleButton(parent);
View itemToolbar = getExpandableView(parent);
itemToolbar.measure(parent.getWidth(), parent.getHeight());

enableFor(more, itemToolbar, position);
itemToolbar.requestLayout();

if(accordionMode && position == 0) {
more.performClick();
}
}


Expand Down Expand Up @@ -254,39 +268,47 @@ public void onAnimationRepeat(Animation animation) {

target.setAnimation(null);

int type = target.getVisibility() == View.VISIBLE
? ExpandCollapseAnimation.COLLAPSE
: ExpandCollapseAnimation.EXPAND;

// remember the state
if (type == ExpandCollapseAnimation.EXPAND) {
openItems.set(position, true);
} else {
openItems.set(position, false);
}
// check if we need to collapse a different view
if (type == ExpandCollapseAnimation.EXPAND) {
if (lastOpenPosition != -1 && lastOpenPosition != position) {
if (lastOpen != null) {
animateView(lastOpen, ExpandCollapseAnimation.COLLAPSE);
notifiyExpandCollapseListener(
ExpandCollapseAnimation.COLLAPSE,
lastOpen, lastOpenPosition);
}
openItems.set(lastOpenPosition, false);
}
lastOpen = target;
lastOpenPosition = position;
} else if (lastOpenPosition == position) {
lastOpenPosition = -1;
if((accordionMode && target.getVisibility() != View.VISIBLE) || !accordionMode) {
toggleView(
target.getVisibility() == View.VISIBLE
? ExpandCollapseAnimation.COLLAPSE
: ExpandCollapseAnimation.EXPAND,
position,
target
);
}
animateView(target, type);
notifiyExpandCollapseListener(type, target, position);
}
}
});
}

private void toggleView(int type, int position, View target) {
// remember the state
if (type == ExpandCollapseAnimation.EXPAND) {
openItems.set(position, true);
} else {
openItems.set(position, false);
}
// check if we need to collapse a different view
if (type == ExpandCollapseAnimation.EXPAND) {
if (lastOpenPosition != -1 && lastOpenPosition != position) {
if (lastOpen != null) {
animateView(lastOpen, ExpandCollapseAnimation.COLLAPSE);
notifiyExpandCollapseListener(
ExpandCollapseAnimation.COLLAPSE,
lastOpen, lastOpenPosition);
}
openItems.set(lastOpenPosition, false);
}
lastOpen = target;
lastOpenPosition = position;
} else if (lastOpenPosition == position) {
lastOpenPosition = -1;
}
animateView(target, type);
notifiyExpandCollapseListener(type, target, position);
}

private void updateExpandable(View target, int position) {

final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)target.getLayoutParams();
Expand Down