Search in sources :

Example 1 with ActivityAndVersionListAdapter

use of com.owncloud.android.ui.adapter.ActivityAndVersionListAdapter in project android by nextcloud.

the class FileDetailActivitiesFragment method setupView.

private void setupView() {
    FileDataStorageManager storageManager = new FileDataStorageManager(user, contentResolver);
    operationsHelper = ((ComponentsGetter) requireActivity()).getFileOperationsHelper();
    OCCapability capability = storageManager.getCapability(user.getAccountName());
    restoreFileVersionSupported = capability.getFilesVersioning().isTrue();
    binding.emptyList.emptyListIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_activity, null));
    binding.emptyList.emptyListView.setVisibility(View.GONE);
    adapter = new ActivityAndVersionListAdapter(getContext(), accountManager, this, this, clientFactory);
    binding.list.setAdapter(adapter);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    binding.list.setLayoutManager(layoutManager);
    binding.list.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int visibleItemCount = recyclerView.getChildCount();
            int totalItemCount = layoutManager.getItemCount();
            int firstVisibleItemIndex = layoutManager.findFirstVisibleItemPosition();
            // synchronize loading state when item count changes
            if (!isLoadingActivities && (totalItemCount - visibleItemCount) <= (firstVisibleItemIndex + 5) && lastGiven > 0) {
                // Almost reached the end, continue to load new activities
                fetchAndSetData(lastGiven);
            }
        }
    });
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) ActivityAndVersionListAdapter(com.owncloud.android.ui.adapter.ActivityAndVersionListAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)1 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)1 ActivityAndVersionListAdapter (com.owncloud.android.ui.adapter.ActivityAndVersionListAdapter)1