添加我的信息界面

0515
panqihua 4 years ago
parent 2d59432be7
commit 5aaf699f71
  1. 2
      app/build.gradle
  2. 75
      app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java
  3. 7
      app/src/main/res/drawable/border.xml
  4. 150
      app/src/main/res/layout/main/layout/info_fragment.xml
  5. 2
      app/src/main/res/values-en-rUS/dimens.xml
  6. 9
      app/src/main/res/values-en-rUS/strings.xml
  7. 2
      app/src/main/res/values-zh-rCN/dimens.xml
  8. 9
      app/src/main/res/values-zh-rCN/strings.xml
  9. 2
      app/src/main/res/values/dimens.xml
  10. 9
      app/src/main/res/values/strings.xml
  11. 2
      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'
}

@ -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<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>

@ -7,14 +7,146 @@
android:layout_height="match_parent"
tools:context=".ui.main.ui.info.InfoFragment">
<TextView
android:id="@+id/text_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_info"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="210dp"
android:background="#77A3C7">
<ImageView
android:id="@+id/headimg"
android:layout_width="200dp"
android:layout_height="200dp"
android:contentDescription="@string/headimg"
android:src="@drawable/comm_titlebar_progress_circular"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/nickname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="@dimen/size_50"
app:layout_constraintStart_toEndOf="@id/headimg"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/credit_score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="@dimen/size_50"
app:layout_constraintStart_toEndOf="@id/headimg"
app:layout_constraintTop_toBottomOf="@id/nickname" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_50"
android:orientation="horizontal">
<TextView
android:id="@+id/recentPosts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border"
android:gravity="center" />
<TextView
android:id="@+id/recentVisitors"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border"
android:gravity="center" />
</LinearLayout>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_30"
android:text="@string/modify_password" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border"
android:gravity="center"
android:text="@string/mobie" />
<TextView
android:id="@+id/mobie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border"
android:gravity="center"
android:text="@string/email" />
<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border"
android:gravity="center" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_30"
android:gravity="center"
android:text="@string/active_history" />
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="@dimen/chart_height"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/chart"
android:layout_width="1000dp"
android:layout_height="@dimen/chart_height" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -4,4 +4,6 @@
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="size_8">8dp</dimen>
<dimen name="size_50">50dp</dimen>
<dimen name="size_30">30dp</dimen>
<dimen name="chart_height">200dp</dimen>
</resources>

@ -37,4 +37,13 @@
<string name="visitor_appointment">Making an Appointment</string>
<string name="visitor_reservation">My Reservation</string>
<string name="visitor_visitor">My Visitor</string>
<string name="nick_name">nickname:%1$s</string>
<string name="credit_score">credit score:%1$d</string>
<string name="headimg">headimg</string>
<string name="modify_password">modify password</string>
<string name="mobie">mobie</string>
<string name="email">email</string>
<string name="recent_posts">recent posts:%1$d</string>
<string name="recent_visitors">recent visitors:%1$d</string>
<string name="active_history">active history</string>
</resources>

@ -4,4 +4,6 @@
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="size_8">8dp</dimen>
<dimen name="size_50">50dp</dimen>
<dimen name="size_30">30dp</dimen>
<dimen name="chart_height">200dp</dimen>
</resources>

@ -37,4 +37,13 @@
<string name="visitor_appointment">访客预约</string>
<string name="visitor_reservation">我的预约</string>
<string name="visitor_visitor">我的访客</string>
<string name="nick_name">昵称:%1$s</string>
<string name="credit_score">信用分:%1$d</string>
<string name="headimg">头像</string>
<string name="modify_password">修改密码</string>
<string name="mobie">手机号绑定</string>
<string name="email">邮箱绑定</string>
<string name="recent_posts">最近发帖数 :%1$d</string>
<string name="recent_visitors">最近访客数:%1$d</string>
<string name="active_history">信用分活动记录</string>
</resources>

@ -5,4 +5,6 @@
<dimen name="size_8">8dp</dimen>
<dimen name="size_50">50dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="size_30">30dp</dimen>
<dimen name="chart_height">200dp</dimen>
</resources>

@ -38,6 +38,15 @@
<string name="visitor_appointment">Making an Appointment</string>
<string name="visitor_reservation">My Reservation</string>
<string name="visitor_visitor">My Visitor</string>
<string name="nick_name">nickname:%1$s</string>
<string name="credit_score">credit score:%1$d</string>
<string name="headimg">headimg</string>
<string name="modify_password">modify password</string>
<string name="mobie">mobie</string>
<string name="email">email</string>
<string name="recent_posts">recent posts:%1$d</string>
<string name="recent_visitors">recent visitors:%1$d</string>
<string name="active_history">active history</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

@ -6,7 +6,6 @@ buildscript {
maven { url 'https://maven.aliyun.com/repository/public/' }
google()
jcenter()
// maven { url 'https://dl.bintray.com/a10188755550/maven'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
@ -22,6 +21,7 @@ allprojects {
maven { url 'https://maven.aliyun.com/repository/public/' }
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

Loading…
Cancel
Save