1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 02:25:50 +01:00

Keep device info on the correct device during reordering

This commit is contained in:
José Rebelo 2021-12-18 23:08:57 +00:00 committed by Gitea
parent 2f217b077f
commit 93dad44750

View File

@ -108,7 +108,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
private final Context context;
private List<GBDevice> deviceList;
private int expandedDevicePosition = RecyclerView.NO_POSITION;
private String expandedDeviceAddress = "";
private ViewGroup parent;
private HashMap<String, long[]> deviceActivityMap = new HashMap();
@ -385,7 +385,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
justifyListViewHeightBasedOnChildren(holder.deviceInfoList);
holder.deviceInfoList.setFocusable(false);
final boolean detailsShown = position == expandedDevicePosition;
final boolean detailsShown = expandedDeviceAddress.equals(device.getAddress());
boolean showInfoIcon = device.hasDeviceInfos() && !device.isBusy();
holder.deviceInfoView.setVisibility(showInfoIcon ? View.VISIBLE : View.GONE);
holder.deviceInfoBox.setActivated(detailsShown);
@ -393,7 +393,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
holder.deviceInfoView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandedDevicePosition = detailsShown ? -1 : position;
expandedDeviceAddress = detailsShown ? "" : device.getAddress();
TransitionManager.beginDelayedTransition(parent);
notifyDataSetChanged();
}