Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
PDF Viewer Scanner White
Commits
9991f275
Commit
9991f275
authored
Oct 10, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
915db78d
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
159 additions
and
125 deletions
+159
-125
DocumentBean.kt
.../java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
+1
-0
PdfSelectActivity.kt
...dfviewerscannerwhite/ui/document/pdf/PdfSelectActivity.kt
+2
-2
DocumentAdapter.kt
...com/base/pdfviewerscannerwhite/ui/main/DocumentAdapter.kt
+101
-100
DocumentFragment.kt
...om/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
+1
-1
DocumentPageFragment.kt
...ase/pdfviewerscannerwhite/ui/main/DocumentPageFragment.kt
+20
-14
DocumentPresenter.kt
...m/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
+1
-1
activity_main2.xml
app/src/main/res/layout/activity_main2.xml
+9
-1
fragment_document_page.xml
app/src/main/res/layout/fragment_document_page.xml
+18
-6
item_ad.xml
app/src/main/res/layout/item_ad.xml
+6
-0
zhanweitu2.png
app/src/main/res/mipmap-xxhdpi/zhanweitu2.png
+0
-0
No files found.
app/src/main/java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
View file @
9991f275
...
...
@@ -13,6 +13,7 @@ data class DocumentBean(
var
state
:
Int
=
-
1
//0正常状态 1 锁定
var
password
:
String
=
""
var
lastViewTime
:
Long
=
0
var
isAd
:
Boolean
=
false
companion
object
{
const
val
TYPE_PDF
=
"type_pdf"
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/pdf/PdfSelectActivity.kt
View file @
9991f275
...
...
@@ -61,7 +61,7 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView
DO_LOCK_PDF
->
{
binding
.
tvBtnNext
.
visibility
=
View
.
GONE
binding
.
tvSelectTip
.
text
=
getString
(
R
.
string
.
select_a_project
)
documentPresenter
.
initUnLo
ad
Data
()
documentPresenter
.
initUnLo
ck
Data
()
}
DO_UNLOCK_PDF
->
{
...
...
@@ -96,7 +96,7 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView
@SuppressLint
(
"StringFormatMatches"
)
private
fun
initAdapter
()
{
adapter
=
DocumentAdapter
()
adapter
=
DocumentAdapter
(
this
)
adapter
.
itemClick
=
{
if
(
doWhat
==
DO_SPLIT_PDF
)
{
startActivity
(
Intent
(
this
,
PdfSplitActivity
::
class
.
java
).
apply
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentAdapter.kt
View file @
9991f275
package
com.base.pdfviewerscannerwhite.ui.main
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PDF
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PPT
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_WORD
import
com.base.pdfviewerscannerwhite.databinding.ItemAdBinding
import
com.base.pdfviewerscannerwhite.databinding.ItemDocumentBinding
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.XmlEx.inflate
import
com.chad.library.adapter4.BaseQuickAdapter
import
java.io.File
import
java.util.concurrent.LinkedBlockingQueue
import
java.util.concurrent.ThreadPoolExecutor
import
java.util.concurrent.TimeUnit
class
DocumentAdapter
:
BaseQuickAdapter
<
DocumentBean
,
DocumentAdapter
.
DocumentViewHolder
>()
{
class
DocumentAdapter
(
val
activity
:
Activity
)
:
BaseQuickAdapter
<
DocumentBean
,
DocumentAdapter
.
DocumentViewHolder
>()
{
private
val
TAG
=
"DocumentAdapter"
inner
class
DocumentViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
var
itemClick
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
bookmarkAction
:
((
addRemove
:
Boolean
,
path
:
String
)
->
Unit
)?
=
null
var
moreAction
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
selectAction
:
((
size
:
Int
)
->
Unit
)?
=
null
var
corePoolSize
=
4
// 核心线程数
var
maximumPoolSize
=
10
// 最大线程数
var
keepAliveTime
:
Long
=
120
// 非核心线程空闲存活时间
var
threadPoolExecutor
=
ThreadPoolExecutor
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
TimeUnit
.
SECONDS
,
LinkedBlockingQueue
()
)
@SuppressLint
(
"SetTextI18n"
)
override
fun
onBindViewHolder
(
holder
:
DocumentViewHolder
,
position
:
Int
,
item
:
DocumentBean
?)
{
if
(
item
==
null
)
return
if
(
item
.
isAd
)
{
val
binding
=
ItemAdBinding
.
bind
(
holder
.
itemView
)
AdmobNativeUtils
.
showNativeAd
(
activity
,
binding
.
flAd
)
}
else
{
val
binding
=
ItemDocumentBinding
.
bind
(
holder
.
itemView
)
if
(
item
.
type
==
TYPE_PDF
)
{
if
(
item
.
state
==
0
){
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_pdfiocn
)
}
if
(
item
.
state
==
1
){
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
suoding
)
}
}
if
(
item
.
type
==
TYPE_WORD
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_wordfiocn
)
}
if
(
item
.
type
==
TYPE_EXCEL
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_exceliocn
)
}
if
(
item
.
type
==
TYPE_PPT
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_pptfiocn
)
}
changeIcon
(
item
,
binding
)
val
file
=
File
(
item
.
path
)
runCatching
{
binding
.
tvName
.
text
=
file
.
name
binding
.
tvInfo
.
text
=
file
.
lastModified
().
toFormatTime
()
+
" "
+
file
.
length
().
toFormatSize
()
}
when
(
item
.
uiType
)
{
0
->
{
//首页
binding
.
flSelect
.
visibility
=
View
.
GONE
...
...
@@ -149,9 +121,38 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
}
}
}
fun
changeIcon
(
item
:
DocumentBean
,
binding
:
ItemDocumentBinding
)
{
if
(
item
.
type
==
TYPE_PDF
)
{
if
(
item
.
state
==
0
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_pdfiocn
)
}
if
(
item
.
state
==
1
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
suoding
)
}
}
if
(
item
.
type
==
TYPE_WORD
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_wordfiocn
)
}
if
(
item
.
type
==
TYPE_EXCEL
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_exceliocn
)
}
if
(
item
.
type
==
TYPE_PPT
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_pptfiocn
)
}
}
override
fun
getItemViewType
(
position
:
Int
,
list
:
List
<
DocumentBean
>):
Int
{
val
item
=
list
[
position
]
return
if
(
item
.
isAd
)
1
else
0
}
override
fun
onCreateViewHolder
(
context
:
Context
,
parent
:
ViewGroup
,
viewType
:
Int
):
DocumentViewHolder
{
return
DocumentViewHolder
(
R
.
layout
.
item_document
.
inflate
(
parent
))
return
if
(
viewType
==
0
)
{
DocumentViewHolder
(
R
.
layout
.
item_document
.
inflate
(
parent
))
}
else
{
DocumentViewHolder
(
R
.
layout
.
item_ad
.
inflate
(
parent
))
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
View file @
9991f275
...
...
@@ -93,7 +93,7 @@ class DocumentFragment(
}
private
fun
initSearchAdapter
()
{
searchAdapter
=
DocumentAdapter
()
searchAdapter
=
DocumentAdapter
(
requireActivity
()
)
binding
.
rvSearch
.
adapter
=
searchAdapter
searchAdapter
.
moreAction
=
{
item
->
currentPage
.
documentMoreAction
.
invoke
(
item
)
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentPageFragment.kt
View file @
9991f275
...
...
@@ -2,9 +2,10 @@ package com.base.pdfviewerscannerwhite.ui.main
import
android.annotation.SuppressLint
import
android.content.Intent
import
android.
util.Log
import
android.
view.View
import
androidx.core.view.isVisible
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_FINAL_MODIFIED
import
com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_NAME_A_Z
...
...
@@ -33,7 +34,6 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
private
val
TAG
=
"DocumentFragment"
var
type
=
TYPE_PDF
var
dataType
:
String
=
""
private
var
documentList
:
ArrayList
<
DocumentBean
>
=
arrayListOf
()
lateinit
var
adapter
:
DocumentAdapter
lateinit
var
documentPresenter
:
DocumentPresenter
...
...
@@ -50,8 +50,6 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
documentPresenter
=
DocumentPresenter
(
requireContext
(),
this
,
type
,
lifecycleScope
)
initAdapter
()
isInitialized
=
true
Log
.
d
(
"glc"
,
"我被调用了setView"
)
}
override
fun
onResume
()
{
...
...
@@ -62,17 +60,32 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
fun
refreshData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
if
(
isInitialized
&&
!
isHidden
)
{
val
list
=
(
requireActivity
()
as
MainActivity
).
mainPresenter
.
getDataByType
(
type
,
dataType
)
(
requireActivity
()
as
MainActivity
).
mainPresenter
.
getDataByType
(
type
,
dataType
)
.
toMutableList
()
val
dataType
=
(
parentFragment
as
DocumentFragment
).
dataType
launch
(
Dispatchers
.
Main
)
{
if
(
dataType
==
ConstObject
.
RECENT_DATA_TYPE
)
{
if
(
list
.
isNotEmpty
())
{
list
.
add
(
1
,
DocumentBean
().
apply
{
isAd
=
true
})
}
adapter
.
submitList
(
list
)
}
else
{
val
sortList
=
sortByMode
(
list
)
adapter
.
submitList
(
sortList
)
val
arrayList
=
arrayListOf
<
DocumentBean
>()
arrayList
.
addAll
(
sortList
)
if
(
arrayList
.
isNotEmpty
())
{
arrayList
.
add
(
1
,
DocumentBean
().
apply
{
isAd
=
true
})
}
adapter
.
submitList
(
arrayList
)
}
binding
.
llEmpty
.
isVisible
=
list
.
isEmpty
()
if
(
list
.
isEmpty
())
{
binding
.
flAd
.
visibility
=
View
.
VISIBLE
AdmobNativeUtils
.
showNativeAd
(
requireActivity
(),
binding
.
flAd
)
}
else
{
binding
.
flAd
.
visibility
=
View
.
GONE
}
}
// Log.d("glc", "加载数据成功:" + type + " list:" + list.size)
}
else
{
...
...
@@ -107,15 +120,8 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
}
override
fun
refreshDocumentRv
(
documentList
:
List
<
DocumentBean
>)
{
binding
.
llEmpty
.
isVisible
=
documentList
.
isEmpty
()
this
.
documentList
.
clear
()
this
.
documentList
.
addAll
(
documentList
)
adapter
.
submitList
(
documentList
)
}
private
fun
initAdapter
()
{
adapter
=
DocumentAdapter
()
adapter
=
DocumentAdapter
(
requireActivity
()
)
adapter
.
bookmarkAction
=
{
addRemove
,
path
->
documentPresenter
.
saveBookmarkChange
(
addRemove
,
path
)
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
View file @
9991f275
...
...
@@ -75,7 +75,7 @@ class DocumentPresenter(
}
fun
initUnLo
ad
Data
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
fun
initUnLo
ck
Data
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
documentList
=
getDocumentBeanList
()
documentList
.
forEach
{
it
.
state
=
PdfBoxUtils
.
checkPdfEncryption
(
it
.
path
)
...
...
app/src/main/res/layout/activity_main2.xml
View file @
9991f275
...
...
@@ -249,7 +249,15 @@
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/ll_bottom"
/>
app:layout_constraintTop_toBottomOf=
"@id/ll_bottom"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/zhanweitu2"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_test"
...
...
app/src/main/res/layout/fragment_document_page.xml
View file @
9991f275
...
...
@@ -6,6 +6,15 @@
android:layout_height=
"match_parent"
tools:context=
".ui.main.DocumentPageFragment"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<FrameLayout
android:id=
"@+id/fl_ad"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv"
...
...
@@ -14,6 +23,9 @@
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem=
"@layout/item_document"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_empty"
android:layout_width=
"wrap_content"
...
...
app/src/main/res/layout/item_ad.xml
0 → 100644
View file @
9991f275
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/fl_ad"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
</FrameLayout>
\ No newline at end of file
app/src/main/res/mipmap-xxhdpi/zhanweitu2.png
0 → 100644
View file @
9991f275
11.6 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment