From 5aaf699f71e17d245b2963ab6f2c6c2712b8910e Mon Sep 17 00:00:00 2001 From: panqihua <1029559041@qq.com> Date: Thu, 26 Mar 2020 21:08:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=88=91=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 + .../pocket/ui/main/ui/info/InfoFragment.java | 75 ++++++++- app/src/main/res/drawable/border.xml | 7 + .../res/layout/main/layout/info_fragment.xml | 150 ++++++++++++++++-- app/src/main/res/values-en-rUS/dimens.xml | 2 + app/src/main/res/values-en-rUS/strings.xml | 9 ++ app/src/main/res/values-zh-rCN/dimens.xml | 2 + app/src/main/res/values-zh-rCN/strings.xml | 9 ++ app/src/main/res/values/dimens.xml | 2 + app/src/main/res/values/strings.xml | 9 ++ build.gradle | 2 +- 11 files changed, 255 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/drawable/border.xml diff --git a/app/build.gradle b/app/build.gradle index a9b6039..d080ccc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,4 +50,6 @@ dependencies { implementation 'org.xutils:xutils:3.8.5' implementation 'com.squareup.okhttp3:okhttp:4.4.1' implementation 'com.wuhenzhizao:titlebar:1.2.0' + + implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java index 7a364a1..fa11df0 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java @@ -1,17 +1,84 @@ package com.community.pocket.ui.main.ui.info; +import android.os.Build; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; + import com.community.pocket.R; -import com.community.pocket.ui.main.TestMainFragment; +import com.community.pocket.ui.BaseFragment; +import com.github.mikephil.charting.charts.LineChart; +import com.github.mikephil.charting.data.Entry; +import com.github.mikephil.charting.data.LineData; +import com.github.mikephil.charting.data.LineDataSet; import org.xutils.view.annotation.ContentView; +import org.xutils.view.annotation.ViewInject; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * 我的信息框架 + */ @ContentView(R.layout.info_fragment) -public class InfoFragment extends TestMainFragment { +public class InfoFragment extends BaseFragment { + + //昵称 + @ViewInject(R.id.nickname) + private TextView nickname; + + //信用分 + @ViewInject(R.id.credit_score) + private TextView creditScore; + + //头像 + @ViewInject(R.id.headimg) + private ImageView headimg; + + //最近发帖数 + @ViewInject(R.id.recentPosts) + private TextView recentPosts; + //最近访客数 + @ViewInject(R.id.recentVisitors) + private TextView recentVisitors; + + @ViewInject(R.id.chart) + private LineChart lineChart; + + @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Override - protected int viewId() { - return R.id.text_info; + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + nickname.setText(getString(R.string.nick_name, "。。。。。。")); + creditScore.setText(getString(R.string.credit_score, 0)); + + recentPosts.setText(getString(R.string.recent_posts, 0)); + recentVisitors.setText(getString(R.string.recent_visitors, 0)); + + loadChart(); } + //加载图表数据 + private void loadChart() { + LineData lineData = new LineData(); + List entries = new ArrayList<>(); + //TODO 测试数据 + for (int i = 0; i < 100; i++) { + entries.add(new Entry(i, new Random().nextInt(100))); + } + LineDataSet lineDataSet = new LineDataSet(entries, getString(R.string.active_history)); + lineData.addDataSet(lineDataSet); + lineChart.getDescription().setEnabled(false); + lineChart.setData(lineData); + } } diff --git a/app/src/main/res/drawable/border.xml b/app/src/main/res/drawable/border.xml new file mode 100644 index 0000000..2fb3796 --- /dev/null +++ b/app/src/main/res/drawable/border.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/app/src/main/res/layout/main/layout/info_fragment.xml b/app/src/main/res/layout/main/layout/info_fragment.xml index 46f0c0b..e5a0391 100644 --- a/app/src/main/res/layout/main/layout/info_fragment.xml +++ b/app/src/main/res/layout/main/layout/info_fragment.xml @@ -7,14 +7,146 @@ android:layout_height="match_parent" tools:context=".ui.main.ui.info.InfoFragment"> - + + + + + + + + + + + + + + + + + + + + +