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"> - + + + + + + + + + + + + + + + + + + + + +