use of com.odysee.app.tasks.localdata.LoadGalleryItemsTask in project odysee-android by OdyseeTeam.
the class PublishFragment method loadGalleryItems.
private void loadGalleryItems() {
Context context = getContext();
Helper.setViewVisibility(noVideosLoaded, View.GONE);
LoadGalleryItemsTask task = new LoadGalleryItemsTask(loading, context, new LoadGalleryItemsTask.LoadGalleryHandler() {
@Override
public void onItemLoaded(GalleryItem item) {
if (context != null) {
if (adapter == null) {
adapter = new GalleryGridAdapter(Arrays.asList(item), context);
adapter.setListener(new GalleryGridAdapter.GalleryItemClickListener() {
@Override
public void onGalleryItemClicked(GalleryItem item) {
Context context = getContext();
if (context instanceof MainActivity) {
Map<String, Object> params = new HashMap<>();
params.put("galleryItem", item);
params.put("suggestedUrl", getSuggestedPublishUrl());
// ((MainActivity) context).openFragment(PublishFormFragment.class, true, NavMenuItem.ID_ITEM_NEW_PUBLISH, params);
}
}
});
} else {
adapter.addItem(item);
}
if (galleryGrid.getAdapter() == null) {
galleryGrid.setAdapter(adapter);
}
Helper.setViewVisibility(loading, adapter == null || adapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
}
}
@Override
public void onAllItemsLoaded(List<GalleryItem> items) {
if (context != null) {
if (adapter == null) {
adapter = new GalleryGridAdapter(items, context);
} else {
adapter.addItems(items);
}
if (galleryGrid.getAdapter() == null) {
galleryGrid.setAdapter(adapter);
}
}
checkNoVideosLoaded();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations