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

Added test case with childs next to each other #36

Merged
merged 1 commit into from
Dec 17, 2015
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextMenu;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.RelativeLayout;
Expand Down Expand Up @@ -96,6 +97,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int sumSize = 0;
View view;
LayoutParams params;
// At this point you just iterate through all children and don't take into account, their position to each other
for (int i = 0; i < getChildCount(); i++) {
view = getChildAt(i);
params = (LayoutParams) view.getLayoutParams();
Expand All @@ -111,7 +113,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
childPositionList.add(sumSize + childSize + childMargin);
}
layoutSize = childPositionList.get(childPositionList.size() - 1);
Log.v("TAG", "layoutsize: " + layoutSize + ", measuredHeight: " + getMeasuredHeight());
Log.d("TAG", "layoutsize: " + layoutSize + ", measuredHeight: " + super.getMeasuredHeight());

if (0 < layoutSize) {
isCalculatedSize = true;
Expand Down Expand Up @@ -146,7 +148,17 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
protected Parcelable onSaveInstanceState() {
final Parcelable parcelable = super.onSaveInstanceState();
final ExpandableSavedState ss = new ExpandableSavedState(parcelable);
/**At this point is the bug mentioned by #34
You should probably add this line (I did not test this !)
Reason is that the System will use your CREATOR field to retain the Layout
In your Constructor you try to read the weight, since you did not set it, Appllication will crash.

=== This is just my understanding, I might still be wrong here === **/
ss.setWeight((float) 0.0);


ss.setSize(getCurrentPosition());

return ss;
}

Expand Down Expand Up @@ -372,7 +384,6 @@ public int getCurrentPosition() {
public void setClosePositionIndex(final int childIndex) {
this.closePosition = getChildPosition(childIndex);
}

private boolean isVertical() {
return orientation == VERTICAL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setTitle(TestActivity.class.getSimpleName());

mExpandButton = (Button) findViewById(R.id.expandButton);
mVariableButton = (Button) findViewById(R.id.variableButton);
mLinearLayout = (LinearLayout) findViewById(R.id.linearLayout);
// mVariableButton = (Button) findViewById(R.id.variableButton);
mExpandLayout = (ExpandableRelativeLayout) findViewById(R.id.expandableLayout);
mText = (TextView) findViewById(R.id.text);
mExpandButton.setOnClickListener(this);
mVariableButton.setOnClickListener(this);
// mVariableButton.setOnClickListener(this);
}

@Override
Expand All @@ -45,22 +44,22 @@ public void onClick(final View v) {
case R.id.expandButton:
mExpandLayout.toggle();
break;
case R.id.variableButton:
mLinearLayout.getLayoutParams().height = 1000;
// mText.setText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
mExpandLayout.initLayout(true);
break;
// case R.id.variableButton:
//// mLinearLayout.getLayoutParams().height = 1000;
//// mText.setText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
//// "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
// mExpandLayout.initLayout(true);
// break;
}
}
}
52 changes: 21 additions & 31 deletions sample/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
@@ -1,74 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">

<Button
android:id="@+id/expandButton"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/white"
android:text="button" />
android:text="button toggle" />

<Button
android:id="@+id/variableButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/white"
android:text="variabl" />

<com.github.aakira.expandablelayout.ExpandableRelativeLayout
android:id="@+id/expandableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/expandButton"
app:ael_duration="350"
app:ael_expanded="false"
app:ael_interpolator="fastOutSlowIn"
app:ael_orientation="vertical">

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/material_brown_500"
android:orientation="vertical">

<!-- Since its a RelativeLayout i assumed I could use all tags
In your Readme it just says orientation is only for the direction of animation
========If I put both text views into a separate Layout it will work=========== !-->
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:background="@color/material_amber_200"
android:gravity="center"
android:padding="@dimen/margin_normal"
android:text="sample.sample.sample.sample.sample.sample.sample.sample.sample.sample.
sample.sample.sample.sample.sample.sample.sample.sample.sample.sample. hoge"
android:text="sample.sample.sample. hoge"
android:textColor="@color/white"
android:textSize="16sp" />

<!-- placing this text view on right hand side of first text view !-->
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_width="160dp"
android:layout_height="150dp"
android:background="@color/material_blue_200"
android:layout_toRightOf="@id/text"
android:layout_toEndOf="@id/text"
android:gravity="center"
android:padding="@dimen/margin_normal"
android:text="foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.
foo.foo.foo.foo.foo.foo.foo.foo.foo.foo. hoge"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>

<TextView
android:id="@+id/text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/linearLayout"
android:layout_below="@id/text"
android:background="@color/material_orange_200"
android:gravity="center"
android:padding="@dimen/margin_normal"
Expand All @@ -77,4 +62,9 @@
android:textColor="@color/white"
android:textSize="20sp" />
</com.github.aakira.expandablelayout.ExpandableRelativeLayout>
</RelativeLayout>

<View
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@color/material_pink_900" />
</LinearLayout>