mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-29 19:40:32 +00:00
Remove FixedGridLayoutManager
This commit is contained in:
parent
a7c31e6bcc
commit
b5558a8b78
@ -35,7 +35,6 @@ import org.schabi.newpipe.util.OnClickGesture;
|
|||||||
import org.schabi.newpipe.util.StateSaver;
|
import org.schabi.newpipe.util.StateSaver;
|
||||||
import org.schabi.newpipe.util.StreamDialogEntry;
|
import org.schabi.newpipe.util.StreamDialogEntry;
|
||||||
import org.schabi.newpipe.views.SuperScrollLayoutManager;
|
import org.schabi.newpipe.views.SuperScrollLayoutManager;
|
||||||
import org.schabi.newpipe.views.FixedGridLayoutManager;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
@ -157,7 +156,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
|||||||
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
|
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
|
||||||
width += (24 * resources.getDisplayMetrics().density);
|
width += (24 * resources.getDisplayMetrics().density);
|
||||||
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
|
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
|
||||||
final GridLayoutManager lm = new FixedGridLayoutManager(activity, spanCount);
|
final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
|
||||||
lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
|
lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
|
||||||
return lm;
|
return lm;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import android.view.View;
|
|||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.fragments.BaseStateFragment;
|
import org.schabi.newpipe.fragments.BaseStateFragment;
|
||||||
import org.schabi.newpipe.fragments.list.ListViewContract;
|
import org.schabi.newpipe.fragments.list.ListViewContract;
|
||||||
import org.schabi.newpipe.views.FixedGridLayoutManager;
|
|
||||||
|
|
||||||
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ public abstract class BaseLocalListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
|
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
|
||||||
width += (24 * resources.getDisplayMetrics().density);
|
width += (24 * resources.getDisplayMetrics().density);
|
||||||
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
|
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
|
||||||
final GridLayoutManager lm = new FixedGridLayoutManager(activity, spanCount);
|
final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
|
||||||
lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount));
|
lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount));
|
||||||
return lm;
|
return lm;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ import org.schabi.newpipe.util.ServiceHelper;
|
|||||||
import org.schabi.newpipe.util.ShareUtils;
|
import org.schabi.newpipe.util.ShareUtils;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
import org.schabi.newpipe.views.CollapsibleView;
|
import org.schabi.newpipe.views.CollapsibleView;
|
||||||
import org.schabi.newpipe.views.FixedGridLayoutManager;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -193,7 +192,7 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
|||||||
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
|
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
|
||||||
width += (24 * resources.getDisplayMetrics().density);
|
width += (24 * resources.getDisplayMetrics().density);
|
||||||
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
|
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels / (double)width);
|
||||||
final GridLayoutManager lm = new FixedGridLayoutManager(activity, spanCount);
|
final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
|
||||||
lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
|
lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
|
||||||
return lm;
|
return lm;
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Eltex ltd 2019 <eltex@eltex-co.ru>
|
|
||||||
* FixedGridLayoutManager.java is part of NewPipe.
|
|
||||||
*
|
|
||||||
* NewPipe 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 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* NewPipe 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 NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.schabi.newpipe.views;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.FocusFinder;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
// Version of GridLayoutManager that works around https://issuetracker.google.com/issues/37067220
|
|
||||||
public class FixedGridLayoutManager extends GridLayoutManager {
|
|
||||||
public FixedGridLayoutManager(Context context, int spanCount) {
|
|
||||||
super(context, spanCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FixedGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FixedGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) {
|
|
||||||
super(context, spanCount, orientation, reverseLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onFocusSearchFailed(View focused, int focusDirection, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
|
||||||
FocusFinder ff = FocusFinder.getInstance();
|
|
||||||
|
|
||||||
View result = ff.findNextFocus((ViewGroup) focused.getParent(), focused, focusDirection);
|
|
||||||
if (result != null) {
|
|
||||||
return super.onFocusSearchFailed(focused, focusDirection, recycler, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (focusDirection == View.FOCUS_DOWN) {
|
|
||||||
scrollVerticallyBy(10, recycler, state);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onFocusSearchFailed(focused, focusDirection, recycler, state);
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,7 +30,6 @@ import org.schabi.newpipe.R;
|
|||||||
import org.schabi.newpipe.settings.NewPipeSettings;
|
import org.schabi.newpipe.settings.NewPipeSettings;
|
||||||
import org.schabi.newpipe.util.FilePickerActivityHelper;
|
import org.schabi.newpipe.util.FilePickerActivityHelper;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
import org.schabi.newpipe.views.FixedGridLayoutManager;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -109,7 +108,7 @@ public class MissionsFragment extends Fragment {
|
|||||||
mList = v.findViewById(R.id.mission_recycler);
|
mList = v.findViewById(R.id.mission_recycler);
|
||||||
|
|
||||||
// Init layouts managers
|
// Init layouts managers
|
||||||
mGridManager = new FixedGridLayoutManager(getActivity(), SPAN_SIZE);
|
mGridManager = new GridLayoutManager(getActivity(), SPAN_SIZE);
|
||||||
mGridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
mGridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||||
@Override
|
@Override
|
||||||
public int getSpanSize(int position) {
|
public int getSpanSize(int position) {
|
||||||
|
Loading…
Reference in New Issue
Block a user