Search in sources :

Example 1 with ActivityListAdapter

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

the class ActivitiesActivity method setupContent.

/**
 * sets up the UI elements and loads all activity items.
 */
private void setupContent() {
    binding.emptyList.emptyListIcon.setImageResource(R.drawable.ic_activity);
    adapter = new ActivityListAdapter(this, getUserAccountManager(), this, clientFactory, false, themeColorUtils, themeDrawableUtils);
    binding.list.setAdapter(adapter);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    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
                actionListener.loadActivities(lastGiven);
            }
        }
    });
    actionListener.loadActivities(ActivitiesContract.ActionListener.UNDEFINED);
}
Also used : ActivityListAdapter(com.owncloud.android.ui.adapter.ActivityListAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 2 with ActivityListAdapter

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

the class ActivitiesListActivity method setupContent.

/**
 * sets up the UI elements and loads all activity items.
 */
private void setupContent() {
    emptyContentIcon.setImageResource(R.drawable.ic_activity_light_grey);
    emptyContentProgressBar.getIndeterminateDrawable().setColorFilter(ThemeUtils.primaryAccentColor(), PorterDuff.Mode.SRC_IN);
    setLoadingMessage();
    FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
    adapter = new ActivityListAdapter(this, this, storageManager);
    recyclerView.setAdapter(adapter);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(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) && nextPageUrl != null && !nextPageUrl.isEmpty()) {
                // Almost reached the end, continue to load new activities
                fetchAndSetData(nextPageUrl);
            }
        }
    });
    if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
        bottomNavigationView.setVisibility(View.VISIBLE);
        DisplayUtils.setupBottomBar(bottomNavigationView, getResources(), this, -1);
    }
    fetchAndSetData(null);
}
Also used : FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) ActivityListAdapter(com.owncloud.android.ui.adapter.ActivityListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

ActivityListAdapter (com.owncloud.android.ui.adapter.ActivityListAdapter)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)1