diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java index 246c9a45..e319c02c 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java @@ -10,8 +10,10 @@ import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import java.util.ArrayList; +import java.util.concurrent.CompletableFuture; import javax.inject.Inject; @@ -61,16 +63,21 @@ public class ComponentViewerTopFragment extends Fragment { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_component_viewer_top, container, false); - DocumentDetail documentDetail = document.getDocument(documentId); - - ArrayList documentPages = new ArrayList<>(); - documentPages = documentDetail.getPages(); - RecyclerView recyclerView = view.findViewById(R.id.body_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(documentPages); + ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> { + Toast.makeText(getContext(), fileName, Toast.LENGTH_SHORT).show(); + }); recyclerView.setAdapter(viewerBodyAdapter); + document.getDocument(documentId).thenAccept(documentDetail -> { + ArrayList pages = documentDetail.getPages(); + viewerBodyAdapter.setPages(pages); + getActivity().runOnUiThread(() -> { + viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); + }); + }); + return view; } } \ No newline at end of file diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyAdapter.java index 60fe5790..8a430f96 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerBodyAdapter.java @@ -17,12 +17,16 @@ public class ViewerBodyAdapter extends RecyclerView.Adapter pages; - public ViewerBodyAdapter(ArrayList pages){ + ItemClickListener listener; + + public ViewerBodyAdapter(ArrayList pages, ItemClickListener listener){ this.pages = pages; + this.listener = listener; } - public ViewerBodyAdapter(){ - + public ViewerBodyAdapter(ItemClickListener listener){ + this.pages = new ArrayList<>(); + this.listener = listener; } public void setPages(ArrayList pages){ @@ -40,6 +44,9 @@ public class ViewerBodyAdapter extends RecyclerView.Adapter { + + }); } @Override