Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_flowbox
Project
Project
Details
Activity
Releases
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
android
android_flowbox
Commits
4e210681
Commit
4e210681
authored
Jun 30, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加gif图只展示一次
parent
480e3b02
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
3 deletions
+85
-3
AboutusActivity.kt
...in/java/com/mints/flowbox/ui/activitys/AboutusActivity.kt
+7
-0
GlideUtils.java
app/src/main/java/com/mints/library/utils/GlideUtils.java
+75
-0
gradle.properties
gradle.properties
+3
-3
No files found.
app/src/main/java/com/mints/flowbox/ui/activitys/AboutusActivity.kt
View file @
4e210681
...
@@ -14,6 +14,7 @@ import com.mints.flowbox.ui.activitys.base.BaseActivity
...
@@ -14,6 +14,7 @@ import com.mints.flowbox.ui.activitys.base.BaseActivity
import
com.mints.flowbox.utils.ToastUtil
import
com.mints.flowbox.utils.ToastUtil
import
com.mints.library.utils.CommonUtils
import
com.mints.library.utils.CommonUtils
import
com.mints.library.utils.ConstantUtil
import
com.mints.library.utils.ConstantUtil
import
com.mints.library.utils.GlideUtils
import
kotlinx.android.synthetic.main.activity_aboutus.*
import
kotlinx.android.synthetic.main.activity_aboutus.*
import
kotlinx.android.synthetic.main.header_layout.*
import
kotlinx.android.synthetic.main.header_layout.*
import
java.util.*
import
java.util.*
...
@@ -37,6 +38,12 @@ class AboutusActivity : BaseActivity(), View.OnClickListener {
...
@@ -37,6 +38,12 @@ class AboutusActivity : BaseActivity(), View.OnClickListener {
iv_left_icon
.
visibility
=
View
.
VISIBLE
iv_left_icon
.
visibility
=
View
.
VISIBLE
iv_left_icon
.
setImageResource
(
R
.
mipmap
.
ic_arrow_back
)
iv_left_icon
.
setImageResource
(
R
.
mipmap
.
ic_arrow_back
)
// GlideUtils.loadOneTimeGif(this,R.drawable.wifi_speed,iv_left_icon,object:GlideUtils.GifListener{
// override fun gifPlayComplete() {
//
// }
// })
ivAboutasIcon
.
setOnLongClickListener
{
ivAboutasIcon
.
setOnLongClickListener
{
ToastUtil
.
showLong
(
ToastUtil
.
showLong
(
MintsApplication
.
getContext
(),
"自有渠道:"
+
CommonUtils
.
getAppMetaData
(
MintsApplication
.
getContext
(),
"自有渠道:"
+
CommonUtils
.
getAppMetaData
(
...
...
app/src/main/java/com/mints/library/utils/GlideUtils.java
View file @
4e210681
...
@@ -3,12 +3,23 @@ package com.mints.library.utils;
...
@@ -3,12 +3,23 @@ package com.mints.library.utils;
import
android.content.Context
;
import
android.content.Context
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
androidx.annotation.Nullable
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Priority
;
import
com.bumptech.glide.Priority
;
import
com.bumptech.glide.load.DataSource
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.load.engine.GlideException
;
import
com.bumptech.glide.load.resource.gif.GifDrawable
;
import
com.bumptech.glide.request.RequestListener
;
import
com.bumptech.glide.request.RequestOptions
;
import
com.bumptech.glide.request.RequestOptions
;
import
com.bumptech.glide.request.target.Target
;
import
com.bumptech.glide.signature.ObjectKey
;
import
com.bumptech.glide.signature.ObjectKey
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
/**
/**
* 描述:GlideUtils
* 描述:GlideUtils
* 作者:孟崔广
* 作者:孟崔广
...
@@ -71,4 +82,68 @@ public class GlideUtils {
...
@@ -71,4 +82,68 @@ public class GlideUtils {
.
priority
(
Priority
.
HIGH
);
.
priority
(
Priority
.
HIGH
);
Glide
.
with
(
mContext
).
load
(
url
).
apply
(
options
).
into
(
view
);
Glide
.
with
(
mContext
).
load
(
url
).
apply
(
options
).
into
(
view
);
}
}
//只加载一次Gif
public
static
void
loadOneTimeGif
(
Context
context
,
Object
model
,
final
ImageView
imageView
,
final
GifListener
gifListener
)
{
Glide
.
with
(
context
).
asGif
().
load
(
model
).
listener
(
new
RequestListener
<
GifDrawable
>()
{
@Override
public
boolean
onLoadFailed
(
@Nullable
GlideException
e
,
Object
model
,
Target
<
GifDrawable
>
target
,
boolean
isFirstResource
)
{
return
false
;
}
@Override
public
boolean
onResourceReady
(
GifDrawable
resource
,
Object
model
,
Target
<
GifDrawable
>
target
,
DataSource
dataSource
,
boolean
isFirstResource
)
{
try
{
Field
gifStateField
=
GifDrawable
.
class
.
getDeclaredField
(
"state"
);
gifStateField
.
setAccessible
(
true
);
Class
gifStateClass
=
Class
.
forName
(
"com.bumptech.glide.load.resource.gif.GifDrawable$GifState"
);
Field
gifFrameLoaderField
=
gifStateClass
.
getDeclaredField
(
"frameLoader"
);
gifFrameLoaderField
.
setAccessible
(
true
);
Class
gifFrameLoaderClass
=
Class
.
forName
(
"com.bumptech.glide.load.resource.gif.GifFrameLoader"
);
Field
gifDecoderField
=
gifFrameLoaderClass
.
getDeclaredField
(
"gifDecoder"
);
gifDecoderField
.
setAccessible
(
true
);
Class
gifDecoderClass
=
Class
.
forName
(
"com.bumptech.glide.gifdecoder.GifDecoder"
);
Object
gifDecoder
=
gifDecoderField
.
get
(
gifFrameLoaderField
.
get
(
gifStateField
.
get
(
resource
)));
Method
getDelayMethod
=
gifDecoderClass
.
getDeclaredMethod
(
"getDelay"
,
int
.
class
);
getDelayMethod
.
setAccessible
(
true
);
//设置只播放一次
resource
.
setLoopCount
(
1
);
//获得总帧数
int
count
=
resource
.
getFrameCount
();
int
delay
=
0
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
//计算每一帧所需要的时间进行累加
delay
+=
(
int
)
getDelayMethod
.
invoke
(
gifDecoder
,
i
);
}
imageView
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
gifListener
!=
null
)
{
gifListener
.
gifPlayComplete
();
}
}
},
delay
);
}
catch
(
NoSuchFieldException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchMethodException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
}).
into
(
imageView
);
}
/**
* Gif播放完毕回调
*/
public
interface
GifListener
{
void
gifPlayComplete
();
}
}
}
gradle.properties
View file @
4e210681
...
@@ -26,11 +26,11 @@ RELEASE_STORE_PASSWORD=mints.flowbox
...
@@ -26,11 +26,11 @@ RELEASE_STORE_PASSWORD=mints.flowbox
RELEASE_STORE_FILE
=
mints_flowbox.jks
RELEASE_STORE_FILE
=
mints_flowbox.jks
#ShareSDK
#ShareSDK
RELEASE_SHARESDK_KEY
=
3
28d2edfe42fa
RELEASE_SHARESDK_KEY
=
3
387a05ec068c
RELEASE_SHARESDK_SECRET
=
3586272d2ddd7d9de497cdede529ced3
RELEASE_SHARESDK_SECRET
=
7e0819d930224b62c492fa32b84d42a2
#友盟
#友盟
RELEASE_UMENG_KEY
=
60
4869326ee47d382b7ae112
RELEASE_UMENG_KEY
=
60
d2ef4d8a102159db781cd3
#JPush
#JPush
RELEASE_JPUSH_KEY
=
d9e939e7ec22a9e11dcfc345
RELEASE_JPUSH_KEY
=
d9e939e7ec22a9e11dcfc345
...
...
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