daimajia / daimajia/AndroidSwipeLayout

Issue with Listeners and DragPosition

Open
#498 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.3k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Hi, damaija! I'm working on my own recyclerview with using of your library to add two swipe-buttons in my recyclerview's rows. The xml-file for this row looks like that:

`








`

Next I've created ViewHolder, which I put in separate class away from recyclerView:

`public class GroupsViewHolder extends RecyclerView.ViewHolder {

public static final String EXTRA_GROUP = "com.hfad.singleton.GROUP";
private SwipeLayout swipeLayout;
private ImageView imageView;
private TextView nameView;

GroupsViewHolder(View itemView) {
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.item_image);
nameView = (TextView) itemView.findViewById(R.id.group_name);
}

public SwipeLayout getSwipeLayout() {
return swipeLayout;
}

public void setSwipeLayout(SwipeLayout swipeLayout) {
this.swipeLayout = swipeLayout;
}

public ImageView getImageView() {
return imageView;
}

public void setImageView(ImageView imageView) {
this.imageView = imageView;
}

public TextView getNameView() {
return nameView;
}

public void setNameView(TextView nameView) {
this.nameView = nameView;
}

public void setSwipeToItem() {
swipeLayout = (SwipeLayout) LayoutInflater.from
(itemView.getContext()).inflate(R.layout.layout_list_of_groups, null);
swipeLayout.setShowMode(SwipeLayout.ShowMode.PullOut);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, swipeLayout.findViewWithTag("swipeButtons"));

swipeLayout.findViewById(R.id.edit_group).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(itemView.getContext(), "Edit", Toast.LENGTH_SHORT).show();
}
});

swipeLayout.findViewById(R.id.delete_group).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(itemView.getContext(), "Delete", Toast.LENGTH_SHORT).show();
}
});

swipeLayout.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), WordsActivity.class);
String nameOfGroup = (String) nameView.getText();
intent.putExtra(EXTRA_GROUP, nameOfGroup);
itemView.getContext().startActivity(intent);
}
});
}
}`

I've met the following issues:
1) I can swipe RecyclerView's row and watch delete and edit buttons, but neither of this buttons responds to my clicks. Also it's the same problem with my surface part of layout
2) Swipe buttons appear from the right edge of the phone regardless of which ENUM-parameter was setted up in the
` swipeLayout.addDrag(SwipeLayout.DragEdge.Left, swipeLayout.findViewWithTag("swipeButtons"));`
right or left

So I need a help to fix this problems or advices where I'm getting wrong about working with library

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.