Search in sources :

Example 1 with UploadHistoryListAdapter

use of com.thecoolguy.rumaan.fileio.adapters.UploadHistoryListAdapter in project file.io-app by rumaan.

the class UploadHistoryActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_upload_history);
    ButterKnife.bind(this);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(getString(R.string.upload_history_title));
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    final UploadHistoryListAdapter uploadHistoryListAdapter = new UploadHistoryListAdapter(this);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(linearLayoutManager);
    uploadItemViewModel = ViewModelProviders.of(this).get(UploadItemViewModel.class);
    uploadItemViewModel.getUploadHistoryList().observe(this, new Observer<List<UploadItem>>() {

        @Override
        public void onChanged(@Nullable List<UploadItem> uploadItems) {
            if ((uploadItems == null) || uploadItems.isEmpty()) {
                noUploadsView.setVisibility(View.VISIBLE);
                recyclerView.setVisibility(View.INVISIBLE);
            } else {
                noUploadsView.setVisibility(View.INVISIBLE);
                recyclerView.setVisibility(View.VISIBLE);
                uploadHistoryListAdapter.setUploadItemList(uploadItems);
                recyclerView.addItemDecoration(getSectionCallback(uploadItemViewModel.getUploadHistoryList().getValue()));
            }
        }
    });
    recyclerView.setAdapter(uploadHistoryListAdapter);
    uploadHistoryListAdapter.setOnUploadItemLongClickListener(this);
    LayoutAnimationController layoutAnimationController = AnimationUtils.loadLayoutAnimation(this, R.anim.layout_anim_fall_down);
    recyclerView.setLayoutAnimation(layoutAnimationController);
}
Also used : LayoutAnimationController(android.view.animation.LayoutAnimationController) List(java.util.List) UploadHistoryListAdapter(com.thecoolguy.rumaan.fileio.adapters.UploadHistoryListAdapter) UploadItem(com.thecoolguy.rumaan.fileio.data.models.UploadItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ActionBar(android.support.v7.app.ActionBar) UploadItemViewModel(com.thecoolguy.rumaan.fileio.data.UploadItemViewModel)

Aggregations

ActionBar (android.support.v7.app.ActionBar)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 LayoutAnimationController (android.view.animation.LayoutAnimationController)1 UploadHistoryListAdapter (com.thecoolguy.rumaan.fileio.adapters.UploadHistoryListAdapter)1 UploadItemViewModel (com.thecoolguy.rumaan.fileio.data.UploadItemViewModel)1 UploadItem (com.thecoolguy.rumaan.fileio.data.models.UploadItem)1 List (java.util.List)1