Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
cbc5b96c
Commit
cbc5b96c
authored
Jul 10, 2022
by
fengquan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 咨询师详情页改版
parent
de89a4c2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
673 additions
and
745 deletions
+673
-745
AndroidManifest.xml
m-consultant/src/main/AndroidManifest.xml
+1
-0
BasePhotoFragment.java
m-consultant/src/main/java/com/yidianling/consultant/preview/BasePhotoFragment.java
+0
-487
BasePhotoFragment.kt
m-consultant/src/main/java/com/yidianling/consultant/preview/BasePhotoFragment.kt
+417
-0
GPreviewActivity.java
m-consultant/src/main/java/com/yidianling/consultant/preview/GPreviewActivity.java
+0
-252
GPreviewActivity.kt
m-consultant/src/main/java/com/yidianling/consultant/preview/GPreviewActivity.kt
+247
-0
consultant_image_preview_photo.xml
m-consultant/src/main/res/layout/consultant_image_preview_photo.xml
+4
-2
styles.xml
m-consultant/src/main/res/values/styles.xml
+4
-4
No files found.
m-consultant/src/main/AndroidManifest.xml
View file @
cbc5b96c
...
...
@@ -24,6 +24,7 @@
android:theme=
"@style/consultant_Transparent"
/>
<activity
android:name=
".preview.GPreviewActivity"
android:screenOrientation=
"portrait"
android:theme=
"@style/consultant_Transparent"
/>
</application>
...
...
m-consultant/src/main/java/com/yidianling/consultant/preview/BasePhotoFragment.java
deleted
100644 → 0
View file @
de89a4c2
package
com
.
yidianling
.
consultant
.
preview
;
import
android.animation.ObjectAnimator
;
import
android.graphics.Color
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.SeekBar
;
import
androidx.annotation.CallSuper
;
import
androidx.annotation.Nullable
;
import
androidx.core.view.ViewCompat
;
import
androidx.fragment.app.Fragment
;
import
com.dou361.ijkplayer.widget.IjkVideoView
;
import
com.ydl.ydlcommon.ui.Loading
;
import
com.yidianling.consultant.R
;
import
java.util.concurrent.TimeUnit
;
import
io.reactivex.Observable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.functions.Consumer
;
import
io.reactivex.schedulers.Schedulers
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
/**
* @author rainb
* Deprecated: 图片预览单个图片的fragment
*/
public
class
BasePhotoFragment
extends
Fragment
{
/**
* 预览图片 类型
*/
private
static
final
String
KEY_TRANS_PHOTO
=
"is_trans_photo"
;
private
static
final
String
KEY_SING_FILING
=
"isSingleFling"
;
private
static
final
String
KEY_PATH
=
"key_item"
;
private
static
final
String
KEY_DRAG
=
"isDrag"
;
private
static
final
String
KEY_SEN
=
"sensitivity"
;
private
IThumbViewInfo
beanViewInfo
;
private
boolean
isTransPhoto
=
false
;
protected
SmoothImageView
imageView
;
protected
View
rootView
;
protected
View
loading
;
protected
MySimpleTarget
mySimpleTarget
;
protected
View
btnVideo
;
private
RelativeLayout
btnLL
;
private
RelativeLayout
videoContainer
;
private
IjkVideoView
videoView
;
private
Disposable
disposable
;
private
SeekBar
seekBar
;
private
View
ivPlay
;
private
boolean
isPrepared
=
false
;
private
ImageView
ivImg
;
private
volatile
boolean
isTouch
=
false
;
private
boolean
isCompletion
=
false
;
private
boolean
isVisiable
=
false
;
private
View
ivBack
;
// public static VideoClickListener listener;
public
static
BasePhotoFragment
getInstance
(
Class
<?
extends
BasePhotoFragment
>
fragmentClass
,
IThumbViewInfo
item
,
boolean
currentIndex
,
boolean
isSingleFling
,
boolean
isDrag
,
float
sensitivity
)
{
BasePhotoFragment
fragment
;
try
{
fragment
=
fragmentClass
.
newInstance
();
}
catch
(
Exception
e
)
{
fragment
=
new
BasePhotoFragment
();
}
Bundle
bundle
=
new
Bundle
();
bundle
.
putParcelable
(
BasePhotoFragment
.
KEY_PATH
,
item
);
bundle
.
putBoolean
(
BasePhotoFragment
.
KEY_TRANS_PHOTO
,
currentIndex
);
bundle
.
putBoolean
(
BasePhotoFragment
.
KEY_SING_FILING
,
isSingleFling
);
bundle
.
putBoolean
(
BasePhotoFragment
.
KEY_DRAG
,
isDrag
);
bundle
.
putFloat
(
BasePhotoFragment
.
KEY_SEN
,
sensitivity
);
fragment
.
setArguments
(
bundle
);
return
fragment
;
}
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
return
inflater
.
inflate
(
R
.
layout
.
fragment_image_photo_layout
,
container
,
false
);
}
@CallSuper
@Override
public
void
onViewCreated
(
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
initView
(
view
);
initData
();
}
@CallSuper
@Override
public
void
onStop
()
{
ZoomMediaLoader
.
getInstance
().
getLoader
().
onStop
(
this
);
super
.
onStop
();
}
@CallSuper
@Override
public
void
onDestroyView
()
{
super
.
onDestroyView
();
release
();
}
@Override
public
void
setUserVisibleHint
(
boolean
isVisibleToUser
)
{
super
.
setUserVisibleHint
(
isVisibleToUser
);
isVisiable
=
isVisibleToUser
;
if
(!
isVisibleToUser
&&
beanViewInfo
!=
null
)
{
videoView
.
seekTo
(
0
);
seekBar
.
setProgress
(
0
);
videoView
.
pause
();
if
(
ivPlay
!=
null
&&
!
TextUtils
.
isEmpty
(
beanViewInfo
.
getVideoUrl
()))
{
ivPlay
.
setVisibility
(
View
.
VISIBLE
);
if
(
ivImg
!=
null
)
{
ivImg
.
setVisibility
(
View
.
VISIBLE
);
}
}
stopTiming
();
}
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
ZoomMediaLoader
.
getInstance
().
getLoader
().
clearMemory
(
getActivity
());
}
public
void
release
()
{
isTransPhoto
=
false
;
if
(
videoView
!=
null
)
{
videoView
.
release
(
true
);
stopTiming
();
}
}
/**
* 初始化控件
*/
private
void
initView
(
View
view
)
{
loading
=
view
.
findViewById
(
R
.
id
.
loading
);
imageView
=
view
.
findViewById
(
R
.
id
.
photoView
);
btnVideo
=
view
.
findViewById
(
R
.
id
.
btnVideo
);
rootView
=
view
.
findViewById
(
R
.
id
.
rootView
);
rootView
.
setDrawingCacheEnabled
(
false
);
imageView
.
setDrawingCacheEnabled
(
false
);
btnLL
=
view
.
findViewById
(
R
.
id
.
btnLL
);
imageView
.
setOnDragListener
(
new
OnDragListener
()
{
@Override
public
void
drag
()
{
((
GPreviewActivity
)
getActivity
()).
hindView
();
}
@Override
public
void
actionCancel
()
{
((
GPreviewActivity
)
getActivity
()).
showView
();
}
});
videoContainer
=
view
.
findViewById
(
R
.
id
.
videoContainer
);
videoView
=
view
.
findViewById
(
R
.
id
.
videoView
);
seekBar
=
view
.
findViewById
(
R
.
id
.
seekbar
);
ivPlay
=
view
.
findViewById
(
R
.
id
.
ivPlay
);
ivImg
=
view
.
findViewById
(
R
.
id
.
ivImage
);
mySimpleTarget
=
new
MySimpleTarget
()
{
@Override
public
void
onResourceReady
()
{
loading
.
setVisibility
(
View
.
GONE
);
// String video = beanViewInfo.getVideoUrl();
// if (video != null && !video.isEmpty()) {
// btnVideo.setVisibility(View.VISIBLE);
// ViewCompat.animate(btnVideo).alpha(1).setDuration(1000).start();
// } else {
// btnVideo.setVisibility(View.GONE);
// }
}
@Override
public
void
onLoadFailed
(
Drawable
errorDrawable
)
{
loading
.
setVisibility
(
View
.
GONE
);
if
(
errorDrawable
!=
null
)
{
imageView
.
setImageDrawable
(
errorDrawable
);
}
}
};
}
/**
* 初始化数据
*/
private
void
initData
()
{
Bundle
bundle
=
getArguments
();
boolean
isSingleFling
=
true
;
// 非动画进入的Fragment,默认背景为黑色
if
(
bundle
!=
null
)
{
isSingleFling
=
bundle
.
getBoolean
(
KEY_SING_FILING
);
//地址
beanViewInfo
=
bundle
.
getParcelable
(
KEY_PATH
);
//位置
assert
beanViewInfo
!=
null
;
//imageView.setDrag(bundle.getBoolean(KEY_DRAG), bundle.getFloat(KEY_SEN));
imageView
.
setThumbRect
(
beanViewInfo
.
getBounds
());
rootView
.
setTag
(
beanViewInfo
.
getUrl
());
//是否展示动画
isTransPhoto
=
bundle
.
getBoolean
(
KEY_TRANS_PHOTO
,
false
);
if
(!
TextUtils
.
isEmpty
(
beanViewInfo
.
getUrl
()))
{
ivPlay
.
setVisibility
(
View
.
GONE
);
if
(
beanViewInfo
.
getUrl
().
toLowerCase
().
contains
(
".gif"
))
{
imageView
.
setVisibility
(
View
.
VISIBLE
);
videoContainer
.
setVisibility
(
View
.
GONE
);
imageView
.
setZoomable
(
false
);
//加载图
ZoomMediaLoader
.
getInstance
().
getLoader
().
displayGifImage
(
this
,
beanViewInfo
.
getUrl
(),
imageView
,
mySimpleTarget
);
}
else
{
//加载图
ZoomMediaLoader
.
getInstance
().
getLoader
().
displayImage
(
this
,
beanViewInfo
.
getUrl
(),
imageView
,
mySimpleTarget
);
}
}
else
{
ivPlay
.
setVisibility
(
View
.
VISIBLE
);
videoContainer
.
setVisibility
(
View
.
VISIBLE
);
imageView
.
setVisibility
(
View
.
GONE
);
ZoomMediaLoader
.
getInstance
().
getLoader
().
displayImage
(
this
,
"https://hellorfimg.zcool.cn/preview260/123343987.jpg"
,
ivImg
,
mySimpleTarget
);
final
String
videoUlr
=
beanViewInfo
.
getVideoUrl
();
if
(!
TextUtils
.
isEmpty
(
videoUlr
))
{
rootView
.
setBackgroundColor
(
Color
.
BLACK
);
seekBar
.
setVisibility
(
View
.
VISIBLE
);
videoView
.
setVideoURI
(
Uri
.
parse
(
videoUlr
));
videoView
.
setOnPreparedListener
(
new
IMediaPlayer
.
OnPreparedListener
()
{
@Override
public
void
onPrepared
(
IMediaPlayer
iMediaPlayer
)
{
loading
.
setVisibility
(
View
.
GONE
);
isPrepared
=
true
;
int
maxProgress
=
(
int
)
iMediaPlayer
.
getDuration
();
if
(
maxProgress
>
0
)
{
seekBar
.
setMax
(
maxProgress
);
}
else
{
seekBar
.
setVisibility
(
View
.
GONE
);
}
}
});
videoView
.
setOnCompletionListener
(
new
IMediaPlayer
.
OnCompletionListener
()
{
@Override
public
void
onCompletion
(
IMediaPlayer
iMediaPlayer
)
{
isCompletion
=
true
;
videoView
.
seekTo
(
0
);
stopTiming
();
ivPlay
.
setVisibility
(
View
.
VISIBLE
);
}
});
videoView
.
setOnInfoListener
(
new
IMediaPlayer
.
OnInfoListener
()
{
@Override
public
boolean
onInfo
(
IMediaPlayer
iMediaPlayer
,
int
what
,
int
extra
)
{
if
(
what
==
IMediaPlayer
.
MEDIA_INFO_BUFFERING_START
&&
!
isCompletion
&&
isVisiable
)
{
Loading
.
INSTANCE
.
show
(
getContext
(),
"正在加载"
);
}
else
if
(
what
==
IMediaPlayer
.
MEDIA_INFO_BUFFERING_END
)
{
Loading
.
INSTANCE
.
close
();
}
return
true
;
}
});
ivPlay
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(!
isPrepared
)
{
loading
.
setVisibility
(
View
.
VISIBLE
);
}
ivImg
.
setVisibility
(
View
.
GONE
);
ivPlay
.
setVisibility
(
View
.
GONE
);
startTiming
();
videoView
.
start
();
isCompletion
=
false
;
}
});
videoContainer
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
videoView
.
isPlaying
())
{
ivPlay
.
setVisibility
(
View
.
VISIBLE
);
stopTiming
();
videoView
.
pause
();
}
}
});
seekBar
.
setOnSeekBarChangeListener
(
new
SeekBar
.
OnSeekBarChangeListener
()
{
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
}
@Override
public
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
isTouch
=
true
;
}
@Override
public
void
onStopTrackingTouch
(
SeekBar
seekBar
)
{
isTouch
=
false
;
if
(
seekBar
!=
null
)
{
videoView
.
seekTo
(
seekBar
.
getProgress
());
videoView
.
start
();
ivPlay
.
setVisibility
(
View
.
GONE
);
isCompletion
=
false
;
}
}
});
}
}
}
if
(!
isTransPhoto
)
{
rootView
.
setBackgroundColor
(
Color
.
BLACK
);
}
else
{
imageView
.
setMinimumScale
(
0.7f
);
}
if
(
isSingleFling
)
{
imageView
.
setOnViewTapListener
(
new
PhotoViewAttacher
.
OnViewTapListener
()
{
@Override
public
void
onViewTap
(
View
view
,
float
x
,
float
y
)
{
}
});
imageView
.
setOnViewTapListener
(
new
PhotoViewAttacher
.
OnViewTapListener
()
{
@Override
public
void
onViewTap
(
View
view
,
float
x
,
float
y
)
{
if
(
imageView
.
checkMinScale
())
{
((
GPreviewActivity
)
getActivity
()).
transformOut
();
}
}
});
}
else
{
imageView
.
setOnPhotoTapListener
(
new
PhotoViewAttacher
.
OnPhotoTapListener
()
{
@Override
public
void
onPhotoTap
(
View
view
,
float
x
,
float
y
)
{
if
(
imageView
.
checkMinScale
())
{
((
GPreviewActivity
)
getActivity
()).
transformOutAnim
();
((
GPreviewActivity
)
getActivity
()).
transformOut
();
}
}
@Override
public
void
onOutsidePhotoTap
()
{
}
});
}
imageView
.
setAlphaChangeListener
(
new
SmoothImageView
.
OnAlphaChangeListener
()
{
@Override
public
void
onAlphaChange
(
int
alpha
)
{
if
(
alpha
==
255
)
{
String
video
=
beanViewInfo
.
getVideoUrl
();
if
(
video
!=
null
&&
!
video
.
isEmpty
())
{
btnVideo
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
btnVideo
.
setVisibility
(
View
.
GONE
);
}
}
else
{
btnVideo
.
setVisibility
(
View
.
GONE
);
}
rootView
.
setBackgroundColor
(
getColorWithAlpha
(
alpha
/
255
f
,
Color
.
BLACK
));
}
});
imageView
.
setTransformOutListener
(
new
SmoothImageView
.
OnTransformOutListener
()
{
@Override
public
void
onTransformOut
()
{
((
GPreviewActivity
)
getActivity
()).
transformOut
();
}
});
}
public
static
int
getColorWithAlpha
(
float
alpha
,
int
baseColor
)
{
int
a
=
Math
.
min
(
255
,
Math
.
max
(
0
,
(
int
)
(
alpha
*
255
)))
<<
24
;
int
rgb
=
0x00ffffff
&
baseColor
;
return
a
+
rgb
;
}
public
void
transformIn
()
{
assert
imageView
!=
null
;
imageView
.
transformIn
(
new
SmoothImageView
.
onTransformListener
()
{
@Override
public
void
onTransformCompleted
(
SmoothImageView
.
Status
status
)
{
rootView
.
setBackgroundColor
(
Color
.
BLACK
);
}
});
}
public
void
transformOut
(
SmoothImageView
.
onTransformListener
listener
)
{
assert
imageView
!=
null
;
imageView
.
transformOut
(
listener
);
}
public
void
changeBg
(
int
color
)
{
ViewCompat
.
animate
(
btnVideo
).
alpha
(
0
).
setDuration
(
SmoothImageView
.
getDuration
()).
start
();
rootView
.
setBackgroundColor
(
color
);
}
public
IThumbViewInfo
getBeanViewInfo
()
{
return
beanViewInfo
;
}
private
void
startTiming
()
{
disposable
=
Observable
.
interval
(
3
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribeOn
(
Schedulers
.
computation
())
.
subscribe
(
new
Consumer
<
Long
>()
{
@Override
public
void
accept
(
Long
aLong
)
throws
Exception
{
// val pos = (video?.mMediaPlayer as IjkMediaPlayer?)?.currentPosition ?: 0
// if (pos > 0) {
//// if (vm?.isVideo == true) {
//// binding.ivCover.visibility = View.GONE
//// }
// if (!isTouch) {
// binding.seekbar.progress = pos.toInt()// video.bufferPercentage
// }
// if (video?.isPlaying == true) {
// when (vm?.isVideo) {
// true -> {
// binding.ivPlay.visibility = View.GONE
// }
// false -> {
// binding.voicePlay.start()
// }
// }
// }
// }
if
(
videoView
!=
null
&&
!
isTouch
)
{
int
currentPosition
=
videoView
.
getCurrentPosition
();
seekBar
.
setProgress
(
currentPosition
);
}
}
});
}
private
void
stopTiming
()
{
if
(
disposable
!=
null
)
{
disposable
.
dispose
();
disposable
=
null
;
}
}
public
interface
OnDragListener
{
void
drag
();
void
actionCancel
();
}
}
m-consultant/src/main/java/com/yidianling/consultant/preview/BasePhotoFragment.kt
0 → 100644
View file @
cbc5b96c
package
com.yidianling.consultant.preview
import
android.graphics.Color
import
android.graphics.drawable.Drawable
import
android.net.Uri
import
android.os.Bundle
import
android.text.TextUtils
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.RelativeLayout
import
android.widget.SeekBar
import
androidx.annotation.CallSuper
import
androidx.core.view.ViewCompat
import
androidx.fragment.app.Fragment
import
com.dou361.ijkplayer.widget.IjkVideoView
import
com.ydl.ydlcommon.ui.Loading.close
import
com.ydl.ydlcommon.ui.Loading.show
import
com.yidianling.consultant.R
import
com.yidianling.consultant.preview.SmoothImageView.*
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.Disposable
import
io.reactivex.schedulers.Schedulers
import
tv.danmaku.ijk.media.player.IMediaPlayer
import
java.util.concurrent.TimeUnit
/**
* @author rainb
* Deprecated: 图片预览单个图片的fragment
*/
class
BasePhotoFragment
:
Fragment
()
{
var
beanViewInfo
:
IThumbViewInfo
?
=
null
private
set
private
var
isTransPhoto
=
false
protected
var
imageView
:
SmoothImageView
?
=
null
protected
var
rootView
:
View
?
=
null
protected
var
loading
:
View
?
=
null
protected
var
mySimpleTarget
:
MySimpleTarget
?
=
null
protected
var
btnVideo
:
View
?
=
null
private
var
btnLL
:
RelativeLayout
?
=
null
private
var
videoContainer
:
RelativeLayout
?
=
null
private
var
videoView
:
IjkVideoView
?
=
null
private
var
disposable
:
Disposable
?
=
null
private
var
seekBar
:
SeekBar
?
=
null
private
var
ivPlay
:
View
?
=
null
private
var
isPrepared
=
false
private
var
ivImg
:
ImageView
?
=
null
@Volatile
private
var
isTouch
=
false
private
var
isCompletion
=
false
private
var
isVisiable
=
false
private
val
ivBack
:
View
?
=
null
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
fragment_image_photo_layout
,
container
,
false
)
}
@CallSuper
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
initView
(
view
)
initData
()
}
@CallSuper
override
fun
onStop
()
{
ZoomMediaLoader
.
getInstance
().
loader
.
onStop
(
this
)
super
.
onStop
()
}
@CallSuper
override
fun
onDestroyView
()
{
super
.
onDestroyView
()
release
()
}
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
super
.
setUserVisibleHint
(
isVisibleToUser
)
isVisiable
=
isVisibleToUser
if
(!
isVisibleToUser
&&
beanViewInfo
!=
null
)
{
videoView
!!
.
seekTo
(
0
)
seekBar
!!
.
progress
=
0
videoView
!!
.
pause
()
if
(
ivPlay
!=
null
&&
!
TextUtils
.
isEmpty
(
beanViewInfo
!!
.
videoUrl
))
{
ivPlay
!!
.
visibility
=
VISIBLE
if
(
ivImg
!=
null
)
{
ivImg
!!
.
visibility
=
VISIBLE
}
}
stopTiming
()
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
ZoomMediaLoader
.
getInstance
().
loader
.
clearMemory
(
requireActivity
())
}
fun
release
()
{
isTransPhoto
=
false
if
(
videoView
!=
null
)
{
videoView
!!
.
release
(
true
)
stopTiming
()
}
}
/**
* 初始化控件
*/
private
fun
initView
(
view
:
View
)
{
loading
=
view
.
findViewById
(
R
.
id
.
loading
)
imageView
=
view
.
findViewById
(
R
.
id
.
photoView
)
btnVideo
=
view
.
findViewById
(
R
.
id
.
btnVideo
)
rootView
=
view
.
findViewById
(
R
.
id
.
rootView
)
rootView
?.
setDrawingCacheEnabled
(
false
)
imageView
?.
setDrawingCacheEnabled
(
false
)
btnLL
=
view
.
findViewById
(
R
.
id
.
btnLL
)
imageView
?.
setOnDragListener
(
object
:
OnDragListener
{
override
fun
drag
()
{
(
activity
as
GPreviewActivity
?)
!!
.
hindView
()
}
override
fun
actionCancel
()
{
(
activity
as
GPreviewActivity
?)
!!
.
showView
()
}
})
videoContainer
=
view
.
findViewById
(
R
.
id
.
videoContainer
)
videoView
=
view
.
findViewById
(
R
.
id
.
videoView
)
seekBar
=
view
.
findViewById
(
R
.
id
.
seekbar
)
ivPlay
=
view
.
findViewById
(
R
.
id
.
ivPlay
)
ivImg
=
view
.
findViewById
(
R
.
id
.
ivImage
)
mySimpleTarget
=
object
:
MySimpleTarget
{
override
fun
onResourceReady
()
{
loading
?.
setVisibility
(
GONE
)
// String video = beanViewInfo.getVideoUrl();
// if (video != null && !video.isEmpty()) {
// btnVideo.setVisibility(View.VISIBLE);
// ViewCompat.animate(btnVideo).alpha(1).setDuration(1000).start();
// } else {
// btnVideo.setVisibility(View.GONE);
// }
}
override
fun
onLoadFailed
(
errorDrawable
:
Drawable
?)
{
loading
?.
setVisibility
(
GONE
)
if
(
errorDrawable
!=
null
)
{
imageView
?.
setImageDrawable
(
errorDrawable
)
}
}
}
}
/**
* 初始化数据
*/
private
fun
initData
()
{
val
bundle
=
arguments
var
isSingleFling
=
true
// 非动画进入的Fragment,默认背景为黑色
if
(
bundle
!=
null
)
{
isSingleFling
=
bundle
.
getBoolean
(
KEY_SING_FILING
)
//地址
beanViewInfo
=
bundle
.
getParcelable
(
KEY_PATH
)
assert
(
beanViewInfo
!=
null
)
//imageView.setDrag(bundle.getBoolean(KEY_DRAG), bundle.getFloat(KEY_SEN));
imageView
!!
.
setThumbRect
(
beanViewInfo
?.
getBounds
())
rootView
!!
.
tag
=
beanViewInfo
?.
getUrl
()
//是否展示动画
isTransPhoto
=
bundle
.
getBoolean
(
KEY_TRANS_PHOTO
,
false
)
if
(!
TextUtils
.
isEmpty
(
beanViewInfo
!!
.
getUrl
()))
{
ivPlay
!!
.
visibility
=
GONE
if
(
beanViewInfo
!!
.
getUrl
().
toLowerCase
().
contains
(
".gif"
))
{
imageView
!!
.
visibility
=
VISIBLE
videoContainer
!!
.
visibility
=
GONE
imageView
!!
.
setZoomable
(
false
)
//加载图
ZoomMediaLoader
.
getInstance
().
loader
.
displayGifImage
(
this
,
beanViewInfo
!!
.
getUrl
(),
imageView
,
mySimpleTarget
!!
)
}
else
{
//加载图
ZoomMediaLoader
.
getInstance
().
loader
.
displayImage
(
this
,
beanViewInfo
!!
.
getUrl
(),
imageView
,
mySimpleTarget
!!
)
}
}
else
{
ivPlay
!!
.
visibility
=
VISIBLE
videoContainer
!!
.
visibility
=
VISIBLE
imageView
!!
.
visibility
=
GONE
ZoomMediaLoader
.
getInstance
().
loader
.
displayImage
(
this
,
"https://hellorfimg.zcool.cn/preview260/123343987.jpg"
,
ivImg
,
mySimpleTarget
!!
)
val
videoUlr
=
beanViewInfo
!!
.
getVideoUrl
()
if
(!
TextUtils
.
isEmpty
(
videoUlr
))
{
rootView
!!
.
setBackgroundColor
(
Color
.
BLACK
)
seekBar
!!
.
visibility
=
VISIBLE
videoView
!!
.
setVideoURI
(
Uri
.
parse
(
videoUlr
))
videoView
!!
.
setOnPreparedListener
{
iMediaPlayer
->
loading
!!
.
visibility
=
GONE
isPrepared
=
true
val
maxProgress
=
iMediaPlayer
.
duration
.
toInt
()
if
(
maxProgress
>
0
)
{
seekBar
!!
.
max
=
maxProgress
}
else
{
seekBar
!!
.
visibility
=
GONE
}
}
videoView
!!
.
setOnCompletionListener
{
isCompletion
=
true
videoView
!!
.
seekTo
(
0
)
stopTiming
()
ivPlay
!!
.
visibility
=
VISIBLE
}
videoView
!!
.
setOnInfoListener
{
iMediaPlayer
,
what
,
extra
->
if
(
what
==
IMediaPlayer
.
MEDIA_INFO_BUFFERING_START
&&
!
isCompletion
&&
isVisiable
)
{
show
(
context
,
"正在加载"
)
}
else
if
(
what
==
IMediaPlayer
.
MEDIA_INFO_BUFFERING_END
)
{
close
()
}
true
}
ivPlay
!!
.
setOnClickListener
{
if
(!
isPrepared
)
{
loading
!!
.
visibility
=
VISIBLE
}
ivImg
!!
.
visibility
=
GONE
ivPlay
!!
.
visibility
=
GONE
startTiming
()
videoView
!!
.
start
()
isCompletion
=
false
}
videoContainer
!!
.
setOnClickListener
{
if
(
videoView
!!
.
isPlaying
)
{
ivPlay
!!
.
visibility
=
VISIBLE
stopTiming
()
videoView
!!
.
pause
()
}
}
seekBar
!!
.
setOnSeekBarChangeListener
(
object
:
SeekBar
.
OnSeekBarChangeListener
{
override
fun
onProgressChanged
(
seekBar
:
SeekBar
,
progress
:
Int
,
fromUser
:
Boolean
)
{
}
override
fun
onStartTrackingTouch
(
seekBar
:
SeekBar
)
{
isTouch
=
true
}
override
fun
onStopTrackingTouch
(
seekBar
:
SeekBar
)
{
isTouch
=
false
if
(
seekBar
!=
null
)
{
videoView
!!
.
seekTo
(
seekBar
.
progress
)
videoView
!!
.
start
()
ivPlay
!!
.
visibility
=
GONE
isCompletion
=
false
}
}
})
}
}
}
if
(!
isTransPhoto
)
{
rootView
!!
.
setBackgroundColor
(
Color
.
BLACK
)
}
else
{
imageView
!!
.
minimumScale
=
0.7f
}
if
(
isSingleFling
)
{
imageView
!!
.
setOnViewTapListener
{
view
,
x
,
y
->
}
imageView
!!
.
setOnViewTapListener
{
view
,
x
,
y
->
if
(
imageView
!!
.
checkMinScale
())
{
(
activity
as
GPreviewActivity
?)
!!
.
transformOut
()
}
}
}
else
{
imageView
!!
.
setOnPhotoTapListener
(
object
:
PhotoViewAttacher
.
OnPhotoTapListener
{
override
fun
onPhotoTap
(
view
:
View
,
x
:
Float
,
y
:
Float
)
{
if
(
imageView
!!
.
checkMinScale
())
{
(
activity
as
GPreviewActivity
?)
!!
.
transformOutAnim
()
(
activity
as
GPreviewActivity
?)
!!
.
transformOut
()
}
}
override
fun
onOutsidePhotoTap
()
{}
})
}
imageView
!!
.
setAlphaChangeListener
{
alpha
->
if
(
alpha
==
255
)
{
val
video
=
beanViewInfo
!!
.
videoUrl
if
(
video
!=
null
&&
!
video
.
isEmpty
())
{
btnVideo
!!
.
visibility
=
VISIBLE
}
else
{
btnVideo
!!
.
visibility
=
GONE
}
}
else
{
btnVideo
!!
.
visibility
=
GONE
}
rootView
!!
.
setBackgroundColor
(
getColorWithAlpha
(
alpha
/
255f
,
Color
.
BLACK
)
)
}
imageView
!!
.
setTransformOutListener
{
(
activity
as
GPreviewActivity
?)
!!
.
transformOut
()
}
}
fun
transformIn
()
{
assert
(
imageView
!=
null
)
imageView
!!
.
transformIn
{
rootView
!!
.
setBackgroundColor
(
Color
.
BLACK
)
}
}
fun
transformOut
(
listener
:
onTransformListener
?)
{
assert
(
imageView
!=
null
)
imageView
!!
.
transformOut
(
listener
)
}
fun
changeBg
(
color
:
Int
)
{
ViewCompat
.
animate
(
btnVideo
!!
).
alpha
(
0f
).
setDuration
(
getDuration
().
toLong
()).
start
()
rootView
!!
.
setBackgroundColor
(
color
)
}
private
fun
startTiming
()
{
disposable
=
Observable
.
interval
(
3
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribeOn
(
Schedulers
.
computation
())
.
subscribe
{
// val pos = (video?.mMediaPlayer as IjkMediaPlayer?)?.currentPosition ?: 0
// if (pos > 0) {
//// if (vm?.isVideo == true) {
//// binding.ivCover.visibility = View.GONE
//// }
// if (!isTouch) {
// binding.seekbar.progress = pos.toInt()// video.bufferPercentage
// }
// if (video?.isPlaying == true) {
// when (vm?.isVideo) {
// true -> {
// binding.ivPlay.visibility = View.GONE
// }
// false -> {
// binding.voicePlay.start()
// }
// }
// }
// }
if
(
videoView
!=
null
&&
!
isTouch
)
{
val
currentPosition
=
videoView
!!
.
currentPosition
seekBar
!!
.
progress
=
currentPosition
}
}
}
private
fun
stopTiming
()
{
if
(
disposable
!=
null
)
{
disposable
!!
.
dispose
()
disposable
=
null
}
}
interface
OnDragListener
{
fun
drag
()
fun
actionCancel
()
}
companion
object
{
/**
* 预览图片 类型
*/
private
const
val
KEY_TRANS_PHOTO
=
"is_trans_photo"
private
const
val
KEY_SING_FILING
=
"isSingleFling"
private
const
val
KEY_PATH
=
"key_item"
private
const
val
KEY_DRAG
=
"isDrag"
private
const
val
KEY_SEN
=
"sensitivity"
// public static VideoClickListener listener;
fun
getInstance
(
fragmentClass
:
Class
<
out
BasePhotoFragment
>,
item
:
IThumbViewInfo
?,
currentIndex
:
Boolean
,
isSingleFling
:
Boolean
,
isDrag
:
Boolean
,
sensitivity
:
Float
):
BasePhotoFragment
{
val
fragment
:
BasePhotoFragment
fragment
=
try
{
fragmentClass
.
newInstance
()
}
catch
(
e
:
Exception
)
{
BasePhotoFragment
()
}
val
bundle
=
Bundle
()
bundle
.
putParcelable
(
KEY_PATH
,
item
)
bundle
.
putBoolean
(
KEY_TRANS_PHOTO
,
currentIndex
)
bundle
.
putBoolean
(
KEY_SING_FILING
,
isSingleFling
)
bundle
.
putBoolean
(
KEY_DRAG
,
isDrag
)
bundle
.
putFloat
(
KEY_SEN
,
sensitivity
)
fragment
.
arguments
=
bundle
return
fragment
}
fun
getColorWithAlpha
(
alpha
:
Float
,
baseColor
:
Int
):
Int
{
val
a
=
Math
.
min
(
255
,
Math
.
max
(
0
,
(
alpha
*
255
).
toInt
()))
shl
24
val
rgb
=
0
x00ffffff
and
baseColor
return
a
+
rgb
}
}
}
\ No newline at end of file
m-consultant/src/main/java/com/yidianling/consultant/preview/GPreviewActivity.java
deleted
100644 → 0
View file @
de89a4c2
package
com
.
yidianling
.
consultant
.
preview
;
import
android.animation.ObjectAnimator
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.TextView
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentManager
;
import
androidx.fragment.app.FragmentStatePagerAdapter
;
import
androidx.viewpager.widget.ViewPager
;
import
com.yidianling.consultant.R
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author rainb
*/
public
class
GPreviewActivity
extends
AppCompatActivity
{
protected
boolean
isTransformOut
=
false
;
/*** 图片的地址***/
private
List
<
IThumbViewInfo
>
imgUrls
;
/*** 当前图片的位置 ***/
protected
int
currentIndex
;
/***指示器类型枚举***/
private
GPreviewBuilder
.
IndicatorType
type
;
/***默认显示***/
private
boolean
isShow
=
true
;
/*** 展示图片的viewPager ***/
private
PhotoViewPager
viewPager
;
/*** 图片的展示的Fragment***/
private
List
<
BasePhotoFragment
>
fragments
=
new
ArrayList
<>();
private
View
backIv
;
private
View
btnLL
;
private
View
titleBar
;
private
TextView
selectPosition
;
private
TextView
total
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
initData
();
setContentView
(
R
.
layout
.
consultant_image_preview_photo
);
initView
();
}
private
void
initView
()
{
viewPager
=
findViewById
(
R
.
id
.
viewPager
);
//viewPager的适配器
PhotoPagerAdapter
adapter
=
new
PhotoPagerAdapter
(
getSupportFragmentManager
());
viewPager
.
setAdapter
(
adapter
);
viewPager
.
setCurrentItem
(
currentIndex
);
backIv
=
findViewById
(
R
.
id
.
ivBack
);
btnLL
=
findViewById
(
R
.
id
.
btnLL
);
selectPosition
=
findViewById
(
R
.
id
.
select_position
);
total
=
findViewById
(
R
.
id
.
total
);
titleBar
=
findViewById
(
R
.
id
.
titleBar
);
backIv
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
transformOutAnim
();
transformOut
();
}
});
selectPosition
.
setText
((
currentIndex
+
1
)
+
""
);
total
.
setText
(
imgUrls
==
null
?
"0"
:
imgUrls
.
size
()
+
""
);
viewPager
.
addOnPageChangeListener
(
new
ViewPager
.
OnPageChangeListener
()
{
@Override
public
void
onPageScrolled
(
int
position
,
float
positionOffset
,
int
positionOffsetPixels
)
{
}
@Override
public
void
onPageSelected
(
int
position
)
{
selectPosition
.
setText
((
position
+
1
)
+
""
);
}
@Override
public
void
onPageScrollStateChanged
(
int
state
)
{
}
});
// viewPager.setOffscreenPageLimit(3);
}
private
void
initData
()
{
imgUrls
=
getIntent
().
getParcelableArrayListExtra
(
"imagePaths"
);
currentIndex
=
getIntent
().
getIntExtra
(
"position"
,
-
1
);
type
=
(
GPreviewBuilder
.
IndicatorType
)
getIntent
().
getSerializableExtra
(
"type"
);
isShow
=
getIntent
().
getBooleanExtra
(
"isShow"
,
true
);
boolean
isFullscreen
=
getIntent
().
getBooleanExtra
(
"isFullscreen"
,
false
);
boolean
isScale
=
getIntent
().
getBooleanExtra
(
"isScale"
,
false
);
SmoothImageView
.
setFullscreen
(
isFullscreen
);
SmoothImageView
.
setIsScale
(
isScale
);
if
(
isFullscreen
)
{
setTheme
(
android
.
R
.
style
.
Theme_Translucent_NoTitleBar_Fullscreen
);
}
initFragment
(
imgUrls
,
currentIndex
,
BasePhotoFragment
.
class
);
}
private
void
initFragment
(
List
<
IThumbViewInfo
>
imgUrls
,
int
currentIndex
,
Class
<
BasePhotoFragment
>
className
)
{
if
(
imgUrls
!=
null
)
{
int
size
=
imgUrls
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
fragments
.
add
(
BasePhotoFragment
.
getInstance
(
className
,
imgUrls
.
get
(
i
),
currentIndex
==
i
,
getIntent
().
getBooleanExtra
(
"isSingleFling"
,
false
),
getIntent
().
getBooleanExtra
(
"isDrag"
,
false
),
getIntent
().
getFloatExtra
(
"sensitivity"
,
0.5f
))
);
}
}
else
{
finish
();
}
}
@Override
protected
void
onDestroy
()
{
ZoomMediaLoader
.
getInstance
().
getLoader
().
clearMemory
(
this
);
if
(
viewPager
!=
null
)
{
viewPager
.
setAdapter
(
null
);
viewPager
.
clearOnPageChangeListeners
();
viewPager
.
removeAllViews
();
viewPager
=
null
;
}
if
(
fragments
!=
null
)
{
fragments
.
clear
();
fragments
=
null
;
}
if
(
imgUrls
!=
null
)
{
imgUrls
.
clear
();
imgUrls
=
null
;
}
super
.
onDestroy
();
}
/***
* 得到PhotoViewPager
* @return PhotoViewPager
* **/
public
PhotoViewPager
getViewPager
()
{
return
viewPager
;
}
public
void
transformOut
()
{
if
(
isTransformOut
)
{
return
;
}
getViewPager
().
setEnabled
(
false
);
isTransformOut
=
true
;
int
currentItem
=
viewPager
.
getCurrentItem
();
if
(
currentItem
<
imgUrls
.
size
())
{
if
(
TextUtils
.
isEmpty
(
imgUrls
.
get
(
currentItem
).
getVideoUrl
()))
{
BasePhotoFragment
fragment
=
fragments
.
get
(
currentItem
);
fragment
.
changeBg
(
Color
.
TRANSPARENT
);
fragment
.
transformOut
(
new
SmoothImageView
.
onTransformListener
()
{
@Override
public
void
onTransformCompleted
(
SmoothImageView
.
Status
status
)
{
getViewPager
().
setEnabled
(
true
);
exit
();
}
});
}
else
{
exit
();
}
}
else
{
exit
();
}
}
/**
* 关闭页面
*/
private
void
exit
()
{
finish
();
overridePendingTransition
(
0
,
0
);
}
@Override
public
void
onBackPressed
()
{
isTransformOut
=
false
;
transformOut
();
}
@Override
public
void
finish
()
{
// BasePhotoFragment.listener=null;
super
.
finish
();
}
/**
* pager的适配器
*/
private
class
PhotoPagerAdapter
extends
FragmentStatePagerAdapter
{
PhotoPagerAdapter
(
FragmentManager
fm
)
{
super
(
fm
);
}
@Override
public
Fragment
getItem
(
int
position
)
{
return
fragments
.
get
(
position
);
}
@Override
public
int
getCount
()
{
return
fragments
==
null
?
0
:
fragments
.
size
();
}
}
public
void
hindView
()
{
titleBar
.
setVisibility
(
View
.
GONE
);
btnLL
.
setVisibility
(
View
.
GONE
);
}
public
void
showView
()
{
titleBar
.
setVisibility
(
View
.
VISIBLE
);
btnLL
.
setVisibility
(
View
.
VISIBLE
);
}
public
void
transformOutAnim
()
{
ObjectAnimator
animator1
=
ObjectAnimator
.
ofFloat
(
titleBar
,
"alpha"
,
1.0f
,
0.0f
);
animator1
.
setDuration
(
200
);
animator1
.
start
();
ObjectAnimator
animator2
=
ObjectAnimator
.
ofFloat
(
btnLL
,
"alpha"
,
1.0f
,
0.0f
);
animator2
.
setDuration
(
200
);
animator2
.
start
();
}
}
m-consultant/src/main/java/com/yidianling/consultant/preview/GPreviewActivity.kt
0 → 100644
View file @
cbc5b96c
package
com.yidianling.consultant.preview
import
android.animation.ObjectAnimator
import
android.annotation.SuppressLint
import
android.graphics.Color
import
android.os.Build
import
android.os.Bundle
import
android.text.TextUtils
import
android.view.View
import
android.view.WindowManager
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.FragmentManager
import
androidx.fragment.app.FragmentStatePagerAdapter
import
androidx.viewpager.widget.ViewPager
import
com.yidianling.consultant.R
import
com.yidianling.consultant.preview.GPreviewBuilder.IndicatorType
import
com.yidianling.consultant.preview.SmoothImageView.onTransformListener
import
java.util.*
/**
* @author rainb
*/
class
GPreviewActivity
:
AppCompatActivity
()
{
protected
var
isTransformOut
=
false
/*** 图片的地址 */
private
var
imgUrls
:
MutableList
<
IThumbViewInfo
>?
=
null
/*** 当前图片的位置 */
protected
var
currentIndex
=
0
/***指示器类型枚举 */
private
var
type
:
IndicatorType
?
=
null
/***默认显示 */
private
var
isShow
=
true
/***
* 得到PhotoViewPager
* @return PhotoViewPager
*/
/*** 展示图片的viewPager */
var
viewPager
:
PhotoViewPager
?
=
null
private
set
/*** 图片的展示的Fragment */
private
var
fragments
:
MutableList
<
BasePhotoFragment
>?
=
ArrayList
()
private
var
backIv
:
View
?
=
null
private
var
btnLL
:
View
?
=
null
private
var
titleBar
:
View
?
=
null
private
var
selectPosition
:
TextView
?
=
null
private
var
total
:
TextView
?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
initData
()
setContentView
(
R
.
layout
.
consultant_image_preview_photo
)
initView
()
initStatusBar
()
}
/**
* 初始化状态栏位置
*/
private
fun
initStatusBar
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
window
?.
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
)
window
?.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
)
window
?.
statusBarColor
=
Color
.
WHITE
window
?.
decorView
?.
systemUiVisibility
=
View
.
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
}
private
fun
initView
()
{
viewPager
=
findViewById
(
R
.
id
.
viewPager
)
//viewPager的适配器
val
adapter
=
PhotoPagerAdapter
(
supportFragmentManager
)
viewPager
?.
adapter
=
adapter
viewPager
?.
currentItem
=
currentIndex
backIv
=
findViewById
(
R
.
id
.
ivBack
)
btnLL
=
findViewById
(
R
.
id
.
btnLL
)
selectPosition
=
findViewById
(
R
.
id
.
select_position
)
total
=
findViewById
(
R
.
id
.
total
)
titleBar
=
findViewById
(
R
.
id
.
titleBar
)
backIv
?.
setOnClickListener
(
View
.
OnClickListener
{
transformOutAnim
()
transformOut
()
})
selectPosition
?.
setText
((
currentIndex
+
1
).
toString
()
+
""
)
total
?.
setText
(
if
(
imgUrls
==
null
)
"0"
else
imgUrls
!!
.
size
.
toString
()
+
""
)
viewPager
?.
addOnPageChangeListener
(
object
:
ViewPager
.
OnPageChangeListener
{
override
fun
onPageScrolled
(
position
:
Int
,
positionOffset
:
Float
,
positionOffsetPixels
:
Int
)
{
}
override
fun
onPageSelected
(
position
:
Int
)
{
selectPosition
?.
setText
((
position
+
1
).
toString
()
+
""
)
}
override
fun
onPageScrollStateChanged
(
state
:
Int
)
{}
})
// viewPager.setOffscreenPageLimit(3);
}
private
fun
initData
()
{
imgUrls
=
intent
.
getParcelableArrayListExtra
(
"imagePaths"
)
currentIndex
=
intent
.
getIntExtra
(
"position"
,
-
1
)
type
=
intent
.
getSerializableExtra
(
"type"
)
as
IndicatorType
isShow
=
intent
.
getBooleanExtra
(
"isShow"
,
true
)
val
isScale
=
intent
.
getBooleanExtra
(
"isScale"
,
false
)
SmoothImageView
.
setIsScale
(
isScale
)
initFragment
(
imgUrls
,
currentIndex
,
BasePhotoFragment
::
class
.
java
)
}
private
fun
initFragment
(
imgUrls
:
List
<
IThumbViewInfo
>?,
currentIndex
:
Int
,
className
:
Class
<
BasePhotoFragment
>
)
{
if
(
imgUrls
!=
null
)
{
val
size
=
imgUrls
.
size
for
(
i
in
0
until
size
)
{
fragments
!!
.
add
(
BasePhotoFragment
.
getInstance
(
className
,
imgUrls
[
i
],
currentIndex
==
i
,
intent
.
getBooleanExtra
(
"isSingleFling"
,
false
),
intent
.
getBooleanExtra
(
"isDrag"
,
false
),
intent
.
getFloatExtra
(
"sensitivity"
,
0.5f
)
)
)
}
}
else
{
finish
()
}
}
override
fun
onDestroy
()
{
ZoomMediaLoader
.
getInstance
().
loader
.
clearMemory
(
this
)
if
(
viewPager
!=
null
)
{
viewPager
!!
.
adapter
=
null
viewPager
!!
.
clearOnPageChangeListeners
()
viewPager
!!
.
removeAllViews
()
viewPager
=
null
}
if
(
fragments
!=
null
)
{
fragments
!!
.
clear
()
fragments
=
null
}
if
(
imgUrls
!=
null
)
{
imgUrls
!!
.
clear
()
imgUrls
=
null
}
super
.
onDestroy
()
}
/***
* 得到PhotoViewPager
* @return PhotoViewPager
*/
@JvmName
(
"getViewPager1"
)
fun
getViewPager
():
PhotoViewPager
?
{
return
viewPager
}
fun
transformOut
()
{
if
(
isTransformOut
)
{
return
}
viewPager
!!
.
isEnabled
=
false
isTransformOut
=
true
val
currentItem
=
viewPager
!!
.
currentItem
if
(
currentItem
<
imgUrls
!!
.
size
)
{
if
(
TextUtils
.
isEmpty
(
imgUrls
!!
[
currentItem
].
videoUrl
))
{
val
fragment
=
fragments
!!
[
currentItem
]
fragment
.
changeBg
(
Color
.
TRANSPARENT
)
fragment
.
transformOut
(
onTransformListener
{
getViewPager
()
?.
setEnabled
(
true
)
exit
()
})
}
else
{
exit
()
}
}
else
{
exit
()
}
}
/**
* 关闭页面
*/
private
fun
exit
()
{
finish
()
overridePendingTransition
(
0
,
0
)
}
override
fun
onBackPressed
()
{
isTransformOut
=
false
transformOutAnim
()
transformOut
()
}
override
fun
finish
()
{
// BasePhotoFragment.listener=null;
super
.
finish
()
}
/**
* pager的适配器
*/
private
inner
class
PhotoPagerAdapter
internal
constructor
(
fm
:
FragmentManager
?)
:
FragmentStatePagerAdapter
(
fm
!!
)
{
override
fun
getItem
(
position
:
Int
):
Fragment
{
return
fragments
!!
[
position
]
}
override
fun
getCount
():
Int
{
return
if
(
fragments
==
null
)
0
else
fragments
!!
.
size
}
}
fun
hindView
()
{
titleBar
!!
.
visibility
=
View
.
GONE
btnLL
!!
.
visibility
=
View
.
GONE
}
fun
showView
()
{
titleBar
!!
.
visibility
=
View
.
VISIBLE
btnLL
!!
.
visibility
=
View
.
VISIBLE
}
@SuppressLint
(
"ObjectAnimatorBinding"
)
fun
transformOutAnim
()
{
val
animator1
=
ObjectAnimator
.
ofFloat
(
titleBar
,
"alpha"
,
1.0f
,
0.0f
)
animator1
.
duration
=
200
animator1
.
start
()
val
animator2
=
ObjectAnimator
.
ofFloat
(
btnLL
,
"alpha"
,
1.0f
,
0.0f
)
animator2
.
duration
=
200
animator2
.
start
()
}
}
\ No newline at end of file
m-consultant/src/main/res/layout/consultant_image_preview_photo.xml
View file @
cbc5b96c
...
...
@@ -18,7 +18,7 @@
android:layout_alignParentBottom=
"true"
android:layout_marginBottom=
"@dimen/platform_dp_40"
>
<
Button
<
TextView
android:id=
"@+id/chatBtn"
android:layout_width=
"148dp"
android:layout_height=
"47dp"
...
...
@@ -26,11 +26,12 @@
android:layout_marginLeft=
"@dimen/platform_dp_20"
android:background=
"@drawable/consultant_bg_btn_chat"
android:text=
"立即私聊"
android:gravity=
"center"
android:textColor=
"@color/white"
android:textSize=
"17sp"
android:textStyle=
"bold"
/>
<
Button
<
TextView
android:id=
"@+id/bookingBtn"
android:layout_width=
"148dp"
android:layout_height=
"47dp"
...
...
@@ -39,6 +40,7 @@
android:layout_marginRight=
"@dimen/platform_dp_20"
android:background=
"@drawable/consultant_bg_btn_book"
android:text=
"立即预约"
android:gravity=
"center"
android:textColor=
"@color/white"
android:textSize=
"17sp"
android:textStyle=
"bold"
/>
...
...
m-consultant/src/main/res/values/styles.xml
View file @
cbc5b96c
<resources>
<resources
xmlns:tools=
"http://schemas.android.com/tools"
>
<style
name=
"consultant_FilterTextViewStyle"
>
<item
name=
"android:layout_height"
>
40dp
</item>
...
...
@@ -38,11 +38,11 @@
<item
name=
"android:backgroundDimEnabled"
>
true
</item>
</style>
<style
name=
"consultant_Transparent"
parent=
"@style/Base.Theme.AppCompat"
>
<item
name=
"colorPrimary"
>
@color/transparent
</item>
<item
name=
"colorPrimaryDark"
>
@color/transparent
</item>
<style
name=
"consultant_Transparent"
parent=
"Theme.AppCompat.DayNight.NoActionBar"
>
<item
name=
"android:windowBackground"
>
@color/transparent
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
</style>
</resources>
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