parent
2d59432be7
commit
5aaf699f71
@ -1,17 +1,84 @@ |
|||||||
package com.community.pocket.ui.main.ui.info; |
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.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.ContentView; |
||||||
|
import org.xutils.view.annotation.ViewInject; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Random; |
||||||
|
|
||||||
|
/** |
||||||
|
* 我的信息框架 |
||||||
|
*/ |
||||||
@ContentView(R.layout.info_fragment) |
@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 |
@Override |
||||||
protected int viewId() { |
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||||
return R.id.text_info; |
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<Entry> 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); |
||||||
|
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"> |
||||||
|
<stroke |
||||||
|
android:width="1dp" |
||||||
|
android:color="#FFF000" /> |
||||||
|
<solid android:color="@android:color/transparent" /> |
||||||
|
</shape> |
Loading…
Reference in new issue