From 6e932742ae1e0442ffd3dbdf9ae4af8228a2c50e Mon Sep 17 00:00:00 2001 From: panqihua <1029559041@qq.com> Date: Sat, 4 Apr 2020 03:04:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B8=96=E5=AD=90=E8=AF=A6?= =?UTF-8?q?=E6=83=85UI=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 +- .../data/main/forum/ForumDataRequest.java | 48 ++++ .../ui/main/ui/forum/ForumDataActivity.java | 88 ------- .../pocket/ui/main/ui/forum/ForumPost.java | 8 +- .../main/ui/forum/data/ForumDataActivity.java | 242 ++++++++++++++++++ .../main/ui/forum/data/ForumDataResponse.java | 46 ++++ .../ui/forum/data/ForumDataViewModel.java | 83 ++++++ .../forum/data/ForumDataViewModelFactory.java | 20 ++ .../main/ui/forum/data/ForumReplyState.java | 27 ++ .../forum/post/ForumPostActiveFragment.java | 4 +- .../forum/post/ForumPostComplainFragment.java | 4 +- .../main/ui/forum/post/ForumPostContent.java | 4 +- .../ui/forum/post/ForumPostTopicFragment.java | 4 +- .../pocket/ui/resetpwd/ResetPwdStep2.java | 2 +- .../java/com/community/pocket/util/Param.java | 3 +- .../forum/layout/activity_forum_data.xml | 32 ++- .../forum/layout/forum_post_content.xml | 2 +- .../main/layout/forum/layout/forum_replay.xml | 39 +++ app/src/main/res/values-en-rUS/strings.xml | 5 + app/src/main/res/values-zh-rCN/strings.xml | 5 + app/src/main/res/values/strings.xml | 5 + 21 files changed, 564 insertions(+), 109 deletions(-) create mode 100644 app/src/main/java/com/community/pocket/data/main/forum/ForumDataRequest.java delete mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataActivity.java create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModel.java create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModelFactory.java create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumReplyState.java create mode 100644 app/src/main/res/layout/main/layout/forum/layout/forum_replay.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 153e0a7..aeaf47e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme.NoActionBar"> - + diff --git a/app/src/main/java/com/community/pocket/data/main/forum/ForumDataRequest.java b/app/src/main/java/com/community/pocket/data/main/forum/ForumDataRequest.java new file mode 100644 index 0000000..d071674 --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/main/forum/ForumDataRequest.java @@ -0,0 +1,48 @@ +package com.community.pocket.data.main.forum; + +import com.community.pocket.R; +import com.community.pocket.data.model.ForumContent; +import com.community.pocket.ui.main.ui.forum.data.ForumDataResponse; +import com.community.pocket.util.Valid; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * 帖子详情数据接口 + * TODO 完善逻辑 + */ +public class ForumDataRequest { + private static volatile ForumDataRequest instance; + + private ForumDataRequest() { + } + + public static ForumDataRequest getInstance() { + if (instance == null) { + instance = new ForumDataRequest(); + } + return instance; + } + + //回帖 + public Valid sendReply(String content) { + return Valid.ok; + } + + //获取帖子详情数据 + public ForumDataResponse> loadData(int forumId) { + return new ForumDataResponse>().setSuccess(R.string.forum_data_ok).setBody(new ArrayList() {{ + for (int i = 1; i < 10; i++) { + ForumContent forumContent = new ForumContent(); + forumContent.setUsername("fffname" + i); + forumContent.setTime(System.currentTimeMillis()); + forumContent.setScore(new Random().nextInt(100)); + forumContent.setTower(i); + forumContent.setContent("我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋"); + add(forumContent); + } + }}); + } +} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java deleted file mode 100644 index 55192f3..0000000 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java +++ /dev/null @@ -1,88 +0,0 @@ -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.constraintlayout.widget.ConstraintLayout; - -import com.community.pocket.R; -import com.community.pocket.ui.BaseActivity; - -import org.xutils.view.annotation.ContentView; -import org.xutils.view.annotation.Event; -import org.xutils.view.annotation.ViewInject; - -/** - * 帖子详情界面 - */ -@ContentView(R.layout.activity_forum_data) -public class ForumDataActivity extends BaseActivity { - - //第一楼布局 - @ViewInject(R.id.first_layout) - private ConstraintLayout firstLayout; - - //回复楼层布局 - @ViewInject(R.id.reply_layout) - private LinearLayout replyLayout; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - initFirst(); - - createReply(); - } - - /** - * 初始化第一楼数据 - * TODO 测试数据 - */ - private void initFirst() { - setData(firstLayout); - } - - /** - * 返回 - */ - @Event(value = R.id.back) - private void back(View view) { - finish(); - } - - /** - * 创建楼层数据 - */ - private void createReply() { - for (int i = 0; i < 10; i++) { - View view = View.inflate(this, R.layout.forum_data_content, null); - ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - ViewGroup.MarginLayoutParams marginLayoutParams = new ViewGroup.MarginLayoutParams(layoutParams); - marginLayoutParams.setMargins(0, 50, 0, 0); - setData(view); - view.setLayoutParams(marginLayoutParams); - replyLayout.addView(view); - } - } - - /** - * 设置楼层布局 - */ - private void setData(View view) { - TextView name = view.findViewById(R.id.name); - name.setText("我是笨蛋"); - TextView score = view.findViewById(R.id.score); - score.setText("22"); - TextView time = view.findViewById(R.id.time); - time.setText(DateFormat.format(getString(R.string.dateformat), System.currentTimeMillis())); - TextView tower = view.findViewById(R.id.tower); - tower.setText(getString(R.string.tower, 1)); - TextView content = view.findViewById(R.id.content); - content.setText("我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋"); - } -} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java index a5e82e2..52fc92b 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java @@ -1,5 +1,6 @@ package com.community.pocket.ui.main.ui.forum; +import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; import android.text.format.DateFormat; @@ -14,6 +15,8 @@ import androidx.annotation.Nullable; import com.community.pocket.R; import com.community.pocket.ui.BaseFragment; +import com.community.pocket.ui.main.ui.forum.data.ForumDataActivity; +import com.community.pocket.util.Param; import org.xutils.view.annotation.ViewInject; @@ -38,6 +41,7 @@ public abstract class ForumPost extends BaseFragment { * 加载帖子数据 * TODO 测试数据 */ + @SuppressLint("SetTextI18n") private void loadPost(View view) { for (int i = 0; i < 10; i++) { @@ -66,7 +70,9 @@ public abstract class ForumPost extends BaseFragment { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - startActivity(new Intent(getContext(), ForumDataActivity.class)); + Intent intent = new Intent(getContext(), ForumDataActivity.class); + intent.putExtra(Param.forumId.name(), 1); + startActivity(intent); } }); diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataActivity.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataActivity.java new file mode 100644 index 0000000..6ea0636 --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataActivity.java @@ -0,0 +1,242 @@ +package com.community.pocket.ui.main.ui.forum.data; + +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.text.Editable; +import android.text.format.DateFormat; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProvider; + +import com.community.pocket.R; +import com.community.pocket.data.model.ForumContent; +import com.community.pocket.ui.BaseActivity; +import com.community.pocket.ui.listener.MyTextChange; +import com.community.pocket.ui.main.ui.forum.ShowWordCount; +import com.community.pocket.util.Param; + +import org.xutils.view.annotation.ContentView; +import org.xutils.view.annotation.Event; +import org.xutils.view.annotation.ViewInject; + +import java.util.List; + +/** + * 帖子详情界面 + */ +@ContentView(R.layout.activity_forum_data) +public class ForumDataActivity extends BaseActivity { + + //第一楼布局 + @ViewInject(R.id.first_layout) + private ConstraintLayout firstLayout; + + //回复楼层布局 + @ViewInject(R.id.reply_layout) + private LinearLayout replyLayout; + + //回帖文本输入框 + private EditText editText; + + private ForumDataViewModel viewModel; + + //关闭回帖窗口按钮 + private Button close; + + //回帖按钮 + private Button reply; + + private Handler handler; + + @ViewInject(R.id.open_reply) + private Button openReply; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + viewModel = new ViewModelProvider(this, new ForumDataViewModelFactory()).get(ForumDataViewModel.class); + + Intent intent = getIntent(); + int forumId = intent.getIntExtra(Param.forumId.name(), 0); + if (forumId == 0) { + Toast.makeText(getApplicationContext(), R.string.forum_data_fail, Toast.LENGTH_LONG).show(); + finish(); + } else { + viewModel.loadData(forumId); + + //监听回帖表单状态 + viewModel.getForumReplyState().observe(this, new Observer() { + @Override + public void onChanged(ForumReplyState forumReplyState) { + if (forumReplyState == null) { + return; + } + + if (forumReplyState.getContentError() != null) { + editText.setError(getString(forumReplyState.getContentError())); + } + + reply.setEnabled(forumReplyState.isDataValid()); + } + }); + + //监听回帖状态 + viewModel.getReplayResponse().observe(this, new Observer() { + @Override + public void onChanged(ForumDataResponse forumDataResponse) { + if (forumDataResponse == null) { + return; + } + + if (forumDataResponse.getSuccess() != null) { + handler.sendEmptyMessage(0); + Toast.makeText(getApplicationContext(), forumDataResponse.getSuccess(), Toast.LENGTH_LONG).show(); + } + + if (forumDataResponse.getError() != null) { + Toast.makeText(getApplicationContext(), forumDataResponse.getError(), Toast.LENGTH_LONG).show(); + } + } + }); + + //监听帖子详情数据 + viewModel.getForumContentResponse().observe(this, new Observer>>() { + @Override + public void onChanged(ForumDataResponse> listForumDataResponse) { + if (listForumDataResponse == null) { + return; + } + + if (listForumDataResponse.getSuccess() != null) { + List forumContents = listForumDataResponse.getBody(); + initFirst(forumContents.get(0)); + if (forumContents.size() > 1) { + createReply(forumContents.subList(1, forumContents.size() - 1)); + } + + Toast.makeText(getApplicationContext(), listForumDataResponse.getSuccess(), Toast.LENGTH_LONG).show(); + } + + if (listForumDataResponse.getError() != null) { + Toast.makeText(getApplicationContext(), listForumDataResponse.getError(), Toast.LENGTH_LONG).show(); + } + + + } + }); + + openReply.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showContent(); + } + }); + } + } + + /** + * 构建回帖弹窗 + */ + private void showContent() { + + View alertView = View.inflate(this, R.layout.forum_replay, null); + editText = alertView.findViewById(R.id.post_content); + close = alertView.findViewById(R.id.close); + reply = alertView.findViewById(R.id.reply); + reply.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewModel.sendReply(editText.getText().toString()); + } + }); + + editText.addTextChangedListener(new MyTextChange() { + @Override + public void afterTextChanged(Editable s) { + viewModel.replayFormChanged(editText.getText().toString()); + } + }); + + ShowWordCount showWordCount = new ShowWordCount(new int[]{R.id.show_count_top, R.id.show_count_bottom}, R.id.post_content, alertView); + showWordCount.showCount(); + + AlertDialog.Builder alert = new AlertDialog.Builder(this); + final AlertDialog alertDialog = alert.setTitle(R.string.forum_reply).setView(alertView).create(); + + handler = new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(@NonNull Message msg) { + alertDialog.dismiss(); + } + }; + + close.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + handler.sendEmptyMessage(0); + } + }); + + alertDialog.show(); + } + + /** + * 初始化第一楼数据 + */ + private void initFirst(ForumContent forumContent) { + setData(firstLayout, forumContent); + } + + /** + * 返回 + */ + @Event(value = R.id.back) + private void back(View view) { + finish(); + } + + /** + * 创建楼层数据 + */ + private void createReply(List forumContentList) { + for (ForumContent forumContent : forumContentList) { + View view = View.inflate(this, R.layout.forum_data_content, null); + ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewGroup.MarginLayoutParams marginLayoutParams = new ViewGroup.MarginLayoutParams(layoutParams); + marginLayoutParams.setMargins(0, 50, 0, 0); + setData(view, forumContent); + view.setLayoutParams(marginLayoutParams); + replyLayout.addView(view); + } + } + + /** + * 设置楼层布局 + */ + private void setData(View view, ForumContent forumContent) { + TextView name = view.findViewById(R.id.name); + name.setText(forumContent.getUsername()); + TextView score = view.findViewById(R.id.score); + score.setText(String.valueOf(forumContent.getScore())); + TextView time = view.findViewById(R.id.time); + time.setText(DateFormat.format(getString(R.string.dateformat), forumContent.getTime())); + TextView tower = view.findViewById(R.id.tower); + tower.setText(getString(R.string.tower, forumContent.getTower())); + TextView content = view.findViewById(R.id.content); + content.setText(forumContent.getContent()); + } +} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java new file mode 100644 index 0000000..7042a73 --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java @@ -0,0 +1,46 @@ +package com.community.pocket.ui.main.ui.forum.data; + +import androidx.annotation.Nullable; + +/** + * 帖子详情数据管理 + * + * @param 响应实体 + */ +public class ForumDataResponse { + @Nullable + private Integer success; + @Nullable + private Integer error; + + private T body; + + @Nullable + public Integer getSuccess() { + return success; + } + + public ForumDataResponse setSuccess(@Nullable Integer success) { + this.success = success; + return this; + } + + @Nullable + public Integer getError() { + return error; + } + + public ForumDataResponse setError(@Nullable Integer error) { + this.error = error; + return this; + } + + T getBody() { + return body; + } + + public ForumDataResponse setBody(T body) { + this.body = body; + return this; + } +} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModel.java new file mode 100644 index 0000000..8bc386f --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModel.java @@ -0,0 +1,83 @@ +package com.community.pocket.ui.main.ui.forum.data; + +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +import com.community.pocket.R; +import com.community.pocket.data.main.forum.ForumDataRequest; +import com.community.pocket.data.model.ForumContent; +import com.community.pocket.util.Valid; +import com.community.pocket.util.ValidUtil; + +import java.util.List; + +/** + * 帖子详情数据管理 + */ +class ForumDataViewModel extends ViewModel { + //表单校验状态 + private MutableLiveData forumReplyState = new MutableLiveData<>(); + + //回帖请求状态 + private MutableLiveData replayResponse = new MutableLiveData<>(); + + //帖子详情数据状态 + private MutableLiveData>> forumContentResponse = new MutableLiveData<>(); + + private ForumDataRequest forumDataRequest; + + ForumDataViewModel(ForumDataRequest forumDataRequest) { + this.forumDataRequest = forumDataRequest; + } + + MutableLiveData getForumReplyState() { + return forumReplyState; + } + + MutableLiveData getReplayResponse() { + return replayResponse; + } + + MutableLiveData>> getForumContentResponse() { + return forumContentResponse; + } + + /** + * 校验回帖表单 + * + * @param content 内容 + */ + void replayFormChanged(String content) { + if (!ValidUtil.notesValid(content)) { + forumReplyState.setValue(new ForumReplyState(R.string.invalid_post)); + } else { + forumReplyState.setValue(new ForumReplyState(true)); + } + } + + /** + * 回帖状态 + * + * @param content 内容 + */ + void sendReply(String content) { + Valid valid = forumDataRequest.sendReply(content); + if (valid == Valid.ok) { + replayResponse.setValue(new ForumDataResponse().setSuccess(R.string.forum_reply_ok)); + } else { + replayResponse.setValue(new ForumDataResponse().setError(R.string.forum_reply_fail)); + } + } + + /** + * 加载帖子数据 + * + * @param forumId 帖子id + */ + void loadData(int forumId) { + ForumDataResponse> forumDataResponse = forumDataRequest.loadData(forumId); + forumContentResponse.setValue(forumDataResponse); + } + + +} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModelFactory.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModelFactory.java new file mode 100644 index 0000000..81fe554 --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModelFactory.java @@ -0,0 +1,20 @@ +package com.community.pocket.ui.main.ui.forum.data; + +import androidx.annotation.NonNull; +import androidx.lifecycle.ViewModel; +import androidx.lifecycle.ViewModelProvider; + +import com.community.pocket.data.main.forum.ForumDataRequest; + +public class ForumDataViewModelFactory implements ViewModelProvider.Factory { + @NonNull + @Override + @SuppressWarnings("unchecked") + public T create(@NonNull Class modelClass) { + if (modelClass.isAssignableFrom(ForumDataViewModel.class)) { + return (T) new ForumDataViewModel(ForumDataRequest.getInstance()); + } else { + throw new IllegalArgumentException("Unknown ViewModel class"); + } + } +} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumReplyState.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumReplyState.java new file mode 100644 index 0000000..ed94f4b --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumReplyState.java @@ -0,0 +1,27 @@ +package com.community.pocket.ui.main.ui.forum.data; + +import androidx.annotation.Nullable; + +public class ForumReplyState { + @Nullable + private Integer contentError; + + private boolean isDataValid; + + ForumReplyState(@Nullable Integer contentError) { + this.contentError = contentError; + } + + ForumReplyState(boolean isDataValid) { + this.isDataValid = isDataValid; + } + + @Nullable + Integer getContentError() { + return contentError; + } + + public boolean isDataValid() { + return isDataValid; + } +} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostActiveFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostActiveFragment.java index b78ed2a..a37bb2c 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostActiveFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostActiveFragment.java @@ -54,7 +54,7 @@ public class ForumPostActiveFragment extends ForumPostContent { viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostActiveViewModel.class); - //监控表单校验状态 + //监听表单校验状态 viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(ForumPostFormState.Active forumPostFormState) { @@ -82,7 +82,7 @@ public class ForumPostActiveFragment extends ForumPostContent { } }); - //监控发帖状态 + //监听发帖状态 sendPost(viewModel); TextWatcher textWatcher = new MyTextChange() { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostComplainFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostComplainFragment.java index b1c1081..e12acb1 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostComplainFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostComplainFragment.java @@ -62,7 +62,7 @@ public class ForumPostComplainFragment extends ForumPostContent { viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostComplainViewModel.class); - //监控表单校验状态 + //监听表单校验状态 viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(ForumPostFormState.Complain complain) { @@ -83,7 +83,7 @@ public class ForumPostComplainFragment extends ForumPostContent { } }); - //监控发帖状态 + //监听发帖状态 sendPost(viewModel); viewModel.getSearchPeople().observe(getViewLifecycleOwner(), new Observer>>() { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java index c0b47e0..aeea991 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java @@ -56,7 +56,7 @@ abstract class ForumPostContent extends BaseFragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - ShowWordCount showWordCount = new ShowWordCount(new int[]{R.id.show_count, R.id.show_count_top}, R.id.post_content, view); + ShowWordCount showWordCount = new ShowWordCount(new int[]{R.id.show_count_bottom, R.id.show_count_top}, R.id.post_content, view); showWordCount.showCount(); initParentView(); @@ -74,7 +74,7 @@ abstract class ForumPostContent extends BaseFragment { postContent = contentLayout.findViewById(R.id.post_content); } - //监控发帖状态 + //监听发帖状态 void sendPost(ForumPostViewModel viewModel) { viewModel.getForumPostResponse().observe(getViewLifecycleOwner(), new Observer() { @RequiresApi(api = Build.VERSION_CODES.KITKAT) diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostTopicFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostTopicFragment.java index 0755d25..a573bcc 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostTopicFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostTopicFragment.java @@ -32,7 +32,7 @@ public class ForumPostTopicFragment extends ForumPostContent { viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostTopicViewModel.class); - //监控表单校验状态 + //监听表单校验状态 viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(ForumPostFormState forumPostFormState) { @@ -51,7 +51,7 @@ public class ForumPostTopicFragment extends ForumPostContent { } }); - //监控发帖状态 + //监听发帖状态 sendPost(viewModel); TextWatcher textWatcher = new MyTextChange() { diff --git a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java index 2ffcea2..aa2fb2d 100644 --- a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java @@ -72,7 +72,7 @@ public class ResetPwdStep2 extends BaseFragment { resetPwdViewModel = new ViewModelProvider(this, new ResetPwdViewModelFactory()).get(ResetPwdViewModel.class); - //监控表单数据校验状态 + //监听表单数据校验状态 resetPwdViewModel.getResetPwdFormStep2().observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(ResetPwdFormState.Step2 step2) { diff --git a/app/src/main/java/com/community/pocket/util/Param.java b/app/src/main/java/com/community/pocket/util/Param.java index c9ebd6b..9f8c41f 100644 --- a/app/src/main/java/com/community/pocket/util/Param.java +++ b/app/src/main/java/com/community/pocket/util/Param.java @@ -5,5 +5,6 @@ package com.community.pocket.util; */ public enum Param { username, - email + email, + forumId } diff --git a/app/src/main/res/layout/main/layout/forum/layout/activity_forum_data.xml b/app/src/main/res/layout/main/layout/forum/layout/activity_forum_data.xml index b0e89e5..fc305ba 100644 --- a/app/src/main/res/layout/main/layout/forum/layout/activity_forum_data.xml +++ b/app/src/main/res/layout/main/layout/forum/layout/activity_forum_data.xml @@ -5,16 +5,32 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context=".ui.main.ui.forum.ForumDataActivity"> + tools:context=".ui.main.ui.forum.data.ForumDataActivity"> -