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
44b02ca7
Commit
44b02ca7
authored
Oct 28, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
abcf35a2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
232 additions
and
72 deletions
+232
-72
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-1
DocumentAdapter.kt
.../main/java/com/base/pdfreader2/ui/main/DocumentAdapter.kt
+2
-1
DocumentFragment.kt
...main/java/com/base/pdfreader2/ui/main/DocumentFragment.kt
+37
-10
DocumentPresenter.kt
...ain/java/com/base/pdfreader2/ui/main/DocumentPresenter.kt
+12
-8
bg_stroke_ffffff_10.xml
app/src/main/res/drawable/bg_stroke_ffffff_10.xml
+9
-0
fragment_document.xml
app/src/main/res/layout/fragment_document.xml
+57
-44
fragment_tool.xml
app/src/main/res/layout/fragment_tool.xml
+9
-8
layout_admob_document.xml
app/src/main/res/layout/layout_admob_document.xml
+103
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
44b02ca7
...
...
@@ -27,7 +27,9 @@
<activity
android:name=
".ui.splash.SplashActivity"
android:exported=
"true"
android:launchMode=
"singleTask"
>
android:launchMode=
"singleTask"
android:screenOrientation=
"portrait"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
app/src/main/java/com/base/pdfreader2/ui/main/DocumentAdapter.kt
View file @
44b02ca7
...
...
@@ -6,6 +6,7 @@ import android.view.View
import
android.view.ViewGroup
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.pdfreader2.R
import
com.base.pdfreader2.ads.admob.AdmobNativeUtils
import
com.base.pdfreader2.bean.DocumentBean
import
com.base.pdfreader2.bean.DocumentBean.Companion.TYPE_EXCEL
import
com.base.pdfreader2.bean.DocumentBean.Companion.TYPE_PDF
...
...
@@ -35,7 +36,7 @@ class DocumentAdapter() : BaseQuickAdapter<DocumentBean, DocumentAdapter.Documen
if
(
item
==
null
)
return
if
(
item
.
isAd
)
{
val
binding
=
ItemAdBinding
.
bind
(
holder
.
itemView
)
// AdmobNativeUtils.showNativeAd(activity
, binding.flAd, R.layout.layout_admob_document)
AdmobNativeUtils
.
showNativeAd
(
null
,
binding
.
flAd
,
R
.
layout
.
layout_admob_document
)
}
else
{
val
binding
=
ItemDocumentBinding
.
bind
(
holder
.
itemView
)
changeIcon
(
item
,
binding
)
...
...
app/src/main/java/com/base/pdfreader2/ui/main/DocumentFragment.kt
View file @
44b02ca7
...
...
@@ -3,11 +3,14 @@ package com.base.pdfreader2.ui.main
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Intent
import
android.view.View
import
androidx.core.view.isVisible
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfreader2.R
import
com.base.pdfreader2.ads.AdmobHelper
import
com.base.pdfreader2.ads.AdmobHelper.lastOpenDocumentShowAd
import
com.base.pdfreader2.ads.admob.AdmobInterstitialUtils
import
com.base.pdfreader2.ads.admob.AdmobNativeUtils
import
com.base.pdfreader2.bean.ConstObject
import
com.base.pdfreader2.bean.DocumentBean
import
com.base.pdfreader2.bean.DocumentBean.Companion.TYPE_EXCEL
...
...
@@ -35,7 +38,7 @@ import java.util.Locale
class
DocumentFragment
()
:
BaseFragment
<
FragmentDocumentBinding
>()
{
private
val
TAG
=
"DocumentFragment"
var
type
=
TYPE_PDF
var
type
=
TYPE_PDF
private
lateinit
var
adapter
:
DocumentAdapter
private
lateinit
var
documentPresenter
:
DocumentPresenter
...
...
@@ -103,6 +106,18 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>() {
refreshData
()
}
private
fun
getRvAdList
(
list
:
List
<
DocumentBean
>):
List
<
DocumentBean
>
{
val
flag
=
AdmobHelper
.
isShowRvNativeAd
()
if
(
flag
)
{
val
arrayList
=
arrayListOf
<
DocumentBean
>()
arrayList
.
addAll
(
list
)
arrayList
.
add
(
1
,
DocumentBean
().
apply
{
isAd
=
true
})
return
arrayList
}
return
list
}
fun
refreshData
()
{
if
(
isInitialized
&&
!
isHidden
&&
isVisible
)
{
val
mainActivity
=
(
requireActivity
()
as
MainActivity
?)
...
...
@@ -118,27 +133,39 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>() {
private
fun
refreshRecentData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
list
=
documentPresenter
.
getRecentDocument
(
type
)
launch
(
Dispatchers
.
Main
)
{
binding
.
llEmpty
.
isVisible
=
list
.
isEmpty
()
adapter
.
submitList
(
list
)
binding
.
swipeRefreshLayout
.
isRefreshing
=
false
changeRvUI
(
list
)
}
}
private
fun
refreshBookmarkData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
list
=
documentPresenter
.
getBookmarkDocument
(
type
)
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
binding
.
llEmpty
.
isVisible
=
list
.
isEmpty
()
binding
.
swipeRefreshLayout
.
isRefreshing
=
false
adapter
.
submitList
(
documentPresenter
.
sortByMode
(
list
))
changeRvUI
(
list
)
}
}
fun
changeRvUI
(
list
:
List
<
DocumentBean
>)
{
if
(
list
.
isEmpty
())
{
binding
.
llEmpty
.
visibility
=
View
.
VISIBLE
binding
.
swipeRefreshLayout
.
visibility
=
View
.
GONE
val
flag
=
AdmobHelper
.
isShowRvNativeAd
()
if
(
flag
)
{
binding
.
flAd
.
visibility
=
View
.
VISIBLE
AdmobNativeUtils
.
showNativeAd
(
requireActivity
(),
binding
.
flAd
,
R
.
layout
.
layout_admob_document
)
}
}
else
{
binding
.
llEmpty
.
visibility
=
View
.
GONE
binding
.
flAd
.
visibility
=
View
.
GONE
binding
.
swipeRefreshLayout
.
visibility
=
View
.
VISIBLE
adapter
.
submitList
(
getRvAdList
(
list
))
}
binding
.
swipeRefreshLayout
.
isRefreshing
=
false
}
private
fun
refreshAllData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
list
=
documentPresenter
.
getAllDocument
(
type
)
launch
(
Dispatchers
.
Main
)
{
binding
.
llEmpty
.
isVisible
=
list
.
isEmpty
()
binding
.
swipeRefreshLayout
.
isRefreshing
=
false
adapter
.
submitList
(
documentPresenter
.
sortByMode
(
list
))
changeRvUI
(
list
)
}
}
...
...
app/src/main/java/com/base/pdfreader2/ui/main/DocumentPresenter.kt
View file @
44b02ca7
...
...
@@ -36,14 +36,14 @@ class DocumentPresenter(
/**
* 获取所有的
*/
fun
getAllDocument
(
type
:
String
):
Mutable
List
<
DocumentBean
>
{
fun
getAllDocument
(
type
:
String
,
needSort
:
Boolean
=
true
):
List
<
DocumentBean
>
{
context
.
upDateDemoStore
()
if
(!
ConstObject
.
haveSaveDemo
)
{
context
.
saveAssetsFile
()
ConstObject
.
haveSaveDemo
=
true
}
when
(
type
)
{
val
list
=
when
(
type
)
{
TYPE_PDF
->
{
return
getPdfData
()
}
...
...
@@ -60,8 +60,12 @@ class DocumentPresenter(
return
getPptData
()
}
else
->
listOf
<
DocumentBean
>()
}
return
mutableListOf
()
if
(
needSort
)
{
return
sortByMode
(
list
)
}
return
list
}
/**
...
...
@@ -69,7 +73,7 @@ class DocumentPresenter(
*/
fun
getRecentDocument
(
type
:
String
):
List
<
DocumentBean
>
{
val
recentList
=
SpStringUtils
.
getSpStringList
(
LAST_VIEW_KEY
)
val
list
=
getAllDocument
(
type
)
val
list
=
getAllDocument
(
type
,
false
)
list
.
forEach
{
recentFilter
(
recentList
,
it
)
}
return
list
.
filter
{
it
.
lastViewTime
!=
0L
}.
sortedByDescending
{
it
.
lastViewTime
}
}
...
...
@@ -136,7 +140,7 @@ class DocumentPresenter(
}
private
fun
getPdfData
():
Mutable
List
<
DocumentBean
>
{
private
fun
getPdfData
():
List
<
DocumentBean
>
{
val
demoDocumentBean
=
DocumentBean
()
demoDocumentBean
.
type
=
TYPE_PDF
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
...
...
@@ -161,7 +165,7 @@ class DocumentPresenter(
return
new
}
private
fun
getWordData
():
Mutable
List
<
DocumentBean
>
{
private
fun
getWordData
():
List
<
DocumentBean
>
{
val
demoDocumentBean
=
DocumentBean
()
demoDocumentBean
.
type
=
TYPE_WORD
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
...
...
@@ -185,7 +189,7 @@ class DocumentPresenter(
return
new
}
private
fun
getExcelData
():
Mutable
List
<
DocumentBean
>
{
private
fun
getExcelData
():
List
<
DocumentBean
>
{
val
demoDocumentBean
=
DocumentBean
()
demoDocumentBean
.
type
=
TYPE_EXCEL
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
...
...
@@ -208,7 +212,7 @@ class DocumentPresenter(
return
new
}
private
fun
getPptData
():
Mutable
List
<
DocumentBean
>
{
private
fun
getPptData
():
List
<
DocumentBean
>
{
val
demoDocumentBean
=
DocumentBean
()
demoDocumentBean
.
type
=
TYPE_PPT
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
...
...
app/src/main/res/drawable/bg_stroke_ffffff_10.xml
0 → 100644
View file @
44b02ca7
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<stroke
android:width=
"0.5dp"
android:color=
"#E5E5E5"
/>
<solid
android:color=
"@color/white"
/>
<corners
android:radius=
"10dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/fragment_document.xml
View file @
44b02ca7
...
...
@@ -6,55 +6,68 @@
android:layout_height=
"match_parent"
tools:context=
".ui.main.DocumentFragment"
>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id=
"@+id/swipeRefreshLayout"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"
match_par
ent"
android:
background=
"@color/white
"
>
android:layout_height=
"
wrap_cont
ent"
android:
orientation=
"vertical
"
>
<FrameLayout
android:id=
"@+id/fl_ad"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id=
"@+id/swipeRefreshLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv"
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
/>
<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=
"@string/empty"
android:textColor=
"#B1B4B9"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
android:layout_height=
"wrap_content"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
/>
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
<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=
"@string/empty"
android:textColor=
"#B1B4B9"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_tool.xml
View file @
44b02ca7
...
...
@@ -12,6 +12,7 @@
android:id=
"@+id/cl_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:layout_marginTop=
"36dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
...
...
@@ -309,7 +310,7 @@
<LinearLayout
android:id=
"@+id/ll_manager"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:orientation=
"vertical"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -341,7 +342,7 @@
<LinearLayout
android:id=
"@+id/ll_scan"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:layout_marginTop=
"8dp"
android:orientation=
"vertical"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
@@ -374,7 +375,7 @@
<LinearLayout
android:id=
"@+id/ll_image_pdf"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:layout_marginTop=
"8dp"
android:orientation=
"vertical"
app:layout_constraintEnd_toEndOf=
"@id/ll_manager"
...
...
@@ -408,7 +409,7 @@
<LinearLayout
android:id=
"@+id/ll_process"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:layout_marginEnd=
"16dp"
android:orientation=
"vertical"
app:layout_constraintEnd_toStartOf=
"@+id/ll_manager"
...
...
@@ -440,7 +441,7 @@
<LinearLayout
android:id=
"@+id/ll_split"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:layout_marginEnd=
"16dp"
android:orientation=
"vertical"
app:layout_constraintEnd_toStartOf=
"@id/ll_scan"
...
...
@@ -472,7 +473,7 @@
<LinearLayout
android:id=
"@+id/ll_lock"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:layout_marginStart=
"16dp"
android:orientation=
"vertical"
app:layout_constraintStart_toEndOf=
"@id/ll_scan"
...
...
@@ -504,7 +505,7 @@
<LinearLayout
android:id=
"@+id/ll_merge"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:layout_marginStart=
"16dp"
android:orientation=
"vertical"
app:layout_constraintStart_toEndOf=
"@id/ll_manager"
...
...
@@ -536,7 +537,7 @@
<LinearLayout
android:id=
"@+id/ll_unlock"
android:layout_width=
"110dp"
android:layout_height=
"
8
6dp"
android:layout_height=
"
9
6dp"
android:layout_marginEnd=
"16dp"
android:orientation=
"vertical"
app:layout_constraintEnd_toStartOf=
"@id/ll_image_pdf"
...
...
app/src/main/res/layout/layout_admob_document.xml
0 → 100644
View file @
44b02ca7
<com.google.android.gms.ads.nativead.NativeAdView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"#F4F5FA"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"99dp"
android:layout_gravity=
"center"
android:layout_marginHorizontal=
"10dp"
android:layout_marginVertical=
"10dp"
android:background=
"@drawable/bg_stroke_ffffff_10"
android:baselineAligned=
"false"
tools:ignore=
"UselessParent"
>
<com.google.android.gms.ads.nativead.MediaView
android:id=
"@+id/ad_media"
android:layout_width=
"86dp"
android:layout_height=
"64dp"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"8dp"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"8dp"
android:layout_weight=
"1"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/ad_headline"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:maxLines=
"2"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textSize=
"13sp"
android:textStyle=
"bold"
tools:text=
"Your Dlgital Bible Guide Hold The Complete Bible In Your Hand a"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:paddingVertical=
"5dp"
>
<ImageView
android:id=
"@+id/ad_app_icon"
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:layout_gravity=
"center_vertical"
tools:ignore=
"ContentDescription"
/>
<TextView
android:id=
"@+id/ad_body"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:maxLines=
"2"
android:singleLine=
"true"
android:textColor=
"#999999"
android:textSize=
"13sp"
tools:text=
"wuyunbooster"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:text=
"| AD"
android:textColor=
"#999999"
android:textSize=
"13sp"
tools:ignore=
"HardcodedText"
/>
<androidx.appcompat.widget.AppCompatButton
android:id=
"@+id/ad_call_to_action"
android:layout_width=
"82dp"
android:layout_height=
"30dp"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"12dp"
android:background=
"@drawable/bg_00b8de_10"
android:gravity=
"center"
android:maxHeight=
"28dp"
android:textColor=
"@color/white"
android:textSize=
"15sp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</com.google.android.gms.ads.nativead.NativeAdView>
\ No newline at end of file
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