完善论坛—最新布局完善

0515
panqihua 4 years ago
parent 653ac9520c
commit bbf4209f3f
  1. 1
      app/src/main/java/com/community/pocket/data/adapter/NoticeAdpter.java
  2. 8
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumHotFragment.java
  3. 10
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumMyFragment.java
  4. 51
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumNewFragment.java
  5. 12
      app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml
  6. 68
      app/src/main/res/layout/main/layout/forum/layout/post.xml
  7. 3
      app/src/main/res/values-en-rUS/strings.xml
  8. 3
      app/src/main/res/values-zh-rCN/strings.xml
  9. 3
      app/src/main/res/values/strings.xml

@ -30,6 +30,7 @@ public class NoticeAdpter extends RecyclerView.Adapter<NoticeAdpter.PagerViewHol
@NonNull
@Override
public PagerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.forum_notice, parent, false);
return new PagerViewHolder(itemView);
}

@ -4,7 +4,6 @@ import android.content.Context;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@ -24,15 +23,12 @@ import org.xutils.view.annotation.ContentView;
*/
@ContentView(R.layout.forum_hot_fragment)
public class ForumHotFragment extends BaseFragment {
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
//TODO 测试数据
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
addRank(view, R.id.active_user, R.id.active_user_text, new String[]{"aaaa", "bbbb", "ccccc"});
addRank(view, R.id.hot_topic, R.id.hot_topic_text, new String[]{"xxxx", "123", "fuckadsf"});
addRank(view, R.id.hot_events, R.id.hot_events_text, new String[]{"sadf", "fsd12", "123f"});
return view;
}
/**

@ -1,7 +1,7 @@
package com.community.pocket.ui.main.ui.forum;
import com.community.pocket.R;
import com.community.pocket.ui.main.TestMainFragment;
import com.community.pocket.ui.BaseFragment;
import org.xutils.view.annotation.ContentView;
@ -9,9 +9,7 @@ import org.xutils.view.annotation.ContentView;
* 我的帖子
*/
@ContentView(R.layout.forum_my_fragment)
public class ForumMyFragment extends TestMainFragment {
@Override
protected int viewId() {
return R.id.text_my;
}
public class ForumMyFragment extends BaseFragment {
}

@ -1,19 +1,62 @@
package com.community.pocket.ui.main.ui.forum;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.community.pocket.R;
import com.community.pocket.ui.main.TestMainFragment;
import com.community.pocket.ui.BaseFragment;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import java.util.Date;
/**
* 最新帖子
*/
@ContentView(R.layout.forum_new_fragment)
public class ForumNewFragment extends TestMainFragment {
public class ForumNewFragment extends BaseFragment {
@ViewInject(R.id.post_layout)
private LinearLayout layout;
@Override
protected int viewId() {
return R.id.text_new;
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
loadPost(view);
}
/**
* 加载最新帖子
*/
private void loadPost(View view) {
//TODO 测试数据
for (int i = 0; i < 10; i++) {
View childView = View.inflate(getContext(), R.layout.post, null);
TextView title = childView.findViewById(R.id.post_title);
title.setText("标题" + i);
TextView content = childView.findViewById(R.id.post_content);
content.setText("内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容" + i);
TextView author = childView.findViewById(R.id.poster);
author.setText(getString(R.string.poster, "发帖人" + i));
TextView time = childView.findViewById(R.id.post_time);
Date date = new Date();
date.setTime(System.currentTimeMillis());
time.setText(getString(R.string.post_time, DateFormat.format(getString(R.string.dateformat), date)));
ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
layoutParams.setMargins(0, 0, 0, 50);
childView.setLayoutParams(layoutParams);
layout.addView(childView);
}
}
}

@ -5,9 +5,15 @@
android:layout_height="match_parent"
tools:context=".ui.main.ui.forum.ForumNewFragment">
<TextView
android:id="@+id/text_new"
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="match_parent"
tools:ignore="UselessParent">
<LinearLayout
android:id="@+id/post_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
</FrameLayout>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/border">
<TextView
android:id="@+id/post_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/headimg"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/headimg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/post_title"
app:srcCompat="@drawable/border" />
<EditText
android:id="@+id/post_content"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="24dp"
android:background="@drawable/border"
android:ems="10"
android:enabled="false"
android:hint="@string/load_post_content"
android:importantForAutofill="no"
android:inputType="none|textMultiLine"
android:maxLines="4"
app:layout_constraintBottom_toBottomOf="@id/headimg"
app:layout_constraintStart_toEndOf="@id/headimg"
app:layout_constraintTop_toTopOf="@id/headimg"
tools:layout_constraintEnd_toEndOf="parent"
tools:layout_constraintStart_toEndOf="@id/headimg" />
<TextView
android:id="@+id/poster"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/headimg" />
<TextView
android:id="@+id/post_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/poster" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -54,4 +54,7 @@
<string name="hot_topic">Hot Topic</string>
<string name="hot_events">Hot Events</string>
<string name="hot_rank">%1d.%2s</string>
<string name="poster">poster:%1s</string>
<string name="post_time">time:%1$s</string>
<string name="load_post_content">load content.......</string>
</resources>

@ -54,4 +54,7 @@
<string name="hot_topic">热门动态</string>
<string name="hot_events">热门活动</string>
<string name="hot_rank">%1d.%2s</string>
<string name="poster">发帖人:%1s</string>
<string name="post_time">发帖时间:%1s</string>
<string name="load_post_content">加载正文中。。。。</string>
</resources>

@ -55,6 +55,9 @@
<string name="hot_topic">Hot Topic</string>
<string name="hot_events">Hot Events</string>
<string name="hot_rank">%1d.%2s</string>
<string name="poster">poster:%1s</string>
<string name="post_time">time:%1$s</string>
<string name="load_post_content">load content.......</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

Loading…
Cancel
Save