Skip to content

Commit

Permalink
Merge pull request #92 from AAkira/update/v1.6.0
Browse files Browse the repository at this point in the history
v1.6.0
  • Loading branch information
AAkira authored Sep 12, 2016
2 parents abadfc5 + 7b4ae8c commit 0c06b54
Show file tree
Hide file tree
Showing 25 changed files with 840 additions and 102 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,29 @@ add `xmlns:app="http://schemas.android.com/apk/res-auto"`

You should use the ExpandableLinearLayout if child views may change a size.
For example, it gets and sets values from a server.
And you should use this in recycler view.

#### Code

```java

// resize expandable layout

ExpandableLinearLayout expandableLayout
= (ExpandableLinearLayout) findViewById(R.id.expandableLayout);

child.setText("Sets text from a server");
expandableLayout.initLayout(true); // Recalculate size of children
```
expandableLayout.initLayout(); // Recalculate size of children

The `initLayout()` is deprecated in v1.5.0.
The argument of `isMaintain` flag doesn't work.
I'll fix it in [v1.5.1](https://github.com/AAkira/ExpandableLayout/issues/66)
// recycler view
// you must set a ViewHolder#setIsRecyclable(false) and ExpandableLinearLayout#setInRecyclerView(true)

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
holder.setIsRecyclable(false);
holder.expandableLinearLayout.setInRecyclerView(true);
}
```

### ExpandableWeightLayout

Expand Down Expand Up @@ -259,7 +268,7 @@ buildscript {
}
dependencies {
compile 'com.github.aakira:expandable-layout:1.5.1@aar'
compile 'com.github.aakira:expandable-layout:1.6.0@aar'
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ COMPILE_SDK_VERSION=23
BUILD_TOOLS_VERSION=22.0.1
MIN_SDK_VERSION=11
TARGET_SDK_VERSION=23
VERSION_CODE=10
VERSION_NAME=1.5.1
VERSION_CODE=11
VERSION_NAME=1.6.0
SUPPORT_TEST_VERSION=0.4.1
HAMCREST_VERSION=1.3
ESPRESSO_VERSION=2.2.1
Expand Down
8 changes: 8 additions & 0 deletions library-ui-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ dependencies {
compile project(':library')

compile "com.android.support:appcompat-v7:$SUPPORT_APP_COMPAT_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_APP_COMPAT_VERSION"
compile "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
compile 'io.reactivex:rxjava:1.1.6'
compile 'io.reactivex:rxandroid:1.2.1'
androidTestCompile "com.android.support:support-annotations:$SUPPORT_APP_COMPAT_VERSION"
androidTestCompile "com.android.support.test:runner:$SUPPORT_TEST_VERSION"
androidTestCompile "com.android.support.test:rules:$SUPPORT_TEST_VERSION"
androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
androidTestCompile("com.android.support.test.espresso:espresso-contrib:$ESPRESSO_VERSION") {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ExpandableLinearLayoutActivityTest : ActivityInstrumentationTestCase2<Expa
}

@Test
fun testExpandableRelativeLayout() {
fun testExpandableLinearLayoutActivity() {
val activity = activity
val instrumentation = instrumentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExpandableLinearLayoutActivityTest2 : ActivityInstrumentationTestCase2<Exp
}

@Test
fun testExpandableRelativeLayout() {
fun testExpandableLinearLayoutActivity2() {
val activity = activity
val instrumentation = instrumentation

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.github.aakira.expandablelayout.uitest

import android.app.Activity
import android.support.test.InstrumentationRegistry
import android.support.test.espresso.Espresso
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.runner.AndroidJUnit4
import android.test.ActivityInstrumentationTestCase2
import android.widget.TextView
import com.github.aakira.expandablelayout.ExpandableLinearLayout
import com.github.aakira.expandablelayout.uitest.utils.ElapsedIdLingResource
import com.github.aakira.expandablelayout.uitest.utils.equalHeight
import com.github.aakira.expandablelayout.uitest.utils.orMoreHeight
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.core.IsNull.notNullValue
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.hamcrest.CoreMatchers.`is` as _is

/**
* test for [com.github.aakira.expandablelayout.ExpandableLinearLayout#initlayout]
*
* The default value is {@link android.view.animation.AccelerateDecelerateInterpolator}
*
*/
@RunWith(AndroidJUnit4::class)
class ExpandableLinearLayoutActivityTest3 : ActivityInstrumentationTestCase2<ExpandableLinearLayoutActivity3>
(ExpandableLinearLayoutActivity3::class.java) {

companion object {
val DURATION = 300L
}

@Before
@Throws(Exception::class)
public override fun setUp() {
super.setUp()
injectInstrumentation(InstrumentationRegistry.getInstrumentation())
}

@After
@Throws(Exception::class)
public override fun tearDown() {
super.tearDown()
}

@Test
fun testExpandableLinearLayoutActivity3() {
val activity = activity
val instrumentation = instrumentation

// check activity
assertThat<Activity>(activity, notNullValue())
assertThat(instrumentation, notNullValue())

val expandableLayout = activity.findViewById(R.id.expandableLayout) as ExpandableLinearLayout
val child1 = activity.findViewById(R.id.child1) as TextView
val child2 = activity.findViewById(R.id.child2) as TextView
val marginSmall = getActivity().resources.getDimensionPixelSize(R.dimen.margin_small)

// default close
onView(withId(R.id.expandableLayout)).check(matches(equalHeight(0)))

// open toggle
instrumentation.runOnMainSync { expandableLayout.toggle() }
var idlingResource = ElapsedIdLingResource(DURATION)
Espresso.registerIdlingResources(idlingResource)
onView(withId(R.id.expandableLayout)).check(matches(orMoreHeight(1)))
Espresso.unregisterIdlingResources(idlingResource)

// move to first layout
instrumentation.runOnMainSync { expandableLayout.moveChild(0) }
idlingResource = ElapsedIdLingResource(DURATION)
Espresso.registerIdlingResources(idlingResource)
onView(withId(R.id.expandableLayout)).check(matches(equalHeight(
child1,
margin = marginSmall
)))
Espresso.unregisterIdlingResources(idlingResource)

// change child size
instrumentation.runOnMainSync {
child1.text = "++++++++++++++++++++check_init_layout++++++++++++++++++++++++++++" +
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
expandableLayout.initLayout()
}
idlingResource = ElapsedIdLingResource(DURATION)
Espresso.registerIdlingResources(idlingResource)
onView(withId(R.id.expandableLayout)).check(matches(equalHeight(0)))
Espresso.unregisterIdlingResources(idlingResource)

// check init layout
instrumentation.runOnMainSync { expandableLayout.expand() }
idlingResource = ElapsedIdLingResource(DURATION)
Espresso.registerIdlingResources(idlingResource)
onView(withId(R.id.expandableLayout)).check(matches(equalHeight(
child1,
child2,
margin = marginSmall
)))
Espresso.unregisterIdlingResources(idlingResource)
}
}
Loading

0 comments on commit 0c06b54

Please sign in to comment.