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
c7a1e38b
Commit
c7a1e38b
authored
Sep 25, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
9fa8260b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
415 additions
and
994 deletions
+415
-994
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+9
-4
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+5
-0
build.gradle
library/build.gradle
+4
-0
DocViewerActivity.kt
...ary/src/main/java/com/cherry/lib/doc/DocViewerActivity.kt
+11
-3
IOffice.java
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
+1
-3
MovieShape.java
...a/com/cherry/lib/doc/office/fc/hslf/model/MovieShape.java
+35
-53
TextRun.java
...java/com/cherry/lib/doc/office/fc/hslf/model/TextRun.java
+190
-320
PGPrintMode.java
...ava/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
+0
-8
PdfPageViewAdapter.kt
...rc/main/java/com/cherry/lib/doc/pdf/PdfPageViewAdapter.kt
+19
-17
PdfViewAdapter.kt
...ry/src/main/java/com/cherry/lib/doc/pdf/PdfViewAdapter.kt
+18
-18
DocView.kt
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
+64
-285
DocWebView.kt
...ary/src/main/java/com/cherry/lib/doc/widget/DocWebView.kt
+0
-221
PinchImageView.kt
...src/main/java/com/cherry/lib/doc/widget/PinchImageView.kt
+41
-34
PoiViewer.java
...ry/src/main/java/com/cherry/lib/doc/widget/PoiViewer.java
+2
-0
doc_view.xml
library/src/main/res/layout/doc_view.xml
+13
-27
list_item_pdf.xml
library/src/main/res/layout/list_item_pdf.xml
+3
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
c7a1e38b
...
@@ -19,9 +19,6 @@
...
@@ -19,9 +19,6 @@
android:theme=
"@style/Theme.PDFViewerScannerWhite"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
android:usesCleartextTraffic=
"true"
android:usesCleartextTraffic=
"true"
tools:targetApi=
"34"
>
tools:targetApi=
"34"
>
<activity
android:name=
".ui.document.ppt.PptActivity"
android:exported=
"false"
/>
<meta-data
<meta-data
android:name=
"com.google.android.gms.version"
android:name=
"com.google.android.gms.version"
...
@@ -49,6 +46,12 @@
...
@@ -49,6 +46,12 @@
android:launchMode=
"singleTop"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<activity
android:name=
".ui.document.ppt.PptActivity"
android:exported=
"false"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<activity
<activity
android:name=
".ui.document.excel.ExcelActivity"
android:name=
".ui.document.excel.ExcelActivity"
android:exported=
"false"
android:exported=
"false"
...
@@ -58,7 +61,9 @@
...
@@ -58,7 +61,9 @@
<activity
<activity
android:name=
".ui.document.word.WordActivity"
android:name=
".ui.document.word.WordActivity"
android:exported=
"false"
android:exported=
"false"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
/>
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
tools:ignore=
"DiscouragedApi,LockedOrientationActivity"
/>
<activity
<activity
android:name=
".ui.document.pdf.PdfMergeActivity"
android:name=
".ui.document.pdf.PdfMergeActivity"
android:exported=
"false"
android:exported=
"false"
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
c7a1e38b
...
@@ -2,6 +2,7 @@ package com.base.pdfviewerscannerwhite.ui.main
...
@@ -2,6 +2,7 @@ package com.base.pdfviewerscannerwhite.ui.main
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.net.Uri
import
android.net.Uri
import
android.provider.MediaStore
import
android.view.View
import
android.view.View
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
...
@@ -20,6 +21,7 @@ import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime2
...
@@ -20,6 +21,7 @@ import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime2
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import
com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import
com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import
com.base.pdfviewerscannerwhite.utils.updateMediaStore
class
MainActivity
:
BaseActivity
<
ActivityMainBinding
>(),
MainView
{
class
MainActivity
:
BaseActivity
<
ActivityMainBinding
>(),
MainView
{
...
@@ -81,7 +83,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
...
@@ -81,7 +83,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
if
(!
checkStorePermission
())
{
if
(!
checkStorePermission
())
{
showStoragePermission
(
launcher
)
showStoragePermission
(
launcher
)
updateMediaStore
()
}
}
}
}
private
fun
initTabLayout
()
{
private
fun
initTabLayout
()
{
...
...
library/build.gradle
View file @
c7a1e38b
...
@@ -28,6 +28,10 @@ android {
...
@@ -28,6 +28,10 @@ android {
kotlinOptions
{
kotlinOptions
{
jvmTarget
=
'1.8'
jvmTarget
=
'1.8'
}
}
buildFeatures
{
viewBinding
=
true
}
}
}
dependencies
{
dependencies
{
...
...
library/src/main/java/com/cherry/lib/doc/DocViewerActivity.kt
View file @
c7a1e38b
...
@@ -6,7 +6,7 @@ import android.util.Log
...
@@ -6,7 +6,7 @@ import android.util.Log
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.util.Constant
import
com.cherry.lib.doc.util.Constant
import
kotlinx.android.synthetic.main.activity_doc_viewer.m
DocView
import
com.cherry.lib.doc.widget.
DocView
open
class
DocViewerActivity
:
AppCompatActivity
()
{
open
class
DocViewerActivity
:
AppCompatActivity
()
{
private
val
TAG
=
"DocViewerActivity"
private
val
TAG
=
"DocViewerActivity"
...
@@ -16,7 +16,7 @@ open class DocViewerActivity : AppCompatActivity() {
...
@@ -16,7 +16,7 @@ open class DocViewerActivity : AppCompatActivity() {
activity
:
AppCompatActivity
,
docSourceType
:
Int
,
path
:
String
?,
activity
:
AppCompatActivity
,
docSourceType
:
Int
,
path
:
String
?,
fileType
:
Int
?
=
null
,
engine
:
Int
?
=
null
fileType
:
Int
?
=
null
,
engine
:
Int
?
=
null
)
{
)
{
va
r
intent
=
Intent
(
activity
,
DocViewerActivity
::
class
.
java
)
va
l
intent
=
Intent
(
activity
,
DocViewerActivity
::
class
.
java
)
intent
.
putExtra
(
Constant
.
INTENT_SOURCE_KEY
,
docSourceType
)
intent
.
putExtra
(
Constant
.
INTENT_SOURCE_KEY
,
docSourceType
)
intent
.
putExtra
(
Constant
.
INTENT_DATA_KEY
,
path
)
intent
.
putExtra
(
Constant
.
INTENT_DATA_KEY
,
path
)
intent
.
putExtra
(
Constant
.
INTENT_TYPE_KEY
,
fileType
)
intent
.
putExtra
(
Constant
.
INTENT_TYPE_KEY
,
fileType
)
...
@@ -34,6 +34,8 @@ open class DocViewerActivity : AppCompatActivity() {
...
@@ -34,6 +34,8 @@ open class DocViewerActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_doc_viewer
)
setContentView
(
R
.
layout
.
activity_doc_viewer
)
initView
()
initView
()
initData
(
intent
)
initData
(
intent
)
}
}
...
@@ -47,7 +49,13 @@ open class DocViewerActivity : AppCompatActivity() {
...
@@ -47,7 +49,13 @@ open class DocViewerActivity : AppCompatActivity() {
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
mDocView
.
openDoc
(
this
,
docUrl
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
findViewById
<
DocView
>(
R
.
id
.
mDocView
).
openDoc
(
this
,
docUrl
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
Log
.
e
(
TAG
,
"initData-docUrl = $docUrl"
)
Log
.
e
(
TAG
,
"initData-docUrl = $docUrl"
)
Log
.
e
(
TAG
,
"initData-docSourceType = $docSourceType"
)
Log
.
e
(
TAG
,
"initData-docSourceType = $docSourceType"
)
Log
.
e
(
TAG
,
"initData-fileType = $fileType"
)
Log
.
e
(
TAG
,
"initData-fileType = $fileType"
)
...
...
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
View file @
c7a1e38b
...
@@ -5,7 +5,6 @@ import android.graphics.Bitmap;
...
@@ -5,7 +5,6 @@ import android.graphics.Bitmap;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
com.blankj.utilcode.util.AppUtils
;
import
com.blankj.utilcode.util.AppUtils
;
import
com.cherry.lib.doc.office.common.IOfficeToPicture
;
import
com.cherry.lib.doc.office.common.IOfficeToPicture
;
import
com.cherry.lib.doc.office.constant.EventConstant
;
import
com.cherry.lib.doc.office.constant.EventConstant
;
...
@@ -13,7 +12,6 @@ import com.cherry.lib.doc.office.constant.wp.WPViewConstant;
...
@@ -13,7 +12,6 @@ import com.cherry.lib.doc.office.constant.wp.WPViewConstant;
import
com.cherry.lib.doc.office.res.ResKit
;
import
com.cherry.lib.doc.office.res.ResKit
;
import
com.cherry.lib.doc.office.system.IMainFrame
;
import
com.cherry.lib.doc.office.system.IMainFrame
;
import
com.cherry.lib.doc.office.system.MainControl
;
import
com.cherry.lib.doc.office.system.MainControl
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -217,7 +215,7 @@ public abstract class IOffice implements IMainFrame {
...
@@ -217,7 +215,7 @@ public abstract class IOffice implements IMainFrame {
* 是否绘制页码
* 是否绘制页码
*/
*/
public
boolean
isDrawPageNumber
()
{
public
boolean
isDrawPageNumber
()
{
return
tru
e
;
return
fals
e
;
}
}
/**
/**
...
...
library/src/main/java/com/cherry/lib/doc/office/fc/hslf/model/MovieShape.java
View file @
c7a1e38b
...
@@ -17,13 +17,9 @@
...
@@ -17,13 +17,9 @@
package
com
.
cherry
.
lib
.
doc
.
office
.
fc
.
hslf
.
model
;
package
com
.
cherry
.
lib
.
doc
.
office
.
fc
.
hslf
.
model
;
import
java.io.ByteArrayOutputStream
;
import
com.cherry.lib.doc.office.fc.ddf.EscherClientDataRecord
;
import
com.cherry.lib.doc.office.fc.ddf.EscherContainerRecord
;
import
com.cherry.lib.doc.office.fc.ddf.EscherContainerRecord
;
import
com.cherry.lib.doc.office.fc.ddf.EscherProperties
;
import
com.cherry.lib.doc.office.fc.hslf.exceptions.HSLFException
;
import
com.cherry.lib.doc.office.fc.hslf.record.*
;
import
com.cherry.lib.doc.office.fc.hslf.record.*
;
import
com.cherry.lib.doc.office.fc.hslf.record.Record
;
import
com.cherry.lib.doc.office.fc.hslf.usermodel.SlideShow
;
import
com.cherry.lib.doc.office.fc.hslf.usermodel.SlideShow
;
...
@@ -32,8 +28,7 @@ import com.cherry.lib.doc.office.fc.hslf.usermodel.SlideShow;
...
@@ -32,8 +28,7 @@ import com.cherry.lib.doc.office.fc.hslf.usermodel.SlideShow;
*
*
* @author Yegor Kozlov
* @author Yegor Kozlov
*/
*/
public
final
class
MovieShape
extends
Picture
public
final
class
MovieShape
extends
Picture
{
{
public
static
final
int
DEFAULT_MOVIE_THUMBNAIL
=
-
1
;
public
static
final
int
DEFAULT_MOVIE_THUMBNAIL
=
-
1
;
public
static
final
int
MOVIE_MPEG
=
1
;
public
static
final
int
MOVIE_MPEG
=
1
;
...
@@ -42,10 +37,9 @@ public final class MovieShape extends Picture
...
@@ -42,10 +37,9 @@ public final class MovieShape extends Picture
/**
/**
* Create a new <code>Picture</code>
* Create a new <code>Picture</code>
*
*
* @param pictureIdx the index of the picture
* @param pictureIdx the index of the picture
*/
*/
public
MovieShape
(
int
movieIdx
,
int
pictureIdx
)
public
MovieShape
(
int
movieIdx
,
int
pictureIdx
)
{
{
super
(
pictureIdx
,
null
);
super
(
pictureIdx
,
null
);
setMovieIndex
(
movieIdx
);
setMovieIndex
(
movieIdx
);
setAutoPlay
(
true
);
setAutoPlay
(
true
);
...
@@ -54,24 +48,22 @@ public final class MovieShape extends Picture
...
@@ -54,24 +48,22 @@ public final class MovieShape extends Picture
/**
/**
* Create a new <code>Picture</code>
* Create a new <code>Picture</code>
*
*
* @param idx the index of the picture
* @param idx
the index of the picture
* @param parent the parent shape
* @param parent the parent shape
*/
*/
public
MovieShape
(
int
movieIdx
,
int
idx
,
Shape
parent
)
public
MovieShape
(
int
movieIdx
,
int
idx
,
Shape
parent
)
{
{
super
(
idx
,
parent
);
super
(
idx
,
parent
);
setMovieIndex
(
movieIdx
);
setMovieIndex
(
movieIdx
);
}
}
/**
/**
* Create a <code>Picture</code> object
* Create a <code>Picture</code> object
*
*
* @param escherRecord the <code>EscherSpContainer</code> record which holds information about
* @param escherRecord the <code>EscherSpContainer</code> record which holds information about
* this picture in the <code>Slide</code>
* this picture in the <code>Slide</code>
* @param parent the parent shape of this picture
* @param parent the parent shape of this picture
*/
*/
protected
MovieShape
(
EscherContainerRecord
escherRecord
,
Shape
parent
)
protected
MovieShape
(
EscherContainerRecord
escherRecord
,
Shape
parent
)
{
{
super
(
escherRecord
,
parent
);
super
(
escherRecord
,
parent
);
}
}
...
@@ -80,8 +72,7 @@ public final class MovieShape extends Picture
...
@@ -80,8 +72,7 @@ public final class MovieShape extends Picture
*
*
* @return the created <code>EscherContainerRecord</code> which holds shape data
* @return the created <code>EscherContainerRecord</code> which holds shape data
*/
*/
protected
EscherContainerRecord
createSpContainer
(
int
idx
,
boolean
isChild
)
protected
EscherContainerRecord
createSpContainer
(
int
idx
,
boolean
isChild
)
{
{
_escherContainer
=
super
.
createSpContainer
(
idx
,
isChild
);
_escherContainer
=
super
.
createSpContainer
(
idx
,
isChild
);
/*setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
/*setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
...
@@ -112,7 +103,8 @@ public final class MovieShape extends Picture
...
@@ -112,7 +103,8 @@ public final class MovieShape extends Picture
{
{
throw new HSLFException(e);
throw new HSLFException(e);
}
}
cldata.setRemainingData(out.toByteArray())*/
;
cldata.setRemainingData(out.toByteArray())*/
;
return
_escherContainer
;
return
_escherContainer
;
}
}
...
@@ -120,17 +112,15 @@ public final class MovieShape extends Picture
...
@@ -120,17 +112,15 @@ public final class MovieShape extends Picture
/**
/**
* Assign a movie to this shape
* Assign a movie to this shape
*
*
* @param idx the index of the movie
* @see com.cherry.lib.doc.office.fc.hslf.usermodel.SlideShow#addMovie(String, int)
* @see com.cherry.lib.doc.office.fc.hslf.usermodel.SlideShow#addMovie(String, int)
* @param idx the index of the movie
*/
*/
public
void
setMovieIndex
(
int
idx
)
public
void
setMovieIndex
(
int
idx
)
{
{
OEShapeAtom
oe
=
(
OEShapeAtom
)
getClientDataRecord
(
RecordTypes
.
OEShapeAtom
.
typeID
);
OEShapeAtom
oe
=
(
OEShapeAtom
)
getClientDataRecord
(
RecordTypes
.
OEShapeAtom
.
typeID
);
oe
.
setOptions
(
idx
);
oe
.
setOptions
(
idx
);
AnimationInfo
an
=
(
AnimationInfo
)
getClientDataRecord
(
RecordTypes
.
AnimationInfo
.
typeID
);
AnimationInfo
an
=
(
AnimationInfo
)
getClientDataRecord
(
RecordTypes
.
AnimationInfo
.
typeID
);
if
(
an
!=
null
)
if
(
an
!=
null
)
{
{
AnimationInfoAtom
ai
=
an
.
getAnimationInfoAtom
();
AnimationInfoAtom
ai
=
an
.
getAnimationInfoAtom
();
ai
.
setDimColor
(
0x07000000
);
ai
.
setDimColor
(
0x07000000
);
ai
.
setFlag
(
AnimationInfoAtom
.
Automatic
,
true
);
ai
.
setFlag
(
AnimationInfoAtom
.
Automatic
,
true
);
...
@@ -140,21 +130,17 @@ public final class MovieShape extends Picture
...
@@ -140,21 +130,17 @@ public final class MovieShape extends Picture
}
}
}
}
public
void
setAutoPlay
(
boolean
flag
)
public
void
setAutoPlay
(
boolean
flag
)
{
{
AnimationInfo
an
=
(
AnimationInfo
)
getClientDataRecord
(
RecordTypes
.
AnimationInfo
.
typeID
);
AnimationInfo
an
=
(
AnimationInfo
)
getClientDataRecord
(
RecordTypes
.
AnimationInfo
.
typeID
);
if
(
an
!=
null
)
{
if
(
an
!=
null
)
{
an
.
getAnimationInfoAtom
().
setFlag
(
AnimationInfoAtom
.
Automatic
,
flag
);
an
.
getAnimationInfoAtom
().
setFlag
(
AnimationInfoAtom
.
Automatic
,
flag
);
updateClientData
();
updateClientData
();
}
}
}
}
public
boolean
isAutoPlay
()
public
boolean
isAutoPlay
()
{
{
AnimationInfo
an
=
(
AnimationInfo
)
getClientDataRecord
(
RecordTypes
.
AnimationInfo
.
typeID
);
AnimationInfo
an
=
(
AnimationInfo
)
getClientDataRecord
(
RecordTypes
.
AnimationInfo
.
typeID
);
if
(
an
!=
null
)
{
if
(
an
!=
null
)
{
return
an
.
getAnimationInfoAtom
().
getFlag
(
AnimationInfoAtom
.
Automatic
);
return
an
.
getAnimationInfoAtom
().
getFlag
(
AnimationInfoAtom
.
Automatic
);
}
}
return
false
;
return
false
;
...
@@ -163,27 +149,23 @@ public final class MovieShape extends Picture
...
@@ -163,27 +149,23 @@ public final class MovieShape extends Picture
/**
/**
* @return UNC or local path to a video file
* @return UNC or local path to a video file
*/
*/
public
String
getPath
()
public
String
getPath
()
{
{
OEShapeAtom
oe
=
(
OEShapeAtom
)
getClientDataRecord
(
RecordTypes
.
OEShapeAtom
.
typeID
);
OEShapeAtom
oe
=
(
OEShapeAtom
)
getClientDataRecord
(
RecordTypes
.
OEShapeAtom
.
typeID
);
int
idx
=
oe
.
getOptions
();
int
idx
=
oe
.
getOptions
();
SlideShow
ppt
=
getSheet
().
getSlideShow
();
SlideShow
ppt
=
getSheet
().
getSlideShow
();
ExObjList
lst
=
(
ExObjList
)
ppt
.
getDocumentRecord
().
findFirstOfType
(
ExObjList
lst
=
(
ExObjList
)
ppt
.
getDocumentRecord
().
findFirstOfType
(
RecordTypes
.
ExObjList
.
typeID
);
RecordTypes
.
ExObjList
.
typeID
);
if
(
lst
==
null
)
if
(
lst
==
null
)
return
null
;
return
null
;
Record
[]
r
=
lst
.
getChildRecords
();
Record
[]
r
=
lst
.
getChildRecords
();
for
(
int
i
=
0
;
i
<
r
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
r
.
length
;
i
++)
{
{
if
(
r
[
i
]
instanceof
ExMCIMovie
)
{
if
(
r
[
i
]
instanceof
ExMCIMovie
)
ExMCIMovie
mci
=
(
ExMCIMovie
)
r
[
i
];
{
ExMCIMovie
mci
=
(
ExMCIMovie
)
r
[
i
];
ExVideoContainer
exVideo
=
mci
.
getExVideo
();
ExVideoContainer
exVideo
=
mci
.
getExVideo
();
int
objectId
=
exVideo
.
getExMediaAtom
().
getObjectId
();
int
objectId
=
exVideo
.
getExMediaAtom
().
getObjectId
();
if
(
objectId
==
idx
)
if
(
objectId
==
idx
)
{
{
return
exVideo
.
getPathAtom
().
getText
();
return
exVideo
.
getPathAtom
().
getText
();
}
}
}
}
...
...
library/src/main/java/com/cherry/lib/doc/office/fc/hslf/model/TextRun.java
View file @
c7a1e38b
This diff is collapsed.
Click to expand it.
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
View file @
c7a1e38b
...
@@ -29,7 +29,6 @@ import com.cherry.lib.doc.office.system.SysKit;
...
@@ -29,7 +29,6 @@ import com.cherry.lib.doc.office.system.SysKit;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListItem
;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListItem
;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListView
;
import
com.cherry.lib.doc.office.system.beans.pagelist.APageListView
;
import
com.cherry.lib.doc.office.system.beans.pagelist.IPageListViewListener
;
import
com.cherry.lib.doc.office.system.beans.pagelist.IPageListViewListener
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.Canvas
;
...
@@ -275,8 +274,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
...
@@ -275,8 +274,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
}
}
/**
/**
* @param x 为100%的值
* @param y 为100%的值
* /
* /
public long viewToModel(int x, int y, boolean isBack)
public long viewToModel(int x, int y, boolean isBack)
{
{
...
@@ -484,7 +481,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
...
@@ -484,7 +481,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
/**
/**
* page list view moving position
* page list view moving position
* @param position horizontal or vertical
*/
*/
public
int
getPageListViewMovingPosition
()
public
int
getPageListViewMovingPosition
()
{
{
...
@@ -515,7 +511,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
...
@@ -515,7 +511,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
* @param e2 MotionEvent instance
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @param velocityY y axis velocity
* @param eventNethodType event method
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
...
@@ -653,7 +648,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
...
@@ -653,7 +648,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
/**
/**
* 绘制页信息
* 绘制页信息
* @param canvas
* @param canvas
* @param zoom
*/
*/
private
void
drawPageNubmer
(
Canvas
canvas
)
private
void
drawPageNubmer
(
Canvas
canvas
)
{
{
...
@@ -692,8 +686,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
...
@@ -692,8 +686,6 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
* (for PPT, word print mode, PDF)
*
*
* @param b = true, change page
* = false, don't change page
*/
*/
public
boolean
isChangePage
()
public
boolean
isChangePage
()
{
{
...
...
library/src/main/java/com/cherry/lib/doc/pdf/PdfPageViewAdapter.kt
View file @
c7a1e38b
...
@@ -7,14 +7,12 @@ import android.view.View
...
@@ -7,14 +7,12 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.view.animation.AlphaAnimation
import
android.view.animation.AlphaAnimation
import
android.view.animation.LinearInterpolator
import
android.view.animation.LinearInterpolator
import
android.widget.
Toast
import
android.widget.
ImageView
import
android
x.core.view.updateLayoutParams
import
android
.widget.ProgressBar
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
com.cherry.lib.doc.R
import
com.cherry.lib.doc.R
import
com.cherry.lib.doc.util.ViewUtils.hide
import
com.cherry.lib.doc.util.ViewUtils.hide
import
com.cherry.lib.doc.util.ViewUtils.show
import
com.cherry.lib.doc.util.ViewUtils.show
import
kotlinx.android.synthetic.main.page_item_pdf.view.*
import
kotlinx.android.synthetic.main.pdf_view_page_loading_layout.view.*
/*
/*
* -----------------------------------------------------------------
* -----------------------------------------------------------------
...
@@ -31,13 +29,14 @@ internal class PdfPageViewAdapter(
...
@@ -31,13 +29,14 @@ internal class PdfPageViewAdapter(
private
val
renderer
:
PdfRendererCore
?,
private
val
renderer
:
PdfRendererCore
?,
private
val
pageSpacing
:
Rect
,
private
val
pageSpacing
:
Rect
,
private
val
enableLoadingForPages
:
Boolean
private
val
enableLoadingForPages
:
Boolean
)
:
)
:
RecyclerView
.
Adapter
<
PdfPageViewAdapter
.
PdfPageViewHolder
>()
{
RecyclerView
.
Adapter
<
PdfPageViewAdapter
.
PdfPageViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
PdfPageViewHolder
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
PdfPageViewHolder
{
return
PdfPageViewHolder
(
return
PdfPageViewHolder
(
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
page_item_pdf
,
parent
,
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
false
)
R
.
layout
.
page_item_pdf
,
parent
,
false
)
)
)
}
}
...
@@ -49,21 +48,22 @@ internal class PdfPageViewAdapter(
...
@@ -49,21 +48,22 @@ internal class PdfPageViewAdapter(
holder
.
bindView
()
holder
.
bindView
()
}
}
inner
class
PdfPageViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
),
View
.
OnAttachStateChangeListener
{
inner
class
PdfPageViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
),
View
.
OnAttachStateChangeListener
{
fun
bindView
()
{
fun
bindView
()
{
}
}
private
fun
handleLoadingForPage
(
position
:
Int
)
{
private
fun
handleLoadingForPage
(
position
:
Int
)
{
val
progressBar
=
itemView
.
findViewById
<
ProgressBar
>(
R
.
id
.
pdf_view_page_loading_progress
)
if
(!
enableLoadingForPages
)
{
if
(!
enableLoadingForPages
)
{
itemView
.
pdf_view_page_loading_progress
.
hide
()
progressBar
.
hide
()
return
return
}
}
if
(
renderer
?.
pageExistInCache
(
position
)
==
true
)
{
if
(
renderer
?.
pageExistInCache
(
position
)
==
true
)
{
itemView
.
pdf_view_page_loading_progress
.
hide
()
progressBar
.
hide
()
}
else
{
}
else
{
itemView
.
pdf_view_page_loading_progress
.
show
()
progressBar
.
show
()
}
}
}
}
...
@@ -84,20 +84,22 @@ internal class PdfPageViewAdapter(
...
@@ -84,20 +84,22 @@ internal class PdfPageViewAdapter(
// this.rightMargin = pageSpacing.right
// this.rightMargin = pageSpacing.right
// this.bottomMargin = pageSpacing.bottom
// this.bottomMargin = pageSpacing.bottom
// }
// }
itemView
.
pageView
.
setImageBitmap
(
bitmap
)
val
pageView
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
pageView
)
itemView
.
pageView
.
animation
=
AlphaAnimation
(
0F
,
1F
).
apply
{
pageView
.
setImageBitmap
(
bitmap
)
pageView
.
animation
=
AlphaAnimation
(
0F
,
1F
).
apply
{
interpolator
=
LinearInterpolator
()
interpolator
=
LinearInterpolator
()
duration
=
200
duration
=
200
}
}
itemView
.
pdf_view_page_loading_progress
.
hide
()
itemView
.
findViewById
<
ProgressBar
>(
R
.
id
.
pdf_view_page_loading_progress
)
.
hide
()
}
}
}
}
}
}
}
}
override
fun
onViewDetachedFromWindow
(
p0
:
View
)
{
override
fun
onViewDetachedFromWindow
(
p0
:
View
)
{
itemView
.
pageView
.
setImageBitmap
(
null
)
val
pageView
=
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
pageView
)
itemView
.
pageView
.
clearAnimation
()
pageView
.
setImageBitmap
(
null
)
pageView
.
clearAnimation
()
}
}
}
}
}
}
\ No newline at end of file
library/src/main/java/com/cherry/lib/doc/pdf/PdfViewAdapter.kt
View file @
c7a1e38b
...
@@ -14,12 +14,10 @@ import android.widget.Toast
...
@@ -14,12 +14,10 @@ import android.widget.Toast
import
androidx.core.view.updateLayoutParams
import
androidx.core.view.updateLayoutParams
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
com.cherry.lib.doc.R
import
com.cherry.lib.doc.R
import
com.cherry.lib.doc.databinding.ListItemPdfBinding
import
com.cherry.lib.doc.interfaces.OnPdfItemClickListener
import
com.cherry.lib.doc.interfaces.OnPdfItemClickListener
import
com.cherry.lib.doc.util.ViewUtils.hide
import
com.cherry.lib.doc.util.ViewUtils.hide
import
com.cherry.lib.doc.util.ViewUtils.show
import
com.cherry.lib.doc.util.ViewUtils.show
import
kotlinx.android.synthetic.main.doc_view.view.mIvPdf
import
kotlinx.android.synthetic.main.list_item_pdf.view.*
import
kotlinx.android.synthetic.main.pdf_view_page_loading_layout.view.*
/*
/*
* -----------------------------------------------------------------
* -----------------------------------------------------------------
...
@@ -41,8 +39,10 @@ internal class PdfViewAdapter(
...
@@ -41,8 +39,10 @@ internal class PdfViewAdapter(
RecyclerView
.
Adapter
<
PdfViewAdapter
.
PdfPageViewHolder
>()
{
RecyclerView
.
Adapter
<
PdfViewAdapter
.
PdfPageViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
PdfPageViewHolder
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
PdfPageViewHolder
{
return
PdfPageViewHolder
(
return
PdfPageViewHolder
(
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
list_item_pdf
,
parent
,
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
false
)
R
.
layout
.
list_item_pdf
,
parent
,
false
)
)
)
}
}
...
@@ -59,24 +59,24 @@ internal class PdfViewAdapter(
...
@@ -59,24 +59,24 @@ internal class PdfViewAdapter(
holder
.
bindView
()
holder
.
bindView
()
}
}
inner
class
PdfPageViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
),
View
.
OnAttachStateChangeListener
{
inner
class
PdfPageViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
),
View
.
OnAttachStateChangeListener
{
val
binding
=
ListItemPdfBinding
.
bind
(
itemView
)
fun
bindView
()
{
fun
bindView
()
{
itemView
.
container_v
iew
.
setOnClickListener
{
binding
.
containerV
iew
.
setOnClickListener
{
listener
?.
OnPdfItemClick
(
adapterPosition
)
listener
?.
OnPdfItemClick
(
adapterPosition
)
}
}
}
}
private
fun
handleLoadingForPage
(
position
:
Int
)
{
private
fun
handleLoadingForPage
(
position
:
Int
)
{
if
(!
enableLoadingForPages
)
{
if
(!
enableLoadingForPages
)
{
itemView
.
pdf_view_page_loading_p
rogress
.
hide
()
binding
.
include
.
pdfViewPageLoadingP
rogress
.
hide
()
return
return
}
}
if
(
renderer
?.
pageExistInCache
(
position
)
==
true
)
{
if
(
renderer
?.
pageExistInCache
(
position
)
==
true
)
{
itemView
.
pdf_view_page_loading_p
rogress
.
hide
()
binding
.
include
.
pdfViewPageLoadingP
rogress
.
hide
()
}
else
{
}
else
{
itemView
.
pdf_view_page_loading_p
rogress
.
show
()
binding
.
include
.
pdfViewPageLoadingP
rogress
.
show
()
}
}
}
}
...
@@ -89,28 +89,28 @@ internal class PdfViewAdapter(
...
@@ -89,28 +89,28 @@ internal class PdfViewAdapter(
renderer
?.
renderPage
(
adapterPosition
)
{
bitmap
:
Bitmap
?,
pageNo
:
Int
->
renderer
?.
renderPage
(
adapterPosition
)
{
bitmap
:
Bitmap
?,
pageNo
:
Int
->
if
(
pageNo
==
adapterPosition
)
{
if
(
pageNo
==
adapterPosition
)
{
bitmap
?.
let
{
bitmap
?.
let
{
itemView
.
container_v
iew
.
updateLayoutParams
<
ViewGroup
.
MarginLayoutParams
>
{
binding
.
containerV
iew
.
updateLayoutParams
<
ViewGroup
.
MarginLayoutParams
>
{
height
=
height
=
(
itemView
.
container_v
iew
.
width
.
toFloat
()
/
((
bitmap
.
width
.
toFloat
()
/
bitmap
.
height
.
toFloat
()))).
toInt
()
(
binding
.
containerV
iew
.
width
.
toFloat
()
/
((
bitmap
.
width
.
toFloat
()
/
bitmap
.
height
.
toFloat
()))).
toInt
()
this
.
topMargin
=
pageSpacing
.
top
this
.
topMargin
=
pageSpacing
.
top
this
.
leftMargin
=
pageSpacing
.
left
this
.
leftMargin
=
pageSpacing
.
left
this
.
rightMargin
=
pageSpacing
.
right
this
.
rightMargin
=
pageSpacing
.
right
this
.
bottomMargin
=
pageSpacing
.
bottom
this
.
bottomMargin
=
pageSpacing
.
bottom
}
}
itemView
.
pageView
.
setImageBitmap
(
bitmap
)
binding
.
pageView
.
setImageBitmap
(
bitmap
)
itemView
.
pageView
.
animation
=
AlphaAnimation
(
0F
,
1F
).
apply
{
binding
.
pageView
.
animation
=
AlphaAnimation
(
0F
,
1F
).
apply
{
interpolator
=
LinearInterpolator
()
interpolator
=
LinearInterpolator
()
duration
=
200
duration
=
200
}
}
itemView
.
pdf_view_page_loading_p
rogress
.
hide
()
binding
.
include
.
pdfViewPageLoadingP
rogress
.
hide
()
}
}
}
}
}
}
}
}
override
fun
onViewDetachedFromWindow
(
p0
:
View
)
{
override
fun
onViewDetachedFromWindow
(
p0
:
View
)
{
itemView
.
pageView
.
setImageBitmap
(
null
)
binding
.
pageView
.
setImageBitmap
(
null
)
itemView
.
pageView
.
clearAnimation
()
binding
.
pageView
.
clearAnimation
()
}
}
}
}
...
...
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
View file @
c7a1e38b
This diff is collapsed.
Click to expand it.
library/src/main/java/com/cherry/lib/doc/widget/DocWebView.kt
deleted
100644 → 0
View file @
9fa8260b
package
com.cherry.lib.doc.widget
import
android.annotation.SuppressLint
import
android.app.DownloadManager
import
android.content.Context
import
android.content.Intent
import
android.graphics.Color
import
android.net.Uri
import
android.os.Environment
import
android.util.AttributeSet
import
android.util.Log
import
android.view.LayoutInflater
import
android.webkit.*
import
androidx.constraintlayout.widget.ConstraintLayout
import
com.cherry.lib.doc.R
import
com.cherry.lib.doc.interfaces.OnWebLoadListener
import
kotlinx.android.synthetic.main.doc_web_view.view.*
/*
* -----------------------------------------------------------------
* Copyright (C) 2018-2028, by Victor, All rights reserved.
* -----------------------------------------------------------------
* File: ProgressWebView
* Author: Victor
* Date: 2022/3/1 18:28
* Description:
* -----------------------------------------------------------------
*/
class
DocWebView
:
ConstraintLayout
,
DownloadListener
{
val
TAG
=
"DocWebView"
var
isLastLoadSuccess
=
false
//是否成功加载完成过web,成功过后的网络异常 不改变web
var
isError
=
false
var
openLinkBySysBrowser
=
false
//是否使用系统浏览器打开http链接
var
mOnWebLoadListener
:
OnWebLoadListener
?
=
null
constructor
(
context
:
Context
)
:
this
(
context
,
null
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?)
:
this
(
context
,
attrs
,
0
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?,
defStyle
:
Int
)
:
super
(
context
,
attrs
,
defStyle
)
{
initView
()
}
fun
initView
()
{
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
doc_web_view
,
this
,
true
)
mDocView
.
webChromeClient
=
DocWebChromeClient
()
mDocView
.
webViewClient
=
DocWebViewClient
()
//设置可以支持缩放
mDocView
.
settings
.
setSupportZoom
(
true
)
//设置出现缩放工具
mDocView
.
settings
.
builtInZoomControls
=
true
//设定缩放控件隐藏
mDocView
.
settings
.
displayZoomControls
=
true
//设置可在大视野范围内上下左右拖动,并且可以任意比例缩放
mDocView
.
settings
.
useWideViewPort
=
true
//设置默认加载的可视范围是大视野范围
mDocView
.
settings
.
loadWithOverviewMode
=
true
//自适应屏幕 SINGLE_COLUMN:把所有内容放大到webview等宽的一列中 NORMAL:正常显示不做任何渲染。NARROW_COLUMNS:可能的话让所有列的宽度不超过屏幕宽度
mDocView
.
settings
.
layoutAlgorithm
=
WebSettings
.
LayoutAlgorithm
.
SINGLE_COLUMN
mDocView
.
settings
.
javaScriptEnabled
=
true
mDocView
.
settings
.
domStorageEnabled
=
true
mDocView
.
settings
.
allowFileAccess
=
true
mDocView
.
settings
.
allowFileAccessFromFileURLs
=
true
mDocView
.
settings
.
allowUniversalAccessFromFileURLs
=
true
mDocView
.
settings
.
cacheMode
=
WebSettings
.
LOAD_NO_CACHE
mDocView
.
setDownloadListener
(
this
)
}
private
fun
setProgress
(
newProgress
:
Int
)
{
mOnWebLoadListener
?.
OnWebLoadProgress
(
newProgress
)
}
/**
* 千万不要更改这个 "SSDJsBirdge" 注意!!!!!
*/
@SuppressLint
(
"JavascriptInterface"
)
fun
addJavascriptInterface
(
jsInterface
:
Any
)
{
mDocView
.
addJavascriptInterface
(
jsInterface
,
"SSDJsBirdge"
)
}
fun
reload
()
{
isError
=
false
mDocView
.
reload
()
}
fun
loadUrl
(
url
:
String
)
{
isError
=
false
try
{
mDocView
.
loadUrl
(
url
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
fun
loadData
(
htmlData
:
String
)
{
mDocView
.
loadData
(
htmlData
,
"text/html"
,
"utf-8"
)
}
fun
loadData
(
htmlData
:
String
,
secondLinkBySysBrowser
:
Boolean
)
{
openLinkBySysBrowser
=
secondLinkBySysBrowser
mDocView
.
loadData
(
htmlData
,
"text/html"
,
"utf-8"
)
}
fun
downloadFile
(
url
:
String
?,
contentDisposition
:
String
?,
mimeType
:
String
?)
{
val
request
=
DownloadManager
.
Request
(
Uri
.
parse
(
url
))
// 允许媒体扫描,根据下载的文件类型被加入相册、音乐等媒体库
request
.
allowScanningByMediaScanner
()
// 设置通知的显示类型,下载进行时和完成后显示通知
request
.
setNotificationVisibility
(
DownloadManager
.
Request
.
VISIBILITY_VISIBLE_NOTIFY_COMPLETED
)
// 设置通知栏的标题,如果不设置,默认使用文件名
request
.
setTitle
(
"下载完成"
)
// 设置通知栏的描述
// request.setDescription("This is description");
// 允许在计费流量下下载
request
.
setAllowedOverMetered
(
true
)
// 允许该记录在下载管理界面可见
request
.
setVisibleInDownloadsUi
(
true
)
// 允许漫游时下载
request
.
setAllowedOverRoaming
(
true
)
val
fileName
=
URLUtil
.
guessFileName
(
url
,
contentDisposition
,
mimeType
)
Log
.
e
(
TAG
,
"downloadFile()-fileName = $fileName"
)
request
.
setDestinationInExternalPublicDir
(
Environment
.
getExternalStorageDirectory
().
toString
()
+
"/Download/"
,
fileName
)
val
downloadManager
=
mDocView
.
context
.
getSystemService
(
Context
.
DOWNLOAD_SERVICE
)
as
DownloadManager
// 添加一个下载任务
val
downloadId
=
downloadManager
.
enqueue
(
request
)
}
override
fun
onDownloadStart
(
url
:
String
?,
userAgent
:
String
?,
contentDisposition
:
String
?,
mimeType
:
String
?,
contentLength
:
Long
)
{
Log
.
e
(
TAG
,
"onDownloadStart()......url = $url"
)
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
intent
.
data
=
Uri
.
parse
(
url
)
context
.
startActivity
(
intent
)
// downloadFile(url,contentDisposition,mimeType)
}
fun
canGoBack
():
Boolean
{
val
canGoBack
=
mDocView
.
canGoBack
()
if
(
canGoBack
)
{
mDocView
.
goBack
()
}
return
canGoBack
}
fun
onPause
()
{
mDocView
.
pauseTimers
()
}
fun
onResume
()
{
mDocView
.
resumeTimers
()
}
/**
* must be called on the main thread
*/
fun
onDestroy
()
{
try
{
mDocView
.
clearHistory
();
mDocView
.
clearCache
(
true
)
mDocView
.
loadUrl
(
"about:blank"
)
// clearView() should be changed to loadUrl("about:blank"), since clearView() is deprecated now
mDocView
.
freeMemory
()
mDocView
.
pauseTimers
()
mDocView
.
destroy
()
// Note that mWebView.destroy() and mWebView = null do the exact same thing
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
fun
setWebViewBackgroundColor
(
isBlack
:
Boolean
)
{
if
(
isBlack
)
{
//防止加载html白屏(针对播放视频)
setBackgroundColor
(
Color
.
BLACK
)
}
}
override
fun
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
()
onDestroy
()
}
private
inner
class
DocWebChromeClient
:
WebChromeClient
()
{
override
fun
onProgressChanged
(
view
:
WebView
,
newProgress
:
Int
)
{
super
.
onProgressChanged
(
view
,
newProgress
)
setProgress
(
newProgress
)
}
override
fun
onReceivedTitle
(
view
:
WebView
,
title
:
String
)
{
super
.
onReceivedTitle
(
view
,
title
)
if
(
title
.
contains
(
"html"
))
{
return
}
mOnWebLoadListener
?.
onTitle
(
title
)
}
}
private
inner
class
DocWebViewClient
:
WebViewClient
()
{
override
fun
onPageFinished
(
view
:
WebView
,
url
:
String
)
{
super
.
onPageFinished
(
view
,
url
)
//在访问失败的时候会首先回调onReceivedError,然后再回调onPageFinished。
if
(!
isError
)
{
isLastLoadSuccess
=
true
mOnWebLoadListener
?.
OnWebLoadProgress
(
100
)
}
}
override
fun
onReceivedError
(
view
:
WebView
,
request
:
WebResourceRequest
,
error
:
WebResourceError
)
{
super
.
onReceivedError
(
view
,
request
,
error
)
//在访问失败的时候会首先回调onReceivedError,然后再回调onPageFinished。
isError
=
true
if
(!
isLastLoadSuccess
)
{
//之前成功加载完成过,不会回调
mOnWebLoadListener
?.
OnWebLoadProgress
(
100
)
}
}
}
}
\ No newline at end of file
library/src/main/java/com/cherry/lib/doc/widget/PinchImageView.kt
View file @
c7a1e38b
...
@@ -27,7 +27,7 @@ import java.util.*
...
@@ -27,7 +27,7 @@ import java.util.*
* -----------------------------------------------------------------
* -----------------------------------------------------------------
*/
*/
class
PinchImageView
:
AppCompatImageView
{
class
PinchImageView
:
AppCompatImageView
{
companion
object
{
companion
object
{
////////////////////////////////配置参数////////////////////////////////
////////////////////////////////配置参数////////////////////////////////
/**
/**
...
@@ -557,14 +557,15 @@ class PinchImageView: AppCompatImageView {
...
@@ -557,14 +557,15 @@ class PinchImageView: AppCompatImageView {
}
}
////////////////////////////////初始化////////////////////////////////
////////////////////////////////初始化////////////////////////////////
constructor
(
context
:
Context
)
:
super
(
context
)
{
constructor
(
context
:
Context
)
:
super
(
context
)
{
initView
()
initView
()
}
}
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?)
:
super
(
context
,
attrs
)
{
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?)
:
super
(
context
,
attrs
)
{
initView
()
initView
()
}
}
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?,
defStyle
:
Int
):
super
(
context
,
attrs
,
defStyle
)
{
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?,
defStyle
:
Int
)
:
super
(
context
,
attrs
,
defStyle
)
{
initView
()
initView
()
}
}
...
@@ -742,38 +743,39 @@ class PinchImageView: AppCompatImageView {
...
@@ -742,38 +743,39 @@ class PinchImageView: AppCompatImageView {
*
*
* 在onTouchEvent末尾被执行.
* 在onTouchEvent末尾被执行.
*/
*/
private
val
mGestureDetector
=
GestureDetector
(
this
@PinchImageView
.
getContext
(),
object
:
SimpleOnGestureListener
()
{
private
val
mGestureDetector
=
GestureDetector
(
this
@PinchImageView
.
context
,
override
fun
onFling
(
e1
:
MotionEvent
,
e2
:
MotionEvent
,
velocityX
:
Float
,
velocityY
:
Float
):
Boolean
{
object
:
SimpleOnGestureListener
()
{
//只有在单指模式结束之后才允许执行fling
override
fun
onFling
(
e1
:
MotionEvent
?,
e2
:
MotionEvent
,
velocityX
:
Float
,
velocityY
:
Float
):
Boolean
{
if
(
mPinchMode
==
PINCH_MODE_FREE
&&
!(
mScaleAnimator
!=
null
&&
mScaleAnimator
!!
.
isRunning
))
{
//只有在单指模式结束之后才允许执行fling
fling
(
velocityX
,
velocityY
)
if
(
mPinchMode
==
PINCH_MODE_FREE
&&
!(
mScaleAnimator
!=
null
&&
mScaleAnimator
!!
.
isRunning
))
{
fling
(
velocityX
,
velocityY
)
}
return
true
}
}
return
true
}
override
fun
onLongPress
(
e
:
MotionEvent
)
{
override
fun
onLongPress
(
e
:
MotionEvent
)
{
//触发长按
//触发长按
if
(
mOnLongClickListener
!=
null
)
{
if
(
mOnLongClickListener
!=
null
)
{
mOnLongClickListener
!!
.
onLongClick
(
this
@PinchImageView
)
mOnLongClickListener
!!
.
onLongClick
(
this
@PinchImageView
)
}
}
}
}
override
fun
onDoubleTap
(
e
:
MotionEvent
):
Boolean
{
override
fun
onDoubleTap
(
e
:
MotionEvent
):
Boolean
{
//当手指快速第二次按下触发,此时必须是单指模式才允许执行doubleTap
//当手指快速第二次按下触发,此时必须是单指模式才允许执行doubleTap
if
(
mPinchMode
==
PINCH_MODE_SCROLL
&&
!(
mScaleAnimator
!=
null
&&
mScaleAnimator
!!
.
isRunning
))
{
if
(
mPinchMode
==
PINCH_MODE_SCROLL
&&
!(
mScaleAnimator
!=
null
&&
mScaleAnimator
!!
.
isRunning
))
{
doubleTap
(
e
.
x
,
e
.
y
)
doubleTap
(
e
.
x
,
e
.
y
)
}
return
true
}
}
return
true
}
override
fun
onSingleTapConfirmed
(
e
:
MotionEvent
):
Boolean
{
override
fun
onSingleTapConfirmed
(
e
:
MotionEvent
):
Boolean
{
//触发点击
//触发点击
if
(
mOnClickListener
!=
null
)
{
if
(
mOnClickListener
!=
null
)
{
mOnClickListener
!!
.
onClick
(
this
@PinchImageView
)
mOnClickListener
!!
.
onClick
(
this
@PinchImageView
)
}
return
true
}
}
return
true
})
}
})
override
fun
onTouchEvent
(
event
:
MotionEvent
):
Boolean
{
override
fun
onTouchEvent
(
event
:
MotionEvent
):
Boolean
{
super
.
onTouchEvent
(
event
)
super
.
onTouchEvent
(
event
)
...
@@ -1220,7 +1222,11 @@ class PinchImageView: AppCompatImageView {
...
@@ -1220,7 +1222,11 @@ class PinchImageView: AppCompatImageView {
*
*
* 在给定时间内从一个矩阵的变化逐渐动画到另一个矩阵的变化
* 在给定时间内从一个矩阵的变化逐渐动画到另一个矩阵的变化
*/
*/
private
inner
class
ScaleAnimator
@JvmOverloads
constructor
(
start
:
Matrix
,
end
:
Matrix
,
duration
:
Long
=
SCALE_ANIMATOR_DURATION
.
toLong
())
:
ValueAnimator
(),
AnimatorUpdateListener
{
private
inner
class
ScaleAnimator
@JvmOverloads
constructor
(
start
:
Matrix
,
end
:
Matrix
,
duration
:
Long
=
SCALE_ANIMATOR_DURATION
.
toLong
()
)
:
ValueAnimator
(),
AnimatorUpdateListener
{
/**
/**
* 开始矩阵
* 开始矩阵
*/
*/
...
@@ -1284,10 +1290,11 @@ class PinchImageView: AppCompatImageView {
...
@@ -1284,10 +1290,11 @@ class PinchImageView: AppCompatImageView {
* @param <T> 对象池容纳的对象类型
* @param <T> 对象池容纳的对象类型
</T> */
</T> */
private
abstract
class
ObjectsPool
<
T
>(
private
abstract
class
ObjectsPool
<
T
>(
/**
/**
* 对象池的最大容量
* 对象池的最大容量
*/
*/
private
val
mSize
:
Int
)
{
private
val
mSize
:
Int
)
{
/**
/**
* 对象池队列
* 对象池队列
...
...
library/src/main/java/com/cherry/lib/doc/widget/PoiViewer.java
View file @
c7a1e38b
package
com
.
cherry
.
lib
.
doc
.
widget
;
package
com
.
cherry
.
lib
.
doc
.
widget
;
import
android.annotation.SuppressLint
;
import
android.app.ProgressDialog
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.ContextWrapper
;
import
android.content.ContextWrapper
;
...
@@ -41,6 +42,7 @@ public class PoiViewer {
...
@@ -41,6 +42,7 @@ public class PoiViewer {
initCacheDir
();
initCacheDir
();
}
}
@SuppressLint
(
"SetJavaScriptEnabled"
)
private
void
initView
()
{
private
void
initView
()
{
mProgressDialog
=
new
ProgressDialog
(
mContext
);
mProgressDialog
=
new
ProgressDialog
(
mContext
);
mProgressDialog
.
setMessage
(
"正在加载文件..."
);
mProgressDialog
.
setMessage
(
"正在加载文件..."
);
...
...
library/src/main/res/layout/doc_view.xml
View file @
c7a1e38b
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:
android=
"http://schemas.android.com/apk/res/android
"
xmlns:
tools=
"http://schemas.android.com/tools
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
>
xmlns:tools=
"http://schemas.android.com/tools"
>
<com.cherry.lib.doc.pdf.PinchZoomRecyclerView
android:id=
"@+id/mRvPdf"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/transparent"
android:scrollbars=
"vertical"
tools:listitem=
"@layout/list_item_pdf"
/>
<FrameLayout
<FrameLayout
android:id=
"@+id/mLlBigPdfImage"
android:id=
"@+id/mLlBigPdfImage"
...
@@ -23,15 +14,15 @@
...
@@ -23,15 +14,15 @@
<com.cherry.lib.doc.widget.PinchImageView
<com.cherry.lib.doc.widget.PinchImageView
android:id=
"@+id/mIvPdf"
android:id=
"@+id/mIvPdf"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
/>
<ProgressBar
<ProgressBar
android:id=
"@+id/mPbBigLoading"
android:id=
"@+id/mPbBigLoading"
android:layout_gravity=
"center"
android:layout_width=
"40dp"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_height=
"40dp"
android:layout_gravity=
"center"
android:visibility=
"gone"
android:visibility=
"gone"
tools:visibility=
"visible"
/>
tools:visibility=
"visible"
/>
<ImageView
<ImageView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
@@ -40,33 +31,29 @@
...
@@ -40,33 +31,29 @@
android:layout_marginTop=
"50dp"
android:layout_marginTop=
"50dp"
android:layout_marginEnd=
"30dp"
android:layout_marginEnd=
"30dp"
android:scaleType=
"fitCenter"
android:scaleType=
"fitCenter"
android:src=
"@mipmap/ic_big_close"
/>
android:src=
"@mipmap/ic_big_close"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</FrameLayout>
<FrameLayout
<FrameLayout
android:id=
"@+id/mFlDocContainer"
android:id=
"@+id/mFlDocContainer"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
/>
<com.cherry.lib.doc.widget.PinchImageView
<com.cherry.lib.doc.widget.PinchImageView
android:id=
"@+id/mIvImage"
android:id=
"@+id/mIvImage"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"fitCenter"
/>
android:scaleType=
"fitCenter"
/>
<com.cherry.lib.doc.widget.DocWebView
android:id=
"@+id/mDocWeb"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<ProgressBar
<ProgressBar
android:id=
"@+id/mPlLoadProgress"
android:id=
"@+id/mPlLoadProgress"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"20dp"
android:layout_height=
"20dp"
style=
"?android:attr/progressBarStyleHorizontal"
android:progressDrawable=
"@drawable/pb_webview_layer"
android:progressDrawable=
"@drawable/pb_webview_layer"
android:visibility=
"visible"
/>
android:visibility=
"visible"
/>
<TextView
<TextView
android:id=
"@+id/mPdfPageNo"
android:id=
"@+id/mPdfPageNo"
...
@@ -79,7 +66,6 @@
...
@@ -79,7 +66,6 @@
android:paddingEnd=
"12dp"
android:paddingEnd=
"12dp"
android:paddingBottom=
"4dp"
android:paddingBottom=
"4dp"
android:textColor=
"#A19D9D"
android:textColor=
"#A19D9D"
android:textSize=
"16sp"
android:textSize=
"16sp"
/>
android:visibility=
"gone"
/>
</FrameLayout>
</FrameLayout>
\ No newline at end of file
library/src/main/res/layout/list_item_pdf.xml
View file @
c7a1e38b
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
android:padding=
"0dp"
android:padding=
"0dp"
android:scaleType=
"fitCenter"
/>
android:scaleType=
"fitCenter"
/>
<include
layout=
"@layout/pdf_view_page_loading_layout"
/>
<include
android:id=
"@+id/include"
layout=
"@layout/pdf_view_page_loading_layout"
/>
</FrameLayout>
</FrameLayout>
\ 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