forked from h6ah4i/android-advancedrecyclerview
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ExpandableItemIndicator widget
- Loading branch information
Showing
31 changed files
with
282 additions
and
267 deletions.
There are no files selected for viewing
53 changes: 0 additions & 53 deletions
53
...main/java/com/h6ah4i/android/example/advrecyclerview/common/compat/MorphButtonCompat.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...va/com/h6ah4i/android/example/advrecyclerview/common/compat/MorphButtonCompatImplICS.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...com/h6ah4i/android/example/advrecyclerview/common/compat/MorphButtonCompatImplPreICS.java
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
...ava/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2015 Haruki Hasegawa | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.h6ah4i.android.example.advrecyclerview.common.widget; | ||
|
||
import android.content.Context; | ||
import android.os.Build; | ||
import android.os.Parcelable; | ||
import android.util.AttributeSet; | ||
import android.util.SparseArray; | ||
import android.widget.FrameLayout; | ||
|
||
public class ExpandableItemIndicator extends FrameLayout { | ||
static abstract class Impl { | ||
public abstract void onInit(Context context, AttributeSet attrs, int defStyleAttr, ExpandableItemIndicator thiz); | ||
|
||
public abstract void setExpandedState(boolean isExpanded, boolean animate); | ||
} | ||
|
||
private Impl mImpl; | ||
|
||
public ExpandableItemIndicator(Context context) { | ||
super(context); | ||
onInit(context, null, 0); | ||
} | ||
|
||
public ExpandableItemIndicator(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
onInit(context, attrs, 0); | ||
} | ||
|
||
public ExpandableItemIndicator(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
onInit(context, attrs, defStyleAttr); | ||
} | ||
|
||
protected void onInit(Context context, AttributeSet attrs, int defStyleAttr) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { | ||
// NOTE: MorphButton only supports API level 14 or later | ||
mImpl = new ExpandableItemIndicatorImplAnim(); | ||
} else { | ||
mImpl = new ExpandableItemIndicatorImplNoAnim(); | ||
} | ||
mImpl.onInit(context, attrs, defStyleAttr, this); | ||
} | ||
|
||
@Override | ||
protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) { | ||
super.dispatchFreezeSelfOnly(container); | ||
} | ||
|
||
@Override | ||
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) { | ||
super.dispatchThawSelfOnly(container); | ||
} | ||
|
||
public void setExpandedState(boolean isExpanded, boolean animate) { | ||
mImpl.setExpandedState(isExpanded, animate); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplAnim.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2015 Haruki Hasegawa | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.h6ah4i.android.example.advrecyclerview.common.widget; | ||
|
||
import android.annotation.TargetApi; | ||
import android.content.Context; | ||
import android.os.Build; | ||
import android.os.Parcelable; | ||
import android.util.AttributeSet; | ||
import android.util.SparseArray; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.FrameLayout; | ||
|
||
import com.h6ah4i.android.example.advrecyclerview.R; | ||
import com.wnafee.vector.MorphButton; | ||
|
||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) | ||
class ExpandableItemIndicatorImplAnim extends ExpandableItemIndicator.Impl { | ||
private MorphButton mMorphButton; | ||
|
||
@Override | ||
public void onInit(Context context, AttributeSet attrs, int defStyleAttr, ExpandableItemIndicator thiz) { | ||
View v = LayoutInflater.from(context).inflate(R.layout.widget_expandable_item_indicator_anim, thiz, true); | ||
mMorphButton = (MorphButton) v.findViewById(R.id.morph_button); | ||
} | ||
|
||
@Override | ||
public void setExpandedState(boolean isExpanded, boolean animate) { | ||
MorphButton.MorphState indicatorState = (isExpanded) ? MorphButton.MorphState.END : MorphButton.MorphState.START; | ||
|
||
if (mMorphButton.getState() != indicatorState) { | ||
mMorphButton.setState(indicatorState, animate); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplNoAnim.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2015 Haruki Hasegawa | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.h6ah4i.android.example.advrecyclerview.common.widget; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
|
||
import com.h6ah4i.android.example.advrecyclerview.R; | ||
|
||
class ExpandableItemIndicatorImplNoAnim extends ExpandableItemIndicator.Impl { | ||
private ImageView mImageView; | ||
|
||
@Override | ||
public void onInit(Context context, AttributeSet attrs, int defStyleAttr, ExpandableItemIndicator thiz) { | ||
View v = LayoutInflater.from(context).inflate(R.layout.widget_expandable_item_indicator_no_anim, thiz, true); | ||
mImageView = (ImageView) v.findViewById(R.id.image_view); | ||
} | ||
|
||
@Override | ||
public void setExpandedState(boolean isExpanded, boolean animate) { | ||
int resId = (isExpanded) ? R.drawable.ic_expand_less : R.drawable.ic_expand_more; | ||
mImageView.setImageResource(resId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.