Commit fefc2e52 authored by jianglx's avatar jianglx

修改积分界面界面显示混乱的问题

parent c88c9989
......@@ -62,7 +62,7 @@ public class OkHttpCreate {
// return cookies != null ? cookies : new ArrayList<Cookie>();
// }
// });
setCache(mHttpBuilder);
// setCache(mHttpBuilder);
// addHttpHeader();
// return mHttpBuilder;
}
......
......@@ -35,7 +35,7 @@ public class GlideManager {
private Context mContext;
public GlideManager(Context context) {
private GlideManager(Context context) {
this.mContext = context.getApplicationContext();
}
......
......@@ -247,7 +247,7 @@ public class MemberListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
}
});
if (!TextUtils.isEmpty(bean.getIcon()))
new GlideManager(mContext).loadImage(bean.getIcon(), viewHolder.img_icon);
GlideManager.getInstance(mContext).loadImage(bean.getIcon(), viewHolder.img_icon);
SpannableString spannableString = new SpannableString(bean.getName() + bean.getPrice() + "元 (永久)");
spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#F25B5B")), bean.getName().length(), spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
......
......@@ -2,6 +2,8 @@ package com.rv.points;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
......@@ -17,6 +19,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.base.utils.ui.image.round.RoundImageView;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.base.BaseBean;
......@@ -37,6 +40,7 @@ import com.yuyife.okgo.OkGoUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import butterknife.BindView;
......@@ -56,6 +60,8 @@ public class PointsActivity extends BaseStatusActivity<PointPresenter> {
private PointAdapter adapter;
private UserInfoBean userInfo;
private List<PointBean.RvPointItem> points = new ArrayList<>();
@Override
protected int setLayout() {
return R.layout.activity_points;
......@@ -81,20 +87,31 @@ public class PointsActivity extends BaseStatusActivity<PointPresenter> {
}
}
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayout.VERTICAL, false));
adapter = new PointAdapter(new ArrayList<PointBean.RvPointItem>());
adapter = new PointAdapter(this, points);
recyclerView.setAdapter(adapter);
adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
adapter.setOnItemClickListener(new PointAdapter.OnItemClickListener() {
@Override
public void openSignRuler(String code) {
if (!TextUtils.isEmpty(code))
getSignRuler(code);
}
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
int id = view.getId();
PointBean.RvPointItem item = (PointBean.RvPointItem) adapter.getItem(position);
if (R.id.btn_state == id) {
public void onClick(PointBean.RvPointItem item) {
if (!TextUtils.isEmpty(item.getCode()))
mPresenter.go(item.getCode().toLowerCase().trim());
} else if (R.id.tv_regulation == id) {
getSignRuler(item.getCode());
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
Glide.with(PointsActivity.this).resumeRequests();//恢复Glide加载图片
} else {
Glide.with(PointsActivity.this).pauseRequests();//禁止Glide加载图片
}
}
});
}
......@@ -146,8 +163,9 @@ public class PointsActivity extends BaseStatusActivity<PointPresenter> {
if (requestType == 1) {
PointBean pointBean = (PointBean) result;
if (pointBean.getData() != null && pointBean.getData().getData() != null) {
adapter.getData().clear();
adapter.addData(pointBean.getData().getData());
points.clear();
points.addAll(pointBean.getData().getData());
adapter.notifyDataSetChanged();
}
}
......@@ -155,11 +173,11 @@ public class PointsActivity extends BaseStatusActivity<PointPresenter> {
if (result != null && result instanceof UserPointInfoBean) {
UserPointInfoBean pointInfoBean = (UserPointInfoBean) result;
if (pointInfoBean.getData() != null) {
String text = pointInfoBean.getData().getRestPoint() + "\n分";
int position = text.indexOf("分");
String text = pointInfoBean.getData().getRestPoint() + "\n分";
int position = text.indexOf("分");
SpannableString sStr = new SpannableString(text);
sStr.setSpan(new AbsoluteSizeSpan(DisplayUtil.sp2px(this, 12)), position, position + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sStr.setSpan(new ForegroundColorSpan(Color.parseColor("#F8F3C9")), position, position + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sStr.setSpan(new AbsoluteSizeSpan(DisplayUtil.sp2px(this, 12)), position, position + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sStr.setSpan(new ForegroundColorSpan(Color.parseColor("#F8F3C9")), position, position + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tvPoint.setText(sStr);
}
}
......
package com.rv.points.adapter;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -15,38 +23,119 @@ import com.rv.points.bean.PointBean;
import java.util.List;
public class PointAdapter extends BaseQuickAdapter<PointBean.RvPointItem, BaseViewHolder> {
public class PointAdapter extends RecyclerView.Adapter {
public PointAdapter(List<PointBean.RvPointItem> lists) {
super(R.layout.item_point, lists);
private Context mContext;
private List<PointBean.RvPointItem> mLists;
private OnItemClickListener mListener;
public PointAdapter(Context context, List<PointBean.RvPointItem> lists) {
super();
this.mContext = context;
this.mLists = lists;
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.mListener = listener;
}
@NonNull
@Override
protected void convert(BaseViewHolder helper, PointBean.RvPointItem item) {
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(mContext).inflate(R.layout.item_point, viewGroup, false);
return new PointViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
final PointBean.RvPointItem item = mLists.get(i);
PointViewHolder holder = (PointViewHolder) viewHolder;
if (!TextUtils.isEmpty(item.getImg())) {
GlideManager.getInstance(mContext).loadImage(item.getImg(), (ImageView) helper.itemView.findViewById(R.id.img_icon));
GlideManager.getInstance(mContext).loadImage(item.getImg(), holder.imgIcon);
} else {
holder.imgIcon.setImageResource(com.ruiwenliu.wrapper.R.drawable.glide_icon_error);
}
if (!TextUtils.isEmpty(item.getName())) {
helper.setText(R.id.tv_name, item.getName());
holder.tvName.setText(item.getName());
} else {
holder.tvName.setText("");
}
if (!TextUtils.isEmpty(item.getRegulation())) {
if ("SIGN".equals(item.getCode())) {
helper.setText(R.id.tv_regulation, "签到规则");
helper.setTextColor(R.id.tv_regulation, Color.parseColor("#FFB74B"));
helper.addOnClickListener(R.id.tv_regulation);
holder.tvRegulation.setText("签到规则");
holder.tvRegulation.setTextColor(Color.parseColor("#FFB74B"));
holder.tvRegulation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mListener != null) {
mListener.openSignRuler(item.getCode());
}
}
});
} else {
helper.setText(R.id.tv_regulation, item.getRegulation());
helper.setTextColor(R.id.tv_regulation, Color.parseColor("#999999"));
holder.tvRegulation.setText(item.getRegulation());
holder.tvRegulation.setTextColor(Color.parseColor("#999999"));
}
} else {
holder.tvRegulation.setText("");
}
if (item.getPoint() != 0) {
helper.setText(R.id.tv_points, item.getPoint() + "分");
holder.tvPoints.setVisibility(View.VISIBLE);
holder.tvPoints.setText(item.getPoint() + "分");
} else {
holder.tvPoints.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(item.getBtnWord())) {
helper.setText(R.id.btn_state, item.getBtnWord());
holder.btnState.setText(item.getBtnWord());
}
helper.setBackgroundRes(R.id.btn_state, item.isIntegralStatus() ? R.drawable.shape_rv_bg_member_top_grap : R.drawable.shape_rv_bg_dark_yellow);
helper.itemView.findViewById(R.id.btn_state).setEnabled(!item.isIntegralStatus());
helper.addOnClickListener(R.id.btn_state);
if ("SIGN".equals(item.getCode())) {
holder.btnState.setEnabled(true);
holder.btnState.setBackgroundResource(R.drawable.shape_rv_bg_dark_yellow);
} else {
holder.btnState.setEnabled(!item.isIntegralStatus());
holder.btnState.setBackgroundResource(item.isIntegralStatus() ? R.drawable.shape_rv_bg_member_top_grap : R.drawable.shape_rv_bg_dark_yellow);
}
holder.btnState.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mListener != null) {
mListener.onClick(item);
}
}
});
}
@Override
public int getItemCount() {
return mLists.size();
}
private class PointViewHolder extends RecyclerView.ViewHolder {
ImageView imgIcon;
TextView tvName;
TextView tvPoints;
TextView tvRegulation;
Button btnState;
public PointViewHolder(@NonNull View itemView) {
super(itemView);
imgIcon = itemView.findViewById(R.id.img_icon);
tvName = itemView.findViewById(R.id.tv_name);
tvPoints = itemView.findViewById(R.id.tv_points);
tvRegulation = itemView.findViewById(R.id.tv_regulation);
btnState = itemView.findViewById(R.id.btn_state);
}
}
public interface OnItemClickListener {
void openSignRuler(String code);
void onClick(PointBean.RvPointItem item);
}
}
......@@ -17,7 +17,7 @@
android:layout_height="@dimen/dp_40"
android:layout_centerVertical="true"
android:padding="@dimen/size_10"
android:src="@drawable/rv_common_icon_back_white" />
android:src="@drawable/rv_common_icon_back_grap" />
<TextView
android:layout_width="wrap_content"
......@@ -25,7 +25,7 @@
android:layout_centerInParent="true"
android:text="我的积分"
android:textColor="@color/black"
android:textSize="@dimen/sp_16" />
android:textSize="@dimen/text_18" />
</RelativeLayout>
<RelativeLayout
......@@ -61,10 +61,12 @@
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/size_50"
android:fontFamily="sans-serif-condensed"
android:gravity="center"
android:text="0"
android:textColor="@color/white"
android:textSize="@dimen/text_22" />
android:textSize="24sp"
android:textStyle="bold" />
</RelativeLayout>
<include layout="@layout/common_rv" />
......
......@@ -79,7 +79,7 @@
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:layout_toRightOf="@+id/img_icon"
android:text="你已累计签到9天" />
android:text="你已累计签到0天" />
<Button
android:id="@+id/btn_sign"
......
......@@ -29,15 +29,24 @@
android:textColor="#000000"
android:textSize="@dimen/text_15" />
<ImageView
android:id="@+id/img_points_icon"
android:layout_width="@dimen/size_10"
android:layout_height="@dimen/size_10"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/size_3"
android:layout_toRightOf="@id/tv_name"
android:src="@drawable/icon_point" />
<TextView
android:id="@+id/tv_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:layout_toRightOf="@id/tv_name"
android:drawableLeft="@drawable/icon_point"
android:drawablePadding="@dimen/size_2"
android:layout_marginRight="@dimen/dp_10"
android:layout_toRightOf="@id/img_points_icon"
android:text="10分"
android:textColor="@color/tv_gr999999"
android:textSize="@dimen/sp_12" />
......@@ -47,7 +56,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_toLeftOf="@+id/btn_state"
android:layout_toRightOf="@id/tv_points"
......
......@@ -62,11 +62,11 @@ public class PromotionDialog extends Dialog {
dialog.addContentView(layout, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT));
this.button = layout.findViewById(R.id.button);
if (this.act != null && !TextUtils.isEmpty(this.act.getButtonImages())) {
GlideManager.getInstance(mContext).loadImage(this.act.getButtonImages(), this.button);
GlideManager.getInstance(mContext).loadImage2(this.act.getButtonImages(), this.button);
}
this.imgBg = layout.findViewById(R.id.img_bg);
if (this.act != null && !TextUtils.isEmpty(this.act.getBackground())) {
GlideManager.getInstance(mContext).loadImage(this.act.getBackground(), this.imgBg);
GlideManager.getInstance(mContext).loadImage2(this.act.getBackground(), this.imgBg);
}
this.imgClose = layout.findViewById(R.id.img_close);
this.button.setOnClickListener(mListener);
......
......@@ -4,12 +4,14 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
......@@ -90,6 +92,13 @@ public class RvWebView extends WebView {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
WebResourceResponse response = super.shouldInterceptRequest(view, request);
return response;
}
};
public WebChromeClient webChromeClient = new WebChromeClient() {
......
......@@ -157,15 +157,16 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:drawableRight="@drawable/common_icon_rig_black"
android:drawableRight="@drawable/common_icon_rig_gray"
android:drawablePadding="3dp"
android:text="查看详情" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/size_20"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="3">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment