Android - People - Bigger touch area for friend star

This commit is contained in:
Cristian Duarte 2018-08-15 14:50:53 -03:00
parent d20c386102
commit 6b2de05065
2 changed files with 23 additions and 19 deletions

View file

@ -105,19 +105,16 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.ViewHo
public class ToggleWrapper {
private ViewGroup mFrame;
private ImageView mImage;
private boolean mChecked = false;
private String mUsername;
private boolean waitingChangeConfirm = false;
public ToggleWrapper(ImageView imageView) {
mImage = imageView;
mImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
public ToggleWrapper(ViewGroup toggleFrame) {
mFrame = toggleFrame;
mImage = toggleFrame.findViewById(R.id.userFavImage);
mFrame.setOnClickListener(view -> toggle());
}
private void refreshUI() {
@ -136,7 +133,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.ViewHo
@Override
public void requestOk() {
if (!waitingChangeConfirm) return;
mImage.setClickable(true);
mFrame.setClickable(true);
// nothing to do, new status was set
}
@ -145,7 +142,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.ViewHo
if (!waitingChangeConfirm) return;
// new status was not set, rolling back
mChecked = previousStatus;
mImage.setClickable(true);
mFrame.setClickable(true);
refreshUI();
}
@ -155,7 +152,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.ViewHo
// TODO API CALL TO CHANGE
final boolean previousStatus = mChecked;
mChecked = !mChecked;
mImage.setClickable(false);
mFrame.setClickable(false);
refreshUI();
waitingChangeConfirm = true;
if (mChecked) {
@ -169,7 +166,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.ViewHo
mChecked = checked;
mUsername = username;
waitingChangeConfirm = false;
mImage.setClickable(true);
mFrame.setClickable(true);
refreshUI();
}
}

View file

@ -46,16 +46,23 @@
android:textColor="@color/menuOption"/>
</LinearLayout>
</LinearLayout>
<ImageView android:id="@+id/userFav"
android:layout_width="27dp"
android:layout_height="27dp"
android:src="@drawable/ic_star"
android:background="?attr/selectableItemBackgroundBorderless"
<RelativeLayout android:id="@+id/userFav"
android:layout_width="48dp"
android:layout_height="48dp"
android:clickable="true"
android:focusable="true"
android:tint="@color/starUnselectedTint"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="@dimen/activity_horizontal_margin" />
android:layout_marginEnd="5.5dp">
<ImageView android:id="@+id/userFavImage"
android:layout_width="27dp"
android:layout_height="27dp"
android:src="@drawable/ic_star"
android:tint="@color/starUnselectedTint"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_centerInParent="true"
android:layout_marginEnd="0dp" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>