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

Dpad support #77

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
}
}

allprojects {
repositories {
mavenCentral()
}
}

ext {
compileSdkVersion = 23
buildToolsVersion = "23.0.0"

compatibility_JavaVersion = JavaVersion.VERSION_1_7
}
15 changes: 3 additions & 12 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}

apply plugin: 'android-library'
apply plugin: 'com.android.library'

android {
compileSdkVersion 19
buildToolsVersion = '19.0.1'
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
2 changes: 1 addition & 1 deletion library/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# project structure.

# Project target.
target=android-8
target=android-19
android.library=true
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.tjerkw.slideexpandable.library;

import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
Expand Down Expand Up @@ -37,6 +39,23 @@ public void setItemActionListener(OnActionClickListener listener, int ... button
this.buttonIds = buttonIds;
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
SlideExpandableListAdapter adapter = (SlideExpandableListAdapter)getAdapter();
View item = getSelectedView();
if(item != null) {
// found by monkey
adapter.getExpandToggleButton(item).performClick();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
item.setActivated(true);
}
}
return true;
}
return super.onKeyDown(keyCode, event);
}

/**
* Interface for callback to be invoked whenever an action is clicked in
* the expandle area of the list item.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tjerkw.slideexpandable.library;

import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
Expand Down Expand Up @@ -45,15 +44,14 @@ public ExpandCollapseAnimation(View view, int type) {

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {

super.applyTransformation(interpolatedTime, t);
if (interpolatedTime < 1.0f) {
if(mType == EXPAND) {
mLayoutParams.bottomMargin = -mEndHeight + (int) (mEndHeight * interpolatedTime);
} else {
mLayoutParams.bottomMargin = - (int) (mEndHeight * interpolatedTime);
}
Log.d("ExpandCollapseAnimation", "anim height " + mLayoutParams.bottomMargin);
//Log.d("ExpandCollapseAnimation", "anim height " + mLayoutParams.bottomMargin);
mAnimatedView.requestLayout();
} else {
if(mType == EXPAND) {
Expand Down
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
}
}

apply plugin: 'android-library'
apply plugin: 'com.android.library'

dependencies {
compile project(':library')
}

android {
compileSdkVersion 19
buildToolsVersion = '19.0.1'
compileSdkVersion 22
buildToolsVersion = '22.0.1'
}