快传成绩单 - 热点优化

This commit is contained in:
khy
2017-02-24 15:11:00 +08:00
parent ef1f2251b5
commit da20b817d2
42 changed files with 960 additions and 155 deletions

View File

@ -72,6 +72,14 @@ public class MessageShareUtils {
private Activity activity; // 用来关闭分享页面
// 适配快传成绩单分享
private int contentSize;
private int paddTop;
private int picSize;
private int itemSize;
private int gridCount;
private int marImg;
public static MessageShareUtils getInstance(Context context) {
if (instance == null) {
instance = new MessageShareUtils();
@ -82,22 +90,39 @@ public class MessageShareUtils {
return instance;
}
public void showShareWindows(View view, Bitmap bitmap, String picName, boolean ispopupWindow){
public void showShareWindows(View view, Bitmap bitmap, String picName, int shareType){
this.shareBm = bitmap;
this.picName = picName;
this.activity= (Activity) context;
if (shareType == 2) {
contentSize = 75;
paddTop = 0;
gridCount = 4;
picSize = 30;
itemSize = 75;
marImg = 10;
} else {
contentSize = 100;
paddTop = 10;
gridCount = 5;
picSize = 43;
itemSize = 90;
marImg = 13;
}
RelativeLayout contentView = new RelativeLayout(context);
contentView.setBackgroundColor(0x8c000000);
contentView.setFocusable(true);
contentView.setFocusableInTouchMode(true);
RecyclerView shareRecyclerView = new RecyclerView(context);
shareRecyclerView.setPadding(DisplayUtils.dip2px(context, 10), DisplayUtils.dip2px(context, 10), DisplayUtils.dip2px(context, 10), 0);
shareRecyclerView.setPadding(DisplayUtils.dip2px(context, 10), DisplayUtils.dip2px(context, paddTop), DisplayUtils.dip2px(context, 10), 0);
shareRecyclerView.setBackgroundColor(Color.WHITE);
//RecyclerView禁止滑动
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 5){
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, gridCount){
@Override
public boolean canScrollVertically() {
return false;
@ -107,10 +132,10 @@ public class MessageShareUtils {
shareRecyclerView.setLayoutManager(gridLayoutManager);
shareRecyclerView.setAdapter(new ShareRecyclerViewAdapter());
if (!ispopupWindow) {
if (shareType == 0 || shareType == 2) {
LinearLayout llBottom = (LinearLayout) view;
ViewGroup.LayoutParams layoutParams = llBottom.getLayoutParams();
layoutParams.height = DisplayUtils.dip2px(context, 100);
layoutParams.height = DisplayUtils.dip2px(context, contentSize);
llBottom.addView(shareRecyclerView);
return;
}
@ -151,13 +176,13 @@ public class MessageShareUtils {
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(context, 90)));
linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, DisplayUtils.dip2px(context, itemSize)));
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);
linearLayout.setBackgroundResource(R.drawable.cardview_item_style);
ImageView shareLogo = new ImageView(context);
LinearLayout.LayoutParams logoParams = new LinearLayout.LayoutParams(DisplayUtils.dip2px(context, 43), DisplayUtils.dip2px(context, 43));
LinearLayout.LayoutParams logoParams = new LinearLayout.LayoutParams(DisplayUtils.dip2px(context, picSize), DisplayUtils.dip2px(context, picSize));
logoParams.setMargins(0, DisplayUtils.dip2px(context, 10), 0, 0);
shareLogo.setLayoutParams(logoParams);
@ -167,7 +192,7 @@ public class MessageShareUtils {
shareLabel.setLayoutParams(layoutParams);
shareLabel.setGravity(Gravity.CENTER);
shareLabel.setTextColor(Color.parseColor("#3a3a3a"));
shareLabel.setTextSize(13);
shareLabel.setTextSize(marImg);
linearLayout.addView(shareLogo);
linearLayout.addView(shareLabel);
@ -213,7 +238,7 @@ public class MessageShareUtils {
@Override
public int getItemCount() {
return arrLogo.length;
return gridCount;
}
public class ViewHolder extends RecyclerView.ViewHolder{