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

Checklable views fix #24

Merged
merged 1 commit into from
Jul 14, 2015
Merged
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 @@ -22,19 +22,21 @@
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Checkable;
import android.widget.FrameLayout;

/**
* Class to hold a ListView item and the swipe backgrounds
*
* Created by wdullaer on 22.06.14.
*/
public class SwipeViewGroup extends FrameLayout {
public class SwipeViewGroup extends FrameLayout implements Checkable {
private View contentView = null;

private int visibleView = SwipeDirections.DIRECTION_NEUTRAL;
private SparseArray<View> mBackgroundMap = new SparseArray<>();
private OnTouchListener swipeTouchListener;
private boolean checked;

/**
* Standard android View constructor
Expand Down Expand Up @@ -194,4 +196,22 @@ public boolean onTouchEvent(@NonNull MotionEvent ev) {
// Finish the swipe gesture: our parent will no longer do it if this function is called
return swipeTouchListener.onTouch(this, ev);
}

@Override
public void setChecked(boolean checked) {
this.checked = checked;
if ( contentView != null && contentView instanceof Checkable ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking mode: can you remove the spaces after the if brackets?

((Checkable)contentView).setChecked(checked);
}
}

@Override
public boolean isChecked() {
return checked;
}

@Override
public void toggle() {
this.setChecked( ! checked );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking mode: can you refactor this to: this.setChecked(!checked);

}
}