Attempt for fix issue that happens sometimes in RecyclerView: Invalid item position 0
This commit is contained in:
parent
3e95ed8ed4
commit
b21625995e
8 changed files with 65 additions and 6 deletions
|
@ -100,6 +100,10 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if (!LinphoneService.isReady()) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
mOnBackPressGoHome = true;
|
mOnBackPressGoHome = true;
|
||||||
|
|
|
@ -62,6 +62,7 @@ import org.linphone.core.SearchResult;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
import org.linphone.settings.LinphonePreferences;
|
import org.linphone.settings.LinphonePreferences;
|
||||||
import org.linphone.views.ContactSelectView;
|
import org.linphone.views.ContactSelectView;
|
||||||
|
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||||
|
|
||||||
public class ChatRoomCreationFragment extends Fragment
|
public class ChatRoomCreationFragment extends Fragment
|
||||||
implements View.OnClickListener,
|
implements View.OnClickListener,
|
||||||
|
@ -220,7 +221,7 @@ public class ChatRoomCreationFragment extends Fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearLayoutManager layoutManager =
|
LinearLayoutManager layoutManager =
|
||||||
new LinearLayoutManager(getActivity().getApplicationContext());
|
new LinphoneLinearLayoutManager(getActivity().getApplicationContext());
|
||||||
|
|
||||||
mContactsList.setAdapter(mSearchAdapter);
|
mContactsList.setAdapter(mSearchAdapter);
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.linphone.core.CoreListenerStub;
|
||||||
import org.linphone.core.ProxyConfig;
|
import org.linphone.core.ProxyConfig;
|
||||||
import org.linphone.utils.LinphoneUtils;
|
import org.linphone.utils.LinphoneUtils;
|
||||||
import org.linphone.utils.SelectableHelper;
|
import org.linphone.utils.SelectableHelper;
|
||||||
|
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||||
|
|
||||||
public class ChatRoomsFragment extends Fragment
|
public class ChatRoomsFragment extends Fragment
|
||||||
implements ContactsUpdatedListener,
|
implements ContactsUpdatedListener,
|
||||||
|
@ -94,7 +95,7 @@ public class ChatRoomsFragment extends Fragment
|
||||||
mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
||||||
mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
|
mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
|
||||||
|
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
|
LinearLayoutManager layoutManager = new LinphoneLinearLayoutManager(getActivity());
|
||||||
mChatRoomsList.setLayoutManager(layoutManager);
|
mChatRoomsList.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration =
|
DividerItemDecoration dividerItemDecoration =
|
||||||
|
|
|
@ -56,6 +56,7 @@ import org.linphone.core.Factory;
|
||||||
import org.linphone.core.Participant;
|
import org.linphone.core.Participant;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
import org.linphone.utils.LinphoneUtils;
|
import org.linphone.utils.LinphoneUtils;
|
||||||
|
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||||
|
|
||||||
public class GroupInfoFragment extends Fragment {
|
public class GroupInfoFragment extends Fragment {
|
||||||
private ImageView mConfirmButton;
|
private ImageView mConfirmButton;
|
||||||
|
@ -130,7 +131,7 @@ public class GroupInfoFragment extends Fragment {
|
||||||
});
|
});
|
||||||
mParticipantsList.setAdapter(mAdapter);
|
mParticipantsList.setAdapter(mAdapter);
|
||||||
mAdapter.setChatRoom(mChatRoom);
|
mAdapter.setChatRoom(mChatRoom);
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
|
LinearLayoutManager layoutManager = new LinphoneLinearLayoutManager(getActivity());
|
||||||
mParticipantsList.setLayoutManager(layoutManager);
|
mParticipantsList.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
// Divider between items
|
// Divider between items
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.List;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.utils.SelectableHelper;
|
import org.linphone.utils.SelectableHelper;
|
||||||
|
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||||
|
|
||||||
public class ContactsFragment extends Fragment
|
public class ContactsFragment extends Fragment
|
||||||
implements OnItemClickListener,
|
implements OnItemClickListener,
|
||||||
|
@ -166,7 +167,7 @@ public class ContactsFragment extends Fragment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mLayoutManager = new LinearLayoutManager(mContext);
|
mLayoutManager = new LinphoneLinearLayoutManager(mContext);
|
||||||
mContactsList.setLayoutManager(mLayoutManager);
|
mContactsList.setLayoutManager(mLayoutManager);
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration =
|
DividerItemDecoration dividerItemDecoration =
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.linphone.core.Call;
|
||||||
import org.linphone.core.CallLog;
|
import org.linphone.core.CallLog;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.utils.SelectableHelper;
|
import org.linphone.utils.SelectableHelper;
|
||||||
|
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||||
|
|
||||||
public class HistoryFragment extends Fragment
|
public class HistoryFragment extends Fragment
|
||||||
implements OnClickListener,
|
implements OnClickListener,
|
||||||
|
@ -71,7 +72,7 @@ public class HistoryFragment extends Fragment
|
||||||
|
|
||||||
mHistoryList = view.findViewById(R.id.history_list);
|
mHistoryList = view.findViewById(R.id.history_list);
|
||||||
|
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
|
LinearLayoutManager layoutManager = new LinphoneLinearLayoutManager(getActivity());
|
||||||
mHistoryList.setLayoutManager(layoutManager);
|
mHistoryList.setLayoutManager(layoutManager);
|
||||||
// Divider between items
|
// Divider between items
|
||||||
DividerItemDecoration dividerItemDecoration =
|
DividerItemDecoration dividerItemDecoration =
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.linphone.R;
|
||||||
import org.linphone.activities.MainActivity;
|
import org.linphone.activities.MainActivity;
|
||||||
import org.linphone.utils.FileUtils;
|
import org.linphone.utils.FileUtils;
|
||||||
import org.linphone.utils.SelectableHelper;
|
import org.linphone.utils.SelectableHelper;
|
||||||
|
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||||
|
|
||||||
public class RecordingsActivity extends MainActivity
|
public class RecordingsActivity extends MainActivity
|
||||||
implements SelectableHelper.DeleteListener, RecordingViewHolder.ClickListener {
|
implements SelectableHelper.DeleteListener, RecordingViewHolder.ClickListener {
|
||||||
|
@ -81,7 +82,7 @@ public class RecordingsActivity extends MainActivity
|
||||||
mRecordingList = findViewById(R.id.recording_list);
|
mRecordingList = findViewById(R.id.recording_list);
|
||||||
mNoRecordings = findViewById(R.id.no_recordings);
|
mNoRecordings = findViewById(R.id.no_recordings);
|
||||||
|
|
||||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
|
LinearLayoutManager mLayoutManager = new LinphoneLinearLayoutManager(this);
|
||||||
mRecordingList.setLayoutManager(mLayoutManager);
|
mRecordingList.setLayoutManager(mLayoutManager);
|
||||||
|
|
||||||
// Divider between items
|
// Divider between items
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.linphone.views;
|
||||||
|
/*
|
||||||
|
LinphoneLinearLayoutManager.java
|
||||||
|
Copyright (C) 2019 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
|
/* https://stackoverflow.com/questions/30220771/recyclerview-inconsistency-detected-invalid-item-position */
|
||||||
|
public class LinphoneLinearLayoutManager extends LinearLayoutManager {
|
||||||
|
/**
|
||||||
|
* Disable predictive animations. There is a bug in RecyclerView which causes views that are
|
||||||
|
* being reloaded to pull invalid ViewHolders from the internal recycler stack if the adapter
|
||||||
|
* size has decreased since the ViewHolder was recycled.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean supportsPredictiveItemAnimations() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneLinearLayoutManager(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
|
||||||
|
super(context, orientation, reverseLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneLinearLayoutManager(
|
||||||
|
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue