11-30 12:32:48.741 8708-8708/com.qualtosoft.vision E/UncaughtException: java.lang.IllegalStateException: Observer com.mobeta.android.dslv.DragSortListView$2@43c16a50 is already registered.
at android.database.Observable.registerObserver(Observable.java:49)
at android.widget.BaseAdapter.registerDataSetObserver(BaseAdapter.java:38)
at com.mobeta.android.dslv.DragSortListView.setAdapter(DragSortListView.java:608)
at com.qualtosoft.vision.fragment.OrderFragment$5.onTabSelected(OrderFragment.java:250)
at android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1149)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1142)
at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1112)
at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1407)
at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1511)
at android.view.View$PerformClick.run(View.java:17752)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5457)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:879)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
at dalvik.system.NativeStart.main(Native Method)
I have a single list view and two tabs with one one adapter each. For the first run, nothing goes wrong. On switching the next tab works fine. but returning back to previous tab gives me observer already registered error.
i have provided my sample code below
public MyFragment extends CustomFragment {
ArrayList<Order> groupOrders = new ArrayList<>();
ArrayList<Order> outstanding = new ArrayList<>();
ListViewAdapterOrder listViewAdapterOrder;
ListViewAdapterOrder outstandingAdapter;
.
.
.
.
@Override
public void onCreate(Bundle savedInstanceState) {
.
.
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
.
.
tabLayout.addTab(tabLayout.newTab().setText("Order"));
tabLayout.addTab(tabLayout.newTab().setText("Outstanding"));
if (tabLayout.getSelectedTabPosition()==0) {
listView.setDropListener(new DragSortListView.DropListener() {
@Override
public void drop(int from, int to) {
}
});
listView.setRemoveListener(new DragSortListView.RemoveListener() {
@Override
public void remove(int i) {
}
});
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
outstandingAdapter = new ListViewAdapterOrder(getActivity(), outstanding);
}
@Override
public void onStart() {
super.onStart();
listViewAdapterOrder = new ListViewAdapterOrder(getActivity(), groupOrders);
listViewAdapterOrder.notifyDataSetChanged();
listView.setAdapter(listViewAdapterOrder);
}
}
11-30 12:32:48.741 8708-8708/com.qualtosoft.vision E/UncaughtException: java.lang.IllegalStateException: Observer com.mobeta.android.dslv.DragSortListView$2@43c16a50 is already registered. at android.database.Observable.registerObserver(Observable.java:49) at android.widget.BaseAdapter.registerDataSetObserver(BaseAdapter.java:38) at com.mobeta.android.dslv.DragSortListView.setAdapter(DragSortListView.java:608) at com.qualtosoft.vision.fragment.OrderFragment$5.onTabSelected(OrderFragment.java:250) at android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1149) at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1142) at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1112) at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1407) at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1511) at android.view.View$PerformClick.run(View.java:17752) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5457) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:879) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695) at dalvik.system.NativeStart.main(Native Method)
I have a single list view and two tabs with one one adapter each. For the first run, nothing goes wrong. On switching the next tab works fine. but returning back to previous tab gives me observer already registered error.
i have provided my sample code below