使用Glide进行Recyclerview和预加载时出现问题

时间:2017-04-24 00:35:26

标签: android android-recyclerview android-glide

我一直在尝试在我的recyclerView(片段)中使用预加载器但由于某种原因我无法调用它。我的代码:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View ShipList = inflater.inflate(R.layout.ships, container, false);
        ((Homescreen)getActivity()).setActionBarTitle("Ships");
        ShipsDbHelper = new ShipsDbHelper(getActivity());

        shipView = (RecyclerView) ShipList.findViewById(R.id.ShipRec);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        shipView.setLayoutManager(layoutManager);
        shipView.setHasFixedSize(true);
        shipAdapter = new GreenAdapter();
        shipView.addItemDecoration(new DividerItemDecoration(getActivity()));
        shipView.addOnScrollListener(new ShipViewPreloader(,,10));
        shipView.setAdapter(shipAdapter);
        return ShipList;

    }

我想我需要在10之前放一些东西,但我无法确定我需要的东西。

这也是我的Preloader:

public final class ShipViewPreloader<T> extends RecyclerView.OnScrollListener {
        private final recyclerShipListener recyclerShipListener;


        public ShipViewPreloader(ListPreloader.PreloadModelProvider<T> preloadModelProvider,
                                 ListPreloader.PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload) {

            ListPreloader<T> listPreloader = new ListPreloader<>(preloadModelProvider,
                    preloadDimensionProvider, maxPreload);
            recyclerShipListener = new recyclerShipListener(listPreloader);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            recyclerShipListener.onScrolled(recyclerView, dx, dy);}
    }

我希望你们中的一个能帮助我,我是Glide的新手,发现文档并不像Androids文档那么好。

0 个答案:

没有答案