|
@@ -0,0 +1,101 @@
|
|
|
|
+/**
|
|
|
|
+ * Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
|
|
|
|
+ * <p>
|
|
|
|
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
|
|
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
|
|
|
|
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
|
|
|
|
+ * This notice may not be removed from this file.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+package com.compdfkit.tools.pdfbota.pdfoutline;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import android.os.Bundle;
|
|
|
|
+import android.view.LayoutInflater;
|
|
|
|
+import android.view.View;
|
|
|
|
+import android.view.ViewGroup;
|
|
|
|
+
|
|
|
|
+import androidx.annotation.NonNull;
|
|
|
|
+import androidx.annotation.Nullable;
|
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
+
|
|
|
|
+import com.compdfkit.tools.R;
|
|
|
|
+import com.compdfkit.tools.pdfbota.pdfoutline.adapter.COutlineListAdapter;
|
|
|
|
+import com.compdfkit.tools.pdfbota.pdfoutline.bean.COutlineData;
|
|
|
|
+import com.compdfkit.tools.pdfbota.pdfoutline.interfaces.OnOutlineClickListener;
|
|
|
|
+import com.compdfkit.tools.utils.dialog.DialogFragmentUtil;
|
|
|
|
+import com.compdfkit.tools.utils.view.CToolBar;
|
|
|
|
+import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|
|
|
+import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+
|
|
|
|
+public class CPDFOutlineDialogFragment extends BottomSheetDialogFragment {
|
|
|
|
+
|
|
|
|
+ private RecyclerView rvOutlineRecyclerView;
|
|
|
|
+
|
|
|
|
+ private CToolBar toolBar;
|
|
|
|
+
|
|
|
|
+ private COutlineListAdapter outlineListAdapter;
|
|
|
|
+
|
|
|
|
+ private static final String EXTRA_OUTLINE_LIST = "outlineList";
|
|
|
|
+
|
|
|
|
+ private OnOutlineClickListener outlineCallback;
|
|
|
|
+
|
|
|
|
+ public static CPDFOutlineDialogFragment showCPDFOutlineDialogFragment(ArrayList<COutlineData> outlineList){
|
|
|
|
+ CPDFOutlineDialogFragment dialogFragment = new CPDFOutlineDialogFragment();
|
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
|
+ bundle.putParcelableArrayList(EXTRA_OUTLINE_LIST, outlineList);
|
|
|
|
+ dialogFragment.setArguments(bundle);
|
|
|
|
+ return dialogFragment;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onStart() {
|
|
|
|
+ super.onStart();
|
|
|
|
+ BottomSheetBehavior<View> behavior = BottomSheetBehavior.from((View) getView().getParent());
|
|
|
|
+ DialogFragmentUtil.setBottomSheetDialogFragmentFullScreen(getDialog(), behavior);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nullable
|
|
|
|
+ @Override
|
|
|
|
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
+ View rootView = inflater.inflate(R.layout.tools_cpdf_outline_dialog_fragment, container, false);
|
|
|
|
+ rvOutlineRecyclerView = rootView.findViewById(R.id.rv_outline);
|
|
|
|
+ toolBar = rootView.findViewById(R.id.tool_bar);
|
|
|
|
+ toolBar.setBackBtnClickListener(v -> {
|
|
|
|
+ dismiss();
|
|
|
|
+ });
|
|
|
|
+ return rootView;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
|
|
+ outlineListAdapter = new COutlineListAdapter();
|
|
|
|
+ outlineListAdapter.setOutlineClickListener(outlineCallback);
|
|
|
|
+ rvOutlineRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
|
|
+ rvOutlineRecyclerView.setAdapter(outlineListAdapter);
|
|
|
|
+ outlineListAdapter.setList(getOutlineData());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private ArrayList<COutlineData> getOutlineData(){
|
|
|
|
+ ArrayList<COutlineData> outlineList = new ArrayList<>();
|
|
|
|
+ if (getArguments() == null){
|
|
|
|
+ return outlineList;
|
|
|
|
+ }
|
|
|
|
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
|
|
|
|
+ outlineList = getArguments().getParcelableArrayList(EXTRA_OUTLINE_LIST, COutlineData.class);
|
|
|
|
+ }else {
|
|
|
|
+ outlineList = getArguments().getParcelableArrayList(EXTRA_OUTLINE_LIST);
|
|
|
|
+ }
|
|
|
|
+ return outlineList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setOutlineClickListener(OnOutlineClickListener outlineClickListener){
|
|
|
|
+ this.outlineCallback = outlineClickListener;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|