Commit bcafe53a0ae5e15d158ef410fa2c88c1a148ad8a

Authored by 姚旭斌
1 parent 42f6a92a

no message

app/src/main/java/com/shunzhi/parent/adapter/ReportAdapter.java 0 → 100644
... ... @@ -0,0 +1,52 @@
  1 +package com.shunzhi.parent.adapter;
  2 +
  3 +
  4 +import android.content.Context;
  5 +import android.view.LayoutInflater;
  6 +import android.view.View;
  7 +import android.view.ViewGroup;
  8 +
  9 +import com.share.mvpsdk.base.adapter.BaseRecyclerViewAdapter;
  10 +import com.share.mvpsdk.base.adapter.BaseRecyclerViewHolder;
  11 +import com.shunzhi.parent.R;
  12 +import com.shunzhi.parent.bean.ReportBean;
  13 +import com.shunzhi.parent.views.ProgressView;
  14 +
  15 +/**
  16 + * Created by Administrator on 2018/3/9 0009.
  17 + */
  18 +
  19 +public class ReportAdapter extends BaseRecyclerViewAdapter<ReportBean> {
  20 +
  21 + Context context;
  22 +
  23 + public ReportAdapter(Context context) {
  24 + this.context = context;
  25 + }
  26 +
  27 +
  28 + @Override
  29 + public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  30 + View view = LayoutInflater.from(context).inflate(R.layout.item_report, null);
  31 + return new MyViewHolder(view);
  32 + }
  33 +
  34 + private class MyViewHolder extends BaseRecyclerViewHolder<ReportBean> {
  35 +
  36 + ProgressView ringView;
  37 +
  38 +
  39 + public MyViewHolder(View view) {
  40 + super(view);
  41 + ringView = view.findViewById(R.id.ring);
  42 + }
  43 +
  44 + @Override
  45 + public void onBindViewHolder(ReportBean object, int position) {
  46 + ringView.setMaxCount(100.0f);
  47 + ringView.setCurrentCount(100);
  48 + ringView.setScore(100);
  49 + }
  50 +
  51 + }
  52 +}
... ...
app/src/main/java/com/shunzhi/parent/bean/ReportBean.java 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +package com.shunzhi.parent.bean;
  2 +
  3 +/**
  4 + * Created by Administrator on 2018/3/9 0009.
  5 + */
  6 +
  7 +public class ReportBean {
  8 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/ReportFragment.java
1 1 package com.shunzhi.parent.ui.fragment;
2 2  
3   -import android.content.Context;
4   -import android.net.Uri;
5 3 import android.os.Bundle;
6   -import android.support.v4.app.Fragment;
7   -import android.view.LayoutInflater;
  4 +import android.support.annotation.NonNull;
  5 +import android.support.annotation.Nullable;
  6 +import android.support.v7.widget.LinearLayoutManager;
  7 +import android.support.v7.widget.RecyclerView;
8 8 import android.view.View;
9   -import android.view.ViewGroup;
10 9  
  10 +import com.share.mvpsdk.base.BasePresenter;
  11 +import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment;
11 12 import com.shunzhi.parent.R;
  13 +import com.shunzhi.parent.adapter.ReportAdapter;
  14 +import com.shunzhi.parent.bean.ReportBean;
12 15  
13   -public class ReportFragment extends Fragment {
  16 +import java.util.ArrayList;
  17 +import java.util.List;
  18 +
  19 +public class ReportFragment extends BaseMVPCompatFragment {
  20 + RecyclerView recycler_report;
  21 + ReportAdapter reportAdapter;
  22 + List<ReportBean>list=new ArrayList<>();
  23 +
  24 + @NonNull
  25 + @Override
  26 + public BasePresenter initPresenter() {
  27 + return null;
  28 + }
14 29  
15 30 @Override
16   - public View onCreateView(LayoutInflater inflater, ViewGroup container,
17   - Bundle savedInstanceState) {
18   - // Inflate the layout for this fragment
19   - return inflater.inflate(R.layout.fragment_report, container, false);
  31 + public int getLayoutId() {
  32 + return R.layout.fragment_report;
20 33 }
21 34  
  35 + @Override
  36 + public void initUI(View view, @Nullable Bundle savedInstanceState) {
  37 + recycler_report = view.findViewById(R.id.recycle_report);
  38 + recycler_report.setLayoutManager(new LinearLayoutManager(getActivity()));
  39 + reportAdapter=new ReportAdapter(getActivity());
  40 + ReportBean reportBean=new ReportBean();
  41 + list.add(reportBean);
  42 + list.add(reportBean);
  43 + reportAdapter.addAll(list);
  44 + recycler_report.setAdapter(reportAdapter);
  45 +
22 46  
  47 +
  48 + }
23 49 }
... ...
app/src/main/java/com/shunzhi/parent/views/ProgressView.java 0 → 100644
... ... @@ -0,0 +1,181 @@
  1 +package com.shunzhi.parent.views;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Canvas;
  5 +import android.graphics.Color;
  6 +import android.graphics.Matrix;
  7 +import android.graphics.Paint;
  8 +import android.graphics.Paint.Cap;
  9 +import android.graphics.Paint.Style;
  10 +import android.graphics.PorterDuff;
  11 +import android.graphics.PorterDuffXfermode;
  12 +import android.graphics.RectF;
  13 +import android.graphics.SweepGradient;
  14 +import android.util.AttributeSet;
  15 +import android.view.View;
  16 +
  17 +/***
  18 + * 自定义圆弧进度条
  19 + *
  20 + * @author liujing
  21 + */
  22 +public class ProgressView extends View {
  23 +
  24 + //分段颜色
  25 + private static final int[] SECTION_COLORS = {Color.RED, Color.YELLOW,Color.GREEN};
  26 + private static final String[] ALARM_LEVEL = {"", "", "", ""};
  27 + private float maxCount;
  28 + private float currentCount;
  29 + private int score;
  30 + private String crrentLevel;
  31 + private Paint mPaint;
  32 + private Paint mTextPaint;
  33 + private int mWidth, mHeight;
  34 +
  35 + public ProgressView(Context context, AttributeSet attrs, int defStyleAttr) {
  36 + super(context, attrs, defStyleAttr);
  37 + init(context);
  38 + }
  39 +
  40 + public ProgressView(Context context, AttributeSet attrs) {
  41 + this(context, attrs, 0);
  42 + }
  43 +
  44 + public ProgressView(Context context) {
  45 + this(context, null);
  46 + }
  47 +
  48 + private void init(Context context) {
  49 + mPaint = new Paint();
  50 + mTextPaint = new Paint();
  51 + }
  52 +
  53 + @Override
  54 + protected void onDraw(Canvas canvas) {
  55 + super.onDraw(canvas);
  56 + initPaint();
  57 + RectF rectBlackBg = new RectF(20, 20, mWidth - 20, mHeight - 20);
  58 + canvas.drawArc(rectBlackBg, 0, 275, false, mPaint);
  59 + mPaint.setColor(getColor(score));
  60 + canvas.drawText(score + "%", mWidth / 2, mHeight / 2, mTextPaint);
  61 + mTextPaint.setTextSize(40);
  62 +
  63 + SweepGradient sweepGradient = new SweepGradient(mWidth / 2, mWidth / 2, SECTION_COLORS, null);
  64 + Matrix matrix = new Matrix();
  65 + matrix.setRotate(120, this.mWidth / 2, mWidth / 2);
  66 + sweepGradient.setLocalMatrix(matrix);
  67 + float section = currentCount / maxCount;
  68 + mPaint.setShader(sweepGradient);
  69 +
  70 + mPaint.setShader(sweepGradient);
  71 + mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
  72 + mPaint.setStyle(Style.STROKE);
  73 + canvas.drawArc(rectBlackBg, 135, section * 275, false, mPaint);
  74 + }
  75 +
  76 +
  77 + private void initPaint() {
  78 + mPaint.setAntiAlias(true);
  79 + mPaint.setStrokeWidth((float) 40.0);
  80 + mPaint.setStyle(Style.STROKE);
  81 + mPaint.setStrokeCap(Cap.ROUND);
  82 + mPaint.setColor(Color.TRANSPARENT);
  83 + mTextPaint.setAntiAlias(true);
  84 + mTextPaint.setStrokeWidth((float) 3.0);
  85 + mTextPaint.setTextAlign(Paint.Align.CENTER);
  86 + mTextPaint.setTextSize(50);
  87 + mTextPaint.setColor(Color.BLACK);
  88 +
  89 + }
  90 +
  91 + private int dipToPx(int dip) {
  92 + float scale = getContext().getResources().getDisplayMetrics().density;
  93 + return (int) (dip * scale + 0.5f * (dip >= 0 ? 1 : -1));
  94 + }
  95 +
  96 + public int getScore() {
  97 + return score;
  98 + }
  99 +
  100 + public String getCrrentLevel() {
  101 + return crrentLevel;
  102 + }
  103 +
  104 + public void setCrrentLevel(String crrentLevel) {
  105 + this.crrentLevel = crrentLevel;
  106 + }
  107 +
  108 + public float getMaxCount() {
  109 + return maxCount;
  110 + }
  111 +
  112 + public float getCurrentCount() {
  113 + return currentCount;
  114 + }
  115 +
  116 + public void setScore(int score) {
  117 + this.score = score;
  118 + if (score == 100) {
  119 + this.crrentLevel = ALARM_LEVEL[0];
  120 + } else if (score >= 70 && score < 100) {
  121 + this.crrentLevel = ALARM_LEVEL[1];
  122 + } else if (score >= 30 && score < 70) {
  123 + this.crrentLevel = ALARM_LEVEL[2];
  124 + } else {
  125 + this.crrentLevel = ALARM_LEVEL[3];
  126 + }
  127 + invalidate();
  128 + }
  129 + public int getColor(int score) {
  130 + this.score = score;
  131 + if (score > 60 && score <= 100) {
  132 + return SECTION_COLORS[2];
  133 + } else if (score >= 30 && score <= 60) {
  134 + return SECTION_COLORS[1];
  135 + } else {
  136 + return SECTION_COLORS[0];
  137 + }
  138 +
  139 + }
  140 +
  141 + /***
  142 + * 设置最大的进度值
  143 + *
  144 + * @param maxCount
  145 + */
  146 + public void setMaxCount(float maxCount) {
  147 + this.maxCount = maxCount;
  148 + }
  149 +
  150 + /***
  151 + * 设置当前的进度值
  152 + *
  153 + * @param currentCount
  154 + */
  155 + public void setCurrentCount(float currentCount) {
  156 + this.currentCount = currentCount > maxCount ? maxCount : currentCount;
  157 + invalidate();
  158 + }
  159 +
  160 + @Override
  161 + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  162 + int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
  163 + int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
  164 + int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
  165 + int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
  166 + if (widthSpecMode == MeasureSpec.EXACTLY
  167 + || widthSpecMode == MeasureSpec.AT_MOST) {
  168 + mWidth = widthSpecSize;
  169 + } else {
  170 + mWidth = 0;
  171 + }
  172 + if (heightSpecMode == MeasureSpec.AT_MOST
  173 + || heightSpecMode == MeasureSpec.UNSPECIFIED) {
  174 + mHeight = dipToPx(15);
  175 + } else {
  176 + mHeight = heightSpecSize;
  177 + }
  178 + setMeasuredDimension(mWidth, mHeight);
  179 + }
  180 +
  181 + }
... ...
app/src/main/res/drawable/report_white.xml 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <stroke android:color="#00000000" android:width="1dp"/>
  4 + <solid android:color="@color/white" />
  5 + <corners android:radius="10dp"/>
  6 +</shape>
0 7 \ No newline at end of file
... ...
app/src/main/res/drawable/rudiobtn_report_top.xml 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <stroke android:color="#00000000" android:width="1dp"/>
  4 + <solid android:color="#AACFFC" />
  5 + <corners android:topLeftRadius="10dp" android:topRightRadius="10dp"/>
  6 +</shape>
0 7 \ No newline at end of file
... ...
app/src/main/res/layout/fragment_report.xml
... ... @@ -49,8 +49,25 @@
49 49 android:drawableRight="@drawable/screen"
50 50 />
51 51 </LinearLayout>
  52 +<LinearLayout
  53 + android:layout_width="match_parent"
  54 + android:layout_height="60dp">
  55 +<TextView
  56 + android:layout_width="match_parent"
  57 + android:layout_height="match_parent"
  58 + android:text="日期控件"
  59 + android:textColor="@color/white"
  60 + android:gravity="center"
  61 + android:background="@color/textRed"
  62 + />
52 63  
  64 +</LinearLayout>
  65 +<android.support.v7.widget.RecyclerView
  66 + android:id="@+id/recycle_report"
  67 + android:layout_width="match_parent"
  68 + android:layout_height="match_parent">
53 69  
  70 +</android.support.v7.widget.RecyclerView>
54 71 </LinearLayout>
55 72  
56 73 </FrameLayout>
... ...
app/src/main/res/layout/item_report.xml 0 → 100644
... ... @@ -0,0 +1,103 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent">
  5 +
  6 + <LinearLayout
  7 + android:layout_width="match_parent"
  8 + android:layout_height="250dp"
  9 + android:layout_margin="20dp"
  10 + android:background="@drawable/report_white"
  11 + android:orientation="vertical">
  12 +
  13 + <TextView
  14 + android:layout_width="match_parent"
  15 + android:layout_height="40dp"
  16 + android:background="@drawable/rudiobtn_report_top"
  17 + android:gravity="center_vertical"
  18 + android:paddingLeft="20dp"
  19 + android:text="语文作业报告"
  20 + android:textColor="#20519f"
  21 + android:textSize="@dimen/sp_16" />
  22 +
  23 + <RelativeLayout
  24 + android:layout_width="match_parent"
  25 + android:layout_height="wrap_content"
  26 + android:layout_weight="1"
  27 + android:orientation="horizontal">
  28 +
  29 + <LinearLayout
  30 + android:layout_width="80dp"
  31 + android:layout_height="match_parent"
  32 + android:layout_marginTop="10dp"
  33 + android:orientation="vertical">
  34 +
  35 + <TextView
  36 + android:layout_width="match_parent"
  37 + android:layout_height="wrap_content"
  38 + android:gravity="center"
  39 + android:text="12"
  40 + android:textColor="@color/textGreen"
  41 + android:textSize="@dimen/txtsize_num" />
  42 +
  43 + <TextView
  44 + android:layout_width="match_parent"
  45 + android:layout_height="wrap_content"
  46 + android:gravity="center"
  47 + android:text="正确"
  48 + android:textColor="@color/textGreen"
  49 + android:textSize="@dimen/sp_16" />
  50 + </LinearLayout>
  51 +
  52 + <LinearLayout
  53 + android:layout_width="wrap_content"
  54 + android:layout_height="match_parent"
  55 + android:layout_weight="1"
  56 + android:layout_centerInParent="true"
  57 + android:gravity="center_horizontal"
  58 + >
  59 + <com.shunzhi.parent.views.ProgressView
  60 + android:id="@+id/ring"
  61 + android:layout_width="160dp"
  62 + android:layout_height="match_parent"
  63 + android:layout_marginTop="10dp" />
  64 + </LinearLayout>
  65 +
  66 + <LinearLayout
  67 + android:layout_width="80dp"
  68 + android:layout_height="match_parent"
  69 + android:layout_marginTop="10dp"
  70 + android:layout_alignParentRight="true"
  71 + android:orientation="vertical">
  72 +
  73 + <TextView
  74 + android:layout_width="match_parent"
  75 + android:layout_height="wrap_content"
  76 + android:gravity="center"
  77 + android:text="8"
  78 + android:textColor="@color/textRed"
  79 + android:textSize="@dimen/txtsize_num" />
  80 +
  81 + <TextView
  82 + android:layout_width="match_parent"
  83 + android:layout_height="wrap_content"
  84 + android:gravity="center"
  85 + android:text="错误"
  86 + android:textColor="@color/textRed"
  87 + android:textSize="@dimen/sp_16" />
  88 + </LinearLayout>
  89 +
  90 + </RelativeLayout>
  91 +
  92 + <TextView
  93 + android:layout_width="match_parent"
  94 + android:layout_height="wrap_content"
  95 + android:height="40dp"
  96 + android:gravity="center_vertical"
  97 + android:paddingLeft="20dp"
  98 + android:text="3月4日语文作业"
  99 + android:textColor="@color/text_color"
  100 + android:textSize="@dimen/sp_14" />
  101 +
  102 + </LinearLayout>
  103 +</LinearLayout>
... ...
app/src/main/res/values/colors.xml
... ... @@ -18,4 +18,5 @@
18 18 <color name="zxlx">#1BE2E5</color>
19 19 <color name="huodong_blue">#ACD1FB</color>
20 20 <color name="text_color">#757575</color>
  21 + <color name="textGreen">#5FB762</color>
21 22 </resources>
... ...
app/src/main/res/values/dimens.xml
... ... @@ -14,6 +14,7 @@
14 14  
15 15 <!-- txtsize -->
16 16 <dimen name="txtsize_display1">34sp</dimen>
  17 + <dimen name="txtsize_num">36sp</dimen>
17 18 <dimen name="txtsize_headline">24sp</dimen>
18 19 <dimen name="txtsize_title">20sp</dimen>
19 20 <dimen name="txtsize_subhead">16sp</dimen>
... ...