123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /**
- * 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.pdfviewer.home;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.provider.DocumentsContract;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import androidx.annotation.NonNull;
- import androidx.annotation.Nullable;
- import androidx.fragment.app.Fragment;
- import androidx.recyclerview.widget.LinearLayoutManager;
- import com.compdfkit.pdfviewer.MainActivity;
- import com.compdfkit.pdfviewer.R;
- import com.compdfkit.pdfviewer.databinding.FragmentHomeBinding;
- import com.compdfkit.pdfviewer.home.datas.FunDatas;
- import com.compdfkit.ui.utils.CPDFCommomUtils;
- public class HomeFunFragment extends Fragment {
- private CHomeFunListAdapter funListAdapter;
- private FragmentHomeBinding binding;
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- binding = FragmentHomeBinding.inflate(inflater, container, false);
- return binding.getRoot();
- }
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- initFunList();
- }
- private void initFunList() {
- funListAdapter = new CHomeFunListAdapter();
- funListAdapter.setList(FunDatas.getFunList(getContext()));
- binding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- binding.recyclerView.setAdapter(funListAdapter);
- funListAdapter.setOnItemClickListener((adapter, view, position) -> {
- HomeFunBean homeFunBean = funListAdapter.list.get(position);
- if (homeFunBean.isHead()) {
- return;
- }
- switch (homeFunBean.getType()) {
- case SamplePDF:
- Intent intent = new Intent(getContext(), MainActivity.class);
- intent.putExtra(MainActivity.EXTRA_FILE_PATH, homeFunBean.getFilePath());
- startActivity(intent);
- break;
- case Viewer:
- case Annotations:
- case Forms:
- case Signature:
- case DocumentEditor:
- case ContentEditor:
- case Security:
- case Watermark:
- showDocumentListFragment(homeFunBean.getType());
- break;
- case Redaction:
- CPDFCommomUtils.gotoWebsite(getContext(), getString(R.string.tools_compdf_security_url), null);
- break;
- case CompareDocuments:
- CPDFCommomUtils.gotoWebsite(getContext(), getString(R.string.tools_compdf_compare_url), null);
- break;
- case Conversion:
- CPDFCommomUtils.gotoWebsite(getContext(), getString(R.string.tools_compdf_conversion_url), null);
- break;
- case Compress:
- CPDFCommomUtils.gotoWebsite(getContext(), getString(R.string.tools_contact_sales_url), null);
- break;
- case Measurement:
- CPDFCommomUtils.gotoWebsite(getContext(), getString(R.string.tools_contact_sales_url), null);
- break;
- default:
- break;
- }
- });
- }
- private void showDocumentListFragment(HomeFunBean.FunType funType) {
- getParentFragmentManager()
- .beginTransaction()
- .addToBackStack(null)
- .setCustomAnimations(R.anim.tools_slide_in_right, R.anim.tools_slide_out_left, R.anim.tools_slide_in_left, R.anim.tools_slide_out_right)
- .replace(R.id.fragment_content, DocumentListFragment.newInstance(funType), funType.name() + "_DocumentListFragment")
- .commit();
- }
- }
|