Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
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
1
Merge Requests
1
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
lify
RvApp
Commits
2d488ba7
Commit
2d488ba7
authored
Aug 06, 2019
by
jianglx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改拍拍样式
parent
ac00a7fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
14 deletions
+65
-14
DiscoveryRecommendAdapter.java
...com/xxfc/discovery/adapter/DiscoveryRecommendAdapter.java
+26
-14
TransformationUtils.java
...in/java/com/xxfc/discovery/utils/TransformationUtils.java
+39
-0
No files found.
module_discovery/src/main/java/com/xxfc/discovery/adapter/DiscoveryRecommendAdapter.java
View file @
2d488ba7
...
...
@@ -8,13 +8,18 @@ import android.view.ViewGroup;
import
android.widget.ImageView
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.request.RequestOptions
;
import
com.bumptech.glide.request.target.SimpleTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.BaseViewHolder
;
import
com.ruiwenliu.wrapper.util.glide.GlideManager
;
import
com.ruiwenliu.wrapper.util.glide.GlideOptions
;
import
com.ruiwenliu.wrapper.util.glide.GlideRoundTransform
;
import
com.xxfc.discovery.R
;
import
com.xxfc.discovery.bean.DiscoveryRecommendBean
;
import
com.xxfc.discovery.utils.TransformationUtils
;
import
com.xxfc.imcamera.photopicker.Image
;
/**
* 推荐
...
...
@@ -30,7 +35,6 @@ public class DiscoveryRecommendAdapter extends BaseQuickAdapter<DiscoveryRecomme
}
@Override
protected
void
convert
(
BaseViewHolder
helper
,
DiscoveryRecommendBean
.
DataBeanX
.
DataBean
item
)
{
if
(
item
==
null
)
{
...
...
@@ -41,21 +45,29 @@ public class DiscoveryRecommendAdapter extends BaseQuickAdapter<DiscoveryRecomme
DiscoveryRecommendBean
.
DataBeanX
.
DataBean
.
Body
body
=
item
.
getBody
();
if
(
body
!=
null
)
{
if
(
body
.
getImages
()
!=
null
&&
body
.
getImages
().
size
()
>
0
)
{
Glide
.
with
(
mContext
)
.
asBitmap
()
//强制Glide返回一个Bitmap对象
.
load
(
body
.
getImages
().
get
(
0
).
getOurl
())
.
into
(
new
SimpleTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
bitmap
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
ViewGroup
.
LayoutParams
lp
=
helper
.
getView
(
R
.
id
.
iv_icon_pat
).
getLayoutParams
();
lp
.
height
=
bitmap
.
getHeight
()
*
(
int
)
(
display
.
getWidth
()
/
2
-
60
)
/
bitmap
.
getWidth
()
;
helper
.
getView
(
R
.
id
.
iv_icon_pat
).
setLayoutParams
(
lp
);
}
});
// Glide.with(mContext)
// .asBitmap()//强制Glide返回一个Bitmap对象
// .load(body.getImages().get(0).getOurl())
// .into(new SimpleTarget<Bitmap>() {
// @Override
// public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
// ViewGroup.LayoutParams lp =helper.getView(R.id.iv_icon_pat).getLayoutParams();
// lp.height = bitmap.getHeight() * (int) (display.getWidth() / 2 - 30 ) / bitmap.getWidth() ;
// helper.getView(R.id.iv_icon_pat).setLayoutParams(lp);
// }
// });
// GlideManager.getInstance(mContext).loadRoundImage2(body.getImages().get(0).getOurl(), (ImageView) helper.getView(R.id.iv_icon_pat),8);
ImageView
image
=
helper
.
getView
(
R
.
id
.
iv_icon_pat
);
GlideOptions
options
=
GlideOptions
.
placeholderOf
(
com
.
ruiwenliu
.
wrapper
.
R
.
drawable
.
glide_icon_placeholder
).
error
(
com
.
ruiwenliu
.
wrapper
.
R
.
drawable
.
glide_icon_error
);
GlideManager
.
getInstance
(
mContext
).
loadRoundImage2
(
body
.
getImages
().
get
(
0
).
getOurl
(),
(
ImageView
)
helper
.
getView
(
R
.
id
.
iv_icon_pat
),
8
);
Glide
.
with
(
mContext
)
.
asBitmap
()
.
load
(
body
.
getImages
().
get
(
0
).
getOurl
())
.
apply
(
options
)
.
apply
(
RequestOptions
.
bitmapTransform
(
new
GlideRoundTransform
(
mContext
,
3
)))
.
into
(
new
TransformationUtils
(
image
));
}
helper
.
setText
(
R
.
id
.
tv_title
,
body
.
getText
());
if
(
"4"
.
equals
(
body
.
getType
()))
{
//消息类型 基础属性 1=文字消息、2=图文消息、3=语音消息、4=视频消息、 5=文件消
...
...
module_discovery/src/main/java/com/xxfc/discovery/utils/TransformationUtils.java
0 → 100644
View file @
2d488ba7
package
com
.
xxfc
.
discovery
.
utils
;
import
android.graphics.Bitmap
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
com.bumptech.glide.request.target.ImageViewTarget
;
public
class
TransformationUtils
extends
ImageViewTarget
<
Bitmap
>
{
private
ImageView
target
;
public
TransformationUtils
(
ImageView
target
)
{
super
(
target
);
this
.
target
=
target
;
}
@Override
protected
void
setResource
(
Bitmap
resource
)
{
target
.
setImageBitmap
(
resource
);
if
(
resource
==
null
)
return
;
//获取原图的宽高
int
width
=
resource
.
getWidth
();
int
height
=
resource
.
getHeight
();
//获取imageView的宽
int
imageViewWidth
=
target
.
getWidth
();
//计算缩放比例
float
sy
=
(
float
)
(
imageViewWidth
*
0.1
)
/
(
float
)
(
width
*
0.1
);
//计算图片等比例放大后的高
int
imageViewHeight
=
(
int
)
(
height
*
sy
);
ViewGroup
.
LayoutParams
params
=
target
.
getLayoutParams
();
params
.
height
=
imageViewHeight
;
target
.
setLayoutParams
(
params
);
}
}
\ 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