mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43:15 +00:00
WIP
This commit is contained in:
parent
8ad3150f33
commit
cb662fe1ff
|
@ -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<Page> 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<Page> pages = documentDetail.getPages();
|
||||
viewerBodyAdapter.setPages(pages);
|
||||
getActivity().runOnUiThread(() -> {
|
||||
viewerBodyAdapter.notifyItemRangeChanged(0, pages.size());
|
||||
});
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
|
@ -17,12 +17,16 @@ public class ViewerBodyAdapter extends RecyclerView.Adapter<ViewerBodyAdapter.Vi
|
|||
|
||||
ArrayList<Page> pages;
|
||||
|
||||
public ViewerBodyAdapter(ArrayList<Page> pages){
|
||||
ItemClickListener listener;
|
||||
|
||||
public ViewerBodyAdapter(ArrayList<Page> 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<Page> pages){
|
||||
|
@ -40,6 +44,9 @@ public class ViewerBodyAdapter extends RecyclerView.Adapter<ViewerBodyAdapter.Vi
|
|||
public void onBindViewHolder(@NonNull ViewerBodyAdapter.ViewHolder holder, int position) {
|
||||
Bitmap bitmap = pages.get(position).getBitmap();
|
||||
holder.image.setImageBitmap(bitmap);
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user