消息
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.sl.house_property.message;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
||||
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class GlideRoundTransform extends BitmapTransformation {
|
||||
|
||||
private int dp;
|
||||
|
||||
public GlideRoundTransform(int dp) {
|
||||
this.dp = dp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull @NotNull BitmapPool bitmapPool, @NonNull @NotNull Bitmap bitmap, int outWidth, int outHeight) {
|
||||
Bitmap bitmap1 = TransformationUtils.centerCrop(bitmapPool, bitmap, outWidth, outHeight);
|
||||
return roundCrop(bitmapPool, bitmap1);
|
||||
|
||||
}
|
||||
|
||||
private Bitmap roundCrop(BitmapPool pool, Bitmap source) {
|
||||
|
||||
if (source == null) return null;
|
||||
Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
if (result == null) {
|
||||
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
Canvas canvas = new Canvas(result);
|
||||
Paint paint = new Paint();
|
||||
paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
|
||||
paint.setAntiAlias(true);
|
||||
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
|
||||
canvas.drawRoundRect(rectF, dp, dp, paint);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull @NotNull MessageDigest messageDigest) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sl.house_property.message;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
@@ -15,9 +16,16 @@ public class MessageAdapter extends BaseQuickAdapter<MessageEntity.StoreInfo, Ba
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder baseViewHolder, MessageEntity.StoreInfo messageEntity) {
|
||||
Glide.with(mContext).load(messageEntity.getImg()).apply(new RequestOptions().circleCrop())
|
||||
Glide.with(mContext).load(messageEntity.getImg()).apply(new RequestOptions().transform(new GlideRoundTransform(16)))
|
||||
.into(baseViewHolder.itemView.<ImageView>findViewById(R.id.iv));
|
||||
baseViewHolder.setText(R.id.tv_name,messageEntity.getStore_name());
|
||||
baseViewHolder.setText(R.id.tv_title,messageEntity.getTitle());
|
||||
baseViewHolder.setText(R.id.tv_name, messageEntity.getStore_name());
|
||||
baseViewHolder.setText(R.id.tv_title, messageEntity.getTitle());
|
||||
baseViewHolder.setText(R.id.tv_time, messageEntity.getCtime());
|
||||
if (messageEntity.getIs_dot().equals("1")) {
|
||||
baseViewHolder.getView(R.id.view).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
baseViewHolder.getView(R.id.view).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,15 @@ import java.util.ArrayList;
|
||||
public class MessageEntity {
|
||||
private ArrayList<StoreInfo> storeInfo;
|
||||
private String userid;
|
||||
private String Msg_count;
|
||||
|
||||
public String getMsg_count() {
|
||||
return Msg_count;
|
||||
}
|
||||
|
||||
public void setMsg_count(String msg_count) {
|
||||
Msg_count = msg_count;
|
||||
}
|
||||
|
||||
public ArrayList<StoreInfo> getStoreInfo() {
|
||||
return storeInfo;
|
||||
@@ -30,6 +39,25 @@ public class MessageEntity {
|
||||
private String img;
|
||||
private String store_name;
|
||||
private String url;
|
||||
private String ctime;
|
||||
private String is_dot;
|
||||
|
||||
public String getCtime() {
|
||||
return ctime;
|
||||
}
|
||||
|
||||
public void setCtime(String ctime) {
|
||||
this.ctime = ctime;
|
||||
}
|
||||
|
||||
public String getIs_dot() {
|
||||
return is_dot;
|
||||
}
|
||||
|
||||
public void setIs_dot(String is_dot) {
|
||||
this.is_dot = is_dot;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
@@ -37,6 +38,7 @@ import utils.Md5;
|
||||
public class MessageFragment extends Fragment {
|
||||
// private int pageIndex = 0;
|
||||
private MessageAdapter adapter = null;
|
||||
private TextView tvTitle;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -57,6 +59,7 @@ public class MessageFragment extends Fragment {
|
||||
public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
RecyclerView rv = view.findViewById(R.id.rv);
|
||||
tvTitle = view.findViewById(R.id.tv_title);
|
||||
adapter = new MessageAdapter();
|
||||
rv.setAdapter(adapter);
|
||||
rv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
@@ -66,6 +69,12 @@ public class MessageFragment extends Fragment {
|
||||
WebActivitytwo.runActivity(getContext(), adapter.getData().get(i).getTitle(), adapter.getData().get(i).getUrl());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getData();
|
||||
}
|
||||
|
||||
@@ -97,6 +106,13 @@ public class MessageFragment extends Fragment {
|
||||
|
||||
|
||||
MessageEntity messageEntity = gs.fromJson(s, MessageEntity.class);
|
||||
int i = Integer.parseInt(messageEntity.getMsg_count());
|
||||
if (i > 0) {
|
||||
tvTitle.setText("消息(" + i + ")");
|
||||
|
||||
} else {
|
||||
tvTitle.setText("消息");
|
||||
}
|
||||
|
||||
adapter.setNewData(messageEntity.getStoreInfo());
|
||||
}
|
||||
|
||||
11
app/src/main/res/drawable/circle_red.xml
Normal file
11
app/src/main/res/drawable/circle_red.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval"
|
||||
android:useLevel="false">
|
||||
|
||||
<solid android:color="#F00" />
|
||||
|
||||
<size
|
||||
android:width="9dp"
|
||||
android:height="9dp" />
|
||||
</shape>
|
||||
@@ -12,6 +12,7 @@
|
||||
android:layout_marginTop="@dimen/mystatusbar">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
|
||||
@@ -11,8 +11,15 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:src="@color/red" />
|
||||
|
||||
android:src="@color/black" />
|
||||
<View
|
||||
android:id="@+id/view"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:background="@drawable/circle_red"
|
||||
android:layout_marginLeft="57dp"
|
||||
android:layout_marginTop="2dp"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -21,16 +28,30 @@
|
||||
android:layout_marginRight="16dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_toRightOf="@id/iv">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="1"
|
||||
android:ellipsize="end"
|
||||
android:textSize="14sp"
|
||||
android:layout_weight="1"
|
||||
android:textColor="#333333"
|
||||
android:text="哈哈哈" />
|
||||
<TextView
|
||||
android:id="@+id/tv_time"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="201615三d5sd"
|
||||
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
|
||||
Reference in New Issue
Block a user