1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 00:20:32 +00:00

Update RecyclerView & Groupie

This commit is contained in:
TacoTheDank 2021-10-19 17:31:59 -04:00
parent 7edef8d5a2
commit b6b19b474e
8 changed files with 19 additions and 16 deletions

View File

@ -107,7 +107,7 @@ ext {
icepickVersion = '3.2.0' icepickVersion = '3.2.0'
exoPlayerVersion = '2.12.3' exoPlayerVersion = '2.12.3'
googleAutoServiceVersion = '1.0' googleAutoServiceVersion = '1.0'
groupieVersion = '2.9.0' groupieVersion = '2.10.0'
markwonVersion = '4.6.2' markwonVersion = '4.6.2'
leakCanaryVersion = '2.5' leakCanaryVersion = '2.5'
@ -211,11 +211,14 @@ dependencies {
implementation 'androidx.media:media:1.4.2' implementation 'androidx.media:media:1.4.2'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation "androidx.room:room-runtime:${androidxRoomVersion}" implementation "androidx.room:room-runtime:${androidxRoomVersion}"
implementation "androidx.room:room-rxjava3:${androidxRoomVersion}" implementation "androidx.room:room-rxjava3:${androidxRoomVersion}"
kapt "androidx.room:room-compiler:${androidxRoomVersion}" kapt "androidx.room:room-compiler:${androidxRoomVersion}"
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
// Newer version specified to prevent accessibility regressions with RecyclerView, see:
// https://developer.android.com/jetpack/androidx/releases/viewpager2#1.1.0-alpha01
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
implementation 'androidx.webkit:webkit:1.4.0' implementation 'androidx.webkit:webkit:1.4.0'
implementation 'com.google.android.material:material:1.2.1' implementation 'com.google.android.material:material:1.2.1'

View File

@ -143,7 +143,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
final View focusedItem = itemsList.getFocusedChild(); final View focusedItem = itemsList.getFocusedChild();
final RecyclerView.ViewHolder itemHolder = final RecyclerView.ViewHolder itemHolder =
itemsList.findContainingViewHolder(focusedItem); itemsList.findContainingViewHolder(focusedItem);
return itemHolder.getAdapterPosition(); return itemHolder.getBindingAdapterPosition();
} catch (final NullPointerException e) { } catch (final NullPointerException e) {
return -1; return -1;
} }

View File

@ -1088,7 +1088,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
public int getSuggestionMovementFlags(@NonNull final RecyclerView.ViewHolder viewHolder) { public int getSuggestionMovementFlags(@NonNull final RecyclerView.ViewHolder viewHolder) {
final int position = viewHolder.getAdapterPosition(); final int position = viewHolder.getBindingAdapterPosition();
if (position == RecyclerView.NO_POSITION) { if (position == RecyclerView.NO_POSITION) {
return 0; return 0;
} }
@ -1099,7 +1099,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
} }
public void onSuggestionItemSwiped(@NonNull final RecyclerView.ViewHolder viewHolder) { public void onSuggestionItemSwiped(@NonNull final RecyclerView.ViewHolder viewHolder) {
final int position = viewHolder.getAdapterPosition(); final int position = viewHolder.getBindingAdapterPosition();
final String query = suggestionListAdapter.getItem(position).query; final String query = suggestionListAdapter.getItem(position).query;
final Disposable onDelete = historyRecordManager.deleteSearchHistory(query) final Disposable onDelete = historyRecordManager.deleteSearchHistory(query)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())

View File

@ -709,8 +709,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
return false; return false;
} }
final int sourceIndex = source.getAdapterPosition(); final int sourceIndex = source.getBindingAdapterPosition();
final int targetIndex = target.getAdapterPosition(); final int targetIndex = target.getBindingAdapterPosition();
final boolean isSwapped = itemListAdapter.swapItems(sourceIndex, targetIndex); final boolean isSwapped = itemListAdapter.swapItems(sourceIndex, targetIndex);
if (isSwapped) { if (isSwapped) {
saveChanges(); saveChanges();

View File

@ -112,8 +112,8 @@ class FeedGroupReorderDialog : DialogFragment() {
source: RecyclerView.ViewHolder, source: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder target: RecyclerView.ViewHolder
): Boolean { ): Boolean {
val sourceIndex = source.adapterPosition val sourceIndex = source.bindingAdapterPosition
val targetIndex = target.adapterPosition val targetIndex = target.bindingAdapterPosition
groupAdapter.notifyItemMoved(sourceIndex, targetIndex) groupAdapter.notifyItemMoved(sourceIndex, targetIndex)
Collections.swap(groupOrderedIdList, sourceIndex, targetIndex) Collections.swap(groupOrderedIdList, sourceIndex, targetIndex)

View File

@ -51,6 +51,6 @@ public abstract class PlayQueueItemTouchCallback extends ItemTouchHelper.SimpleC
@Override @Override
public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int swipeDir) { public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int swipeDir) {
onSwiped(viewHolder.getAdapterPosition()); onSwiped(viewHolder.getBindingAdapterPosition());
} }
} }

View File

@ -303,8 +303,8 @@ public class PeertubeInstanceListFragment extends Fragment {
return false; return false;
} }
final int sourceIndex = source.getAdapterPosition(); final int sourceIndex = source.getBindingAdapterPosition();
final int targetIndex = target.getAdapterPosition(); final int targetIndex = target.getBindingAdapterPosition();
instanceListAdapter.swapItems(sourceIndex, targetIndex); instanceListAdapter.swapItems(sourceIndex, targetIndex);
return true; return true;
} }
@ -322,7 +322,7 @@ public class PeertubeInstanceListFragment extends Fragment {
@Override @Override
public void onSwiped(@NonNull final RecyclerView.ViewHolder viewHolder, public void onSwiped(@NonNull final RecyclerView.ViewHolder viewHolder,
final int swipeDir) { final int swipeDir) {
final int position = viewHolder.getAdapterPosition(); final int position = viewHolder.getBindingAdapterPosition();
// do not allow swiping the selected instance // do not allow swiping the selected instance
if (instanceList.get(position).getUrl().equals(selectedInstance.getUrl())) { if (instanceList.get(position).getUrl().equals(selectedInstance.getUrl())) {
instanceListAdapter.notifyItemChanged(position); instanceListAdapter.notifyItemChanged(position);

View File

@ -299,8 +299,8 @@ public class ChooseTabsFragment extends Fragment {
return false; return false;
} }
final int sourceIndex = source.getAdapterPosition(); final int sourceIndex = source.getBindingAdapterPosition();
final int targetIndex = target.getAdapterPosition(); final int targetIndex = target.getBindingAdapterPosition();
selectedTabsAdapter.swapItems(sourceIndex, targetIndex); selectedTabsAdapter.swapItems(sourceIndex, targetIndex);
return true; return true;
} }
@ -318,7 +318,7 @@ public class ChooseTabsFragment extends Fragment {
@Override @Override
public void onSwiped(@NonNull final RecyclerView.ViewHolder viewHolder, public void onSwiped(@NonNull final RecyclerView.ViewHolder viewHolder,
final int swipeDir) { final int swipeDir) {
final int position = viewHolder.getAdapterPosition(); final int position = viewHolder.getBindingAdapterPosition();
tabList.remove(position); tabList.remove(position);
selectedTabsAdapter.notifyItemRemoved(position); selectedTabsAdapter.notifyItemRemoved(position);