forked from bauerca/drag-sort-listview
-
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.
Two item view wrappers: checkable and non
So that setActivated() will be called on items that are not checkable when some choice mode is enabled.
- Loading branch information
Showing
3 changed files
with
64 additions
and
27 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
library/src/com/mobeta/android/dslv/DragSortItemViewCheckable.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,55 @@ | ||
package com.mobeta.android.dslv; | ||
|
||
import android.content.Context; | ||
import android.view.Gravity; | ||
import android.view.View; | ||
import android.view.View.MeasureSpec; | ||
import android.view.ViewGroup; | ||
import android.widget.AbsListView; | ||
import android.widget.Checkable; | ||
import android.util.Log; | ||
|
||
/** | ||
* Lightweight ViewGroup that wraps list items obtained from user's | ||
* ListAdapter. ItemView expects a single child that has a definite | ||
* height (i.e. the child's layout height is not MATCH_PARENT). | ||
* The width of | ||
* ItemView will always match the width of its child (that is, | ||
* the width MeasureSpec given to ItemView is passed directly | ||
* to the child, and the ItemView measured width is set to the | ||
* child's measured width). The height of ItemView can be anything; | ||
* the | ||
* | ||
* | ||
* The purpose of this class is to optimize slide | ||
* shuffle animations. | ||
*/ | ||
public class DragSortItemViewCheckable extends DragSortItemView implements Checkable { | ||
|
||
public DragSortItemViewCheckable(Context context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
public boolean isChecked() { | ||
View child = getChildAt(0); | ||
if (child instanceof Checkable) | ||
return ((Checkable) child).isChecked(); | ||
else | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setChecked(boolean checked) { | ||
View child = getChildAt(0); | ||
if (child instanceof Checkable) | ||
((Checkable) child).setChecked(checked); | ||
} | ||
|
||
@Override | ||
public void toggle() { | ||
View child = getChildAt(0); | ||
if (child instanceof Checkable) | ||
((Checkable) child).toggle(); | ||
} | ||
} |
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