1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 14:32:54 +01:00

App Manager: Hide drag handle if app reorder is not supported

This commit is contained in:
José Rebelo 2023-06-10 15:39:51 +01:00 committed by José Rebelo
parent c1339aa5c6
commit 240326c99a
2 changed files with 10 additions and 3 deletions

View File

@ -408,7 +408,12 @@ public abstract class AbstractAppManagerFragment extends Fragment {
}
});
appListView.setLayoutManager(new GridAutoFitLayoutManager(getActivity(), 300));
mGBDeviceAppAdapter = new GBDeviceAppAdapter(appList, R.layout.item_appmanager_watchapp, this);
mGBDeviceAppAdapter = new GBDeviceAppAdapter(
appList,
R.layout.item_appmanager_watchapp,
this,
mCoordinator.supportsAppReordering() || isCacheManager()
);
appListView.setAdapter(mGBDeviceAppAdapter);
ItemTouchHelper.Callback appItemTouchHelperCallback = new AppItemTouchHelperCallback(mGBDeviceAppAdapter);

View File

@ -27,7 +27,6 @@ import android.widget.TextView;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import androidx.recyclerview.widget.RecyclerView;
@ -49,15 +48,17 @@ public class GBDeviceAppAdapter extends RecyclerView.Adapter<GBDeviceAppAdapter.
private final int mLayoutId;
private final List<GBDeviceApp> appList;
private final AbstractAppManagerFragment mParentFragment;
private final boolean allowReorder;
public List<GBDeviceApp> getAppList() {
return appList;
}
public GBDeviceAppAdapter(List<GBDeviceApp> list, int layoutId, AbstractAppManagerFragment parentFragment) {
public GBDeviceAppAdapter(List<GBDeviceApp> list, int layoutId, AbstractAppManagerFragment parentFragment, boolean reorder) {
mLayoutId = layoutId;
appList = list;
mParentFragment = parentFragment;
allowReorder = reorder;
}
@Override
@ -135,6 +136,7 @@ public class GBDeviceAppAdapter extends RecyclerView.Adapter<GBDeviceAppAdapter.
}
});
holder.mDragHandle.setVisibility(allowReorder ? View.VISIBLE : View.GONE);
holder.mDragHandle.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {