Skip to content

Commit d831760

Browse files
committed
Make panels drag-and-droppable
1 parent 84a6164 commit d831760

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

app/src/main/java/de/raffaelhahn/coder/panels/PanelHolder.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
6363

6464
requireView().setOnDragListener((v, event) -> {
6565
switch (event.getAction()) {
66-
case DragEvent.ACTION_DRAG_ENDED:
67-
if(event.getResult() &&
68-
event.getLocalState() instanceof Pair<?, ?> pair &&
69-
pair.first instanceof PanelHolder originView &&
70-
pair.second instanceof Panel panel) {
71-
if(originView == PanelHolder.this) {
72-
removePanel(panel);
73-
}
74-
return true;
75-
}
76-
break;
7766
case DragEvent.ACTION_DRAG_STARTED:
7867
if (event.getLocalState() instanceof Pair<?, ?> pair &&
7968
pair.first instanceof PanelHolder &&
@@ -86,7 +75,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
8675
pair.first instanceof PanelHolder originView &&
8776
pair.second instanceof Panel panel) {
8877
if(originView != PanelHolder.this) {
89-
addPanel(panel);
78+
originView.removePanel(panel);
79+
showPanel(panel);
9080
return true;
9181
}
9282
}
@@ -148,6 +138,7 @@ public void removePanel(Panel panel) {
148138
FragmentTransaction ft = getParentFragmentManager().beginTransaction();
149139
ft.remove(panel.getFragment());
150140
ft.commit();
141+
getParentFragmentManager().executePendingTransactions();
151142
}
152143
}
153144
}

0 commit comments

Comments
 (0)