Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Reader 2
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 Reader 2
Commits
6638b4f8
Commit
6638b4f8
authored
Oct 28, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
84c1ced5
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
102 additions
and
21 deletions
+102
-21
DocumentAdapter.kt
.../main/java/com/base/pdfreader2/ui/main/DocumentAdapter.kt
+2
-0
DocumentPresenter.kt
...ain/java/com/base/pdfreader2/ui/main/DocumentPresenter.kt
+23
-13
PdfActivity.kt
app/src/main/java/com/base/pdfreader2/ui/pdf/PdfActivity.kt
+1
-1
PdfLoadingActivity.kt
...ain/java/com/base/pdfreader2/ui/pdf/PdfLoadingActivity.kt
+4
-0
PdfMergeActivity.kt
.../main/java/com/base/pdfreader2/ui/pdf/PdfMergeActivity.kt
+1
-0
PdfSelectActivity.kt
...main/java/com/base/pdfreader2/ui/pdf/PdfSelectActivity.kt
+38
-5
activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-1
activity_pdf.xml
app/src/main/res/layout/activity_pdf.xml
+2
-1
activity_pdf_select.xml
app/src/main/res/layout/activity_pdf_select.xml
+29
-0
item_document.xml
app/src/main/res/layout/item_document.xml
+1
-0
sousuo_b.png
app/src/main/res/mipmap-xxhdpi/sousuo_b.png
+0
-0
No files found.
app/src/main/java/com/base/pdfreader2/ui/main/DocumentAdapter.kt
View file @
6638b4f8
...
...
@@ -16,6 +16,7 @@ import com.base.pdfreader2.databinding.ItemAdBinding
import
com.base.pdfreader2.databinding.ItemDocumentBinding
import
com.base.pdfreader2.utils.KotlinExt.toFormatSize
import
com.base.pdfreader2.utils.KotlinExt.toFormatTime
import
com.base.pdfreader2.utils.LogEx
import
com.base.pdfreader2.utils.XmlEx.inflate
import
com.chad.library.adapter4.BaseQuickAdapter
import
java.io.File
...
...
@@ -46,6 +47,7 @@ class DocumentAdapter() : BaseQuickAdapter<DocumentBean, DocumentAdapter.Documen
binding
.
tvTime
.
text
=
file
.
lastModified
().
toFormatTime
()
binding
.
tvSize
.
text
=
file
.
length
().
toFormatSize
()
}
LogEx
.
logDebug
(
TAG
,
"uiType=${item.uiType}"
)
when
(
item
.
uiType
)
{
0
->
{
//首页
binding
.
flSelect
.
visibility
=
View
.
GONE
...
...
app/src/main/java/com/base/pdfreader2/ui/main/DocumentPresenter.kt
View file @
6638b4f8
...
...
@@ -73,7 +73,7 @@ class DocumentPresenter(
*/
fun
getRecentDocument
(
type
:
String
):
List
<
DocumentBean
>
{
val
recentList
=
SpStringUtils
.
getSpStringList
(
LAST_VIEW_KEY
)
val
list
=
getAllDocument
(
type
,
false
)
val
list
=
getAllDocument
(
type
,
false
)
list
.
forEach
{
recentFilter
(
recentList
,
it
)
}
return
list
.
filter
{
it
.
lastViewTime
!=
0L
}.
sortedByDescending
{
it
.
lastViewTime
}
}
...
...
@@ -98,43 +98,53 @@ class DocumentPresenter(
return
list
.
filter
{
it
.
isBookmarked
}
}
fun
getAllPdfDataRefresh
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
,
adapter
:
DocumentAdapter
,
progressBar
:
ProgressBar
)
{
fun
getAllPdfDataRefresh
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
,
uiType
:
Int
,
uiAction
:
(
list
:
List
<
DocumentBean
>)
->
Unit
)
{
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
val
list
=
getPdfData
()
list
.
map
{
it
.
uiType
=
=
1
}
list
.
map
{
it
.
uiType
=
uiType
}
launch
(
Dispatchers
.
Main
)
{
adapter
.
submitList
(
list
)
progressBar
.
visibility
=
View
.
GONE
uiAction
.
invoke
(
list
)
}
}
}
fun
getUnLockData
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
,
adapter
:
DocumentAdapter
,
progressBar
:
ProgressBar
)
{
fun
getUnLockData
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
,
uiType
:
Int
,
uiAction
:
(
list
:
List
<
DocumentBean
>)
->
Unit
)
{
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
val
documentList
=
getPdfData
()
documentList
.
forEach
{
it
.
state
=
context
.
checkPdfEncryption
(
it
.
path
)
it
.
uiType
=
3
it
.
uiType
=
uiType
}
val
list
=
documentList
.
filter
{
it
.
state
==
0
}
launch
(
Dispatchers
.
Main
)
{
adapter
.
submitList
(
list
)
progressBar
.
visibility
=
View
.
GONE
uiAction
.
invoke
(
list
)
}
}
}
fun
getLockData
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
,
adapter
:
DocumentAdapter
,
progressBar
:
ProgressBar
)
{
fun
getLockData
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
,
uiType
:
Int
,
uiAction
:
(
list
:
List
<
DocumentBean
>)
->
Unit
)
{
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
val
documentList
=
getPdfData
()
documentList
.
forEach
{
it
.
state
=
context
.
checkPdfEncryption
(
it
.
path
)
it
.
uiType
=
3
it
.
uiType
=
uiType
}
val
list
=
documentList
.
filter
{
it
.
state
==
1
}
launch
(
Dispatchers
.
Main
)
{
adapter
.
submitList
(
list
)
progressBar
.
visibility
=
View
.
GONE
uiAction
.
invoke
(
list
)
}
}
}
...
...
app/src/main/java/com/base/pdfreader2/ui/pdf/PdfActivity.kt
View file @
6638b4f8
...
...
@@ -93,7 +93,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
while
(
isActive
)
{
binding
.
progressBar
.
progress
+=
2
delay
(
150
)
if
(
binding
.
progressBar
.
progress
>=
Random
.
nextInt
(
30
,
40
))
{
if
(
binding
.
progressBar
.
progress
>=
Random
.
nextInt
(
25
,
40
))
{
binding
.
flLoading
.
visibility
=
View
.
GONE
cancel
()
}
...
...
app/src/main/java/com/base/pdfreader2/ui/pdf/PdfLoadingActivity.kt
View file @
6638b4f8
...
...
@@ -57,6 +57,10 @@ class PdfLoadingActivity : BaseActivity<ActivityPdfLoadingBinding>() {
}
override
fun
initView
()
{
if
(
checkNeedRecreate
(
MyApplication
.
pdfLoadingLanguage
))
{
return
}
pdfPresenter
=
PdfPresenter
(
this
)
initSpPa
()
pdfPresenter
.
password
=
pwd
...
...
app/src/main/java/com/base/pdfreader2/ui/pdf/PdfMergeActivity.kt
View file @
6638b4f8
...
...
@@ -61,6 +61,7 @@ class PdfMergeActivity : BaseActivity<ActivityPdfMergeBinding>() {
putExtra
(
"doWhat"
,
DO_MERGE_PDF
)
putExtra
(
"newPath"
,
pdfPresenter
.
createNewPdfPath
(
name
))
})
finish
()
})
}
...
...
app/src/main/java/com/base/pdfreader2/ui/pdf/PdfSelectActivity.kt
View file @
6638b4f8
...
...
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import
android.content.Intent
import
android.view.View
import
androidx.activity.addCallback
import
androidx.core.view.isVisible
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfreader2.R
import
com.base.pdfreader2.ads.AdmobHelper
...
...
@@ -12,6 +13,7 @@ import com.base.pdfreader2.bean.ConstObject.DO_LOCK_PDF
import
com.base.pdfreader2.bean.ConstObject.DO_MERGE_PDF
import
com.base.pdfreader2.bean.ConstObject.DO_SPLIT_PDF
import
com.base.pdfreader2.bean.ConstObject.DO_UNLOCK_PDF
import
com.base.pdfreader2.bean.DocumentBean
import
com.base.pdfreader2.databinding.ActivityPdfSelectBinding
import
com.base.pdfreader2.helper.BaseActivity
import
com.base.pdfreader2.helper.MyApplication
...
...
@@ -40,8 +42,16 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
}
}
override
fun
initView
()
{
if
(
checkNeedRecreate
(
MyApplication
.
pdfSelectLanguage
))
{
return
}
doWhat
=
intent
.
extras
?.
getString
(
"doWhat"
,
""
)
?:
""
LogEx
.
logDebug
(
TAG
,
"doWhat=$doWhat"
)
documentPresenter
=
DocumentPresenter
(
this
)
initAdapter
()
...
...
@@ -50,32 +60,52 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
DO_SPLIT_PDF
->
{
binding
.
tvBtnNext
.
visibility
=
View
.
GONE
binding
.
tvSelectTip
.
text
=
getString
(
R
.
string
.
select_a_project
)
documentPresenter
.
getAllPdfDataRefresh
(
lifecycleScope
,
adapter
,
binding
.
progressBar
)
documentPresenter
.
getAllPdfDataRefresh
(
lifecycleScope
,
2
)
{
refreshUI
(
it
)
}
}
DO_MERGE_PDF
->
{
binding
.
tvSelectTip
.
text
=
getString
(
R
.
string
.
select_a_project
)
documentPresenter
.
getAllPdfDataRefresh
(
lifecycleScope
,
adapter
,
binding
.
progressBar
)
documentPresenter
.
getAllPdfDataRefresh
(
lifecycleScope
,
1
)
{
refreshUI
(
it
)
}
}
DO_LOCK_PDF
->
{
binding
.
tvBtnNext
.
visibility
=
View
.
GONE
binding
.
tvSelectTip
.
text
=
getString
(
R
.
string
.
select_a_project
)
documentPresenter
.
getUnLockData
(
lifecycleScope
,
adapter
,
binding
.
progressBar
)
documentPresenter
.
getUnLockData
(
lifecycleScope
,
3
)
{
refreshUI
(
it
)
}
}
DO_UNLOCK_PDF
->
{
binding
.
tvBtnNext
.
visibility
=
View
.
GONE
binding
.
tvSelectTip
.
text
=
getString
(
R
.
string
.
select_a_project
)
documentPresenter
.
getLockData
(
lifecycleScope
,
adapter
,
binding
.
progressBar
)
documentPresenter
.
getLockData
(
lifecycleScope
,
3
)
{
refreshUI
(
it
)
}
}
}
}
private
fun
refreshUI
(
list
:
List
<
DocumentBean
>)
{
adapter
.
submitList
(
list
)
binding
.
llEmpty
.
isVisible
=
list
.
isEmpty
()
binding
.
progressBar
.
visibility
=
View
.
GONE
}
override
fun
initListener
()
{
super
.
initListener
()
if
(
checkNeedRecreate
(
MyApplication
.
pdfSelectLanguage
))
{
return
}
onBackPressedDispatcher
.
addCallback
{
finishToMain
()
}
...
...
@@ -121,9 +151,11 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
if
(
AdmobHelper
.
canCommonShowAd
())
{
AdmobInterstitialUtils
.
showInterstitialAd
(
this
)
{
flag
->
adapter
.
remove
(
it
)
binding
.
llEmpty
.
isVisible
=
adapter
.
items
.
isEmpty
()
}
}
else
{
adapter
.
remove
(
it
)
binding
.
llEmpty
.
isVisible
=
adapter
.
items
.
isEmpty
()
}
})
}
...
...
@@ -132,9 +164,11 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
if
(
AdmobHelper
.
canCommonShowAd
())
{
AdmobInterstitialUtils
.
showInterstitialAd
(
this
)
{
flag
->
adapter
.
remove
(
it
)
binding
.
llEmpty
.
isVisible
=
adapter
.
items
.
isEmpty
()
}
}
else
{
adapter
.
remove
(
it
)
binding
.
llEmpty
.
isVisible
=
adapter
.
items
.
isEmpty
()
}
})
}
...
...
@@ -154,5 +188,4 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
}
}
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
6638b4f8
...
...
@@ -27,7 +27,7 @@
android:id=
"@+id/cl_top"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"
@color/white
"
>
android:background=
"
#DE202A
"
>
<FrameLayout
android:id=
"@+id/fl_fanhui"
...
...
app/src/main/res/layout/activity_pdf.xml
View file @
6638b4f8
...
...
@@ -96,7 +96,8 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/h_sousuo"
android:backgroundTint=
"@color/black"
android:src=
"@mipmap/sousuo_b"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_more"
app:layout_constraintTop_toTopOf=
"parent"
...
...
app/src/main/res/layout/activity_pdf_select.xml
View file @
6638b4f8
...
...
@@ -68,6 +68,35 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
/>
<LinearLayout
android:id=
"@+id/ll_empty"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_marginBottom=
"60dp"
android:orientation=
"vertical"
android:visibility=
"gone"
tools:ignore=
"UseCompoundDrawables,UselessParent"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@mipmap/empty"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"20dp"
android:text=
"Empty"
android:textColor=
"#B1B4B9"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</FrameLayout>
<TextView
...
...
app/src/main/res/layout/item_document.xml
View file @
6638b4f8
...
...
@@ -153,6 +153,7 @@
</LinearLayout>
<View
android:layout_width=
"0dp"
android:layout_height=
"1px"
...
...
app/src/main/res/mipmap-xxhdpi/sousuo_b.png
0 → 100644
View file @
6638b4f8
2.84 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