增加帖子详情UI数据管理

0515
panqihua 5 years ago
parent 8025ec4ca3
commit 6e932742ae
  1. 2
      app/src/main/AndroidManifest.xml
  2. 48
      app/src/main/java/com/community/pocket/data/main/forum/ForumDataRequest.java
  3. 88
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java
  4. 8
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java
  5. 242
      app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataActivity.java
  6. 46
      app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataResponse.java
  7. 83
      app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModel.java
  8. 20
      app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataViewModelFactory.java
  9. 27
      app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumReplyState.java
  10. 4
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostActiveFragment.java
  11. 4
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostComplainFragment.java
  12. 4
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java
  13. 4
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostTopicFragment.java
  14. 2
      app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java
  15. 3
      app/src/main/java/com/community/pocket/util/Param.java
  16. 32
      app/src/main/res/layout/main/layout/forum/layout/activity_forum_data.xml
  17. 2
      app/src/main/res/layout/main/layout/forum/layout/forum_post_content.xml
  18. 39
      app/src/main/res/layout/main/layout/forum/layout/forum_replay.xml
  19. 5
      app/src/main/res/values-en-rUS/strings.xml
  20. 5
      app/src/main/res/values-zh-rCN/strings.xml
  21. 5
      app/src/main/res/values/strings.xml

@ -10,7 +10,7 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<activity android:name=".ui.main.ui.forum.ForumDataActivity" /> <activity android:name=".ui.main.ui.forum.data.ForumDataActivity" />
<activity android:name=".ui.main.MainMenu" /> <activity android:name=".ui.main.MainMenu" />
<activity android:name=".ui.resetpwd.ResetPwdActivity" /> <activity android:name=".ui.resetpwd.ResetPwdActivity" />
<activity android:name=".ui.register.RegisterActivity" /> <activity android:name=".ui.register.RegisterActivity" />

@ -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<List<ForumContent>> loadData(int forumId) {
return new ForumDataResponse<List<ForumContent>>().setSuccess(R.string.forum_data_ok).setBody(new ArrayList<ForumContent>() {{
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);
}
}});
}
}

@ -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("我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋");
}
}

@ -1,5 +1,6 @@
package com.community.pocket.ui.main.ui.forum; package com.community.pocket.ui.main.ui.forum;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.format.DateFormat; import android.text.format.DateFormat;
@ -14,6 +15,8 @@ import androidx.annotation.Nullable;
import com.community.pocket.R; import com.community.pocket.R;
import com.community.pocket.ui.BaseFragment; 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; import org.xutils.view.annotation.ViewInject;
@ -38,6 +41,7 @@ public abstract class ForumPost extends BaseFragment {
* 加载帖子数据 * 加载帖子数据
* TODO 测试数据 * TODO 测试数据
*/ */
@SuppressLint("SetTextI18n")
private void loadPost(View view) { private void loadPost(View view) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
@ -66,7 +70,9 @@ public abstract class ForumPost extends BaseFragment {
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { 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);
} }
}); });

@ -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<ForumReplyState>() {
@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<ForumDataResponse>() {
@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<ForumDataResponse<List<ForumContent>>>() {
@Override
public void onChanged(ForumDataResponse<List<ForumContent>> listForumDataResponse) {
if (listForumDataResponse == null) {
return;
}
if (listForumDataResponse.getSuccess() != null) {
List<ForumContent> 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<ForumContent> 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());
}
}

@ -0,0 +1,46 @@
package com.community.pocket.ui.main.ui.forum.data;
import androidx.annotation.Nullable;
/**
* 帖子详情数据管理
*
* @param <T> 响应实体
*/
public class ForumDataResponse<T> {
@Nullable
private Integer success;
@Nullable
private Integer error;
private T body;
@Nullable
public Integer getSuccess() {
return success;
}
public ForumDataResponse<T> setSuccess(@Nullable Integer success) {
this.success = success;
return this;
}
@Nullable
public Integer getError() {
return error;
}
public ForumDataResponse<T> setError(@Nullable Integer error) {
this.error = error;
return this;
}
T getBody() {
return body;
}
public ForumDataResponse<T> setBody(T body) {
this.body = body;
return this;
}
}

@ -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> forumReplyState = new MutableLiveData<>();
//回帖请求状态
private MutableLiveData<ForumDataResponse> replayResponse = new MutableLiveData<>();
//帖子详情数据状态
private MutableLiveData<ForumDataResponse<List<ForumContent>>> forumContentResponse = new MutableLiveData<>();
private ForumDataRequest forumDataRequest;
ForumDataViewModel(ForumDataRequest forumDataRequest) {
this.forumDataRequest = forumDataRequest;
}
MutableLiveData<ForumReplyState> getForumReplyState() {
return forumReplyState;
}
MutableLiveData<ForumDataResponse> getReplayResponse() {
return replayResponse;
}
MutableLiveData<ForumDataResponse<List<ForumContent>>> 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<List<ForumContent>> forumDataResponse = forumDataRequest.loadData(forumId);
forumContentResponse.setValue(forumDataResponse);
}
}

@ -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 extends ViewModel> T create(@NonNull Class<T> modelClass) {
if (modelClass.isAssignableFrom(ForumDataViewModel.class)) {
return (T) new ForumDataViewModel(ForumDataRequest.getInstance());
} else {
throw new IllegalArgumentException("Unknown ViewModel class");
}
}
}

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

@ -54,7 +54,7 @@ public class ForumPostActiveFragment extends ForumPostContent {
viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostActiveViewModel.class); viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostActiveViewModel.class);
//监表单校验状态 //监表单校验状态
viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer<ForumPostFormState.Active>() { viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer<ForumPostFormState.Active>() {
@Override @Override
public void onChanged(ForumPostFormState.Active forumPostFormState) { public void onChanged(ForumPostFormState.Active forumPostFormState) {
@ -82,7 +82,7 @@ public class ForumPostActiveFragment extends ForumPostContent {
} }
}); });
//监发帖状态 //监发帖状态
sendPost(viewModel); sendPost(viewModel);
TextWatcher textWatcher = new MyTextChange() { TextWatcher textWatcher = new MyTextChange() {

@ -62,7 +62,7 @@ public class ForumPostComplainFragment extends ForumPostContent {
viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostComplainViewModel.class); viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostComplainViewModel.class);
//监表单校验状态 //监表单校验状态
viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer<ForumPostFormState.Complain>() { viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer<ForumPostFormState.Complain>() {
@Override @Override
public void onChanged(ForumPostFormState.Complain complain) { public void onChanged(ForumPostFormState.Complain complain) {
@ -83,7 +83,7 @@ public class ForumPostComplainFragment extends ForumPostContent {
} }
}); });
//监发帖状态 //监发帖状态
sendPost(viewModel); sendPost(viewModel);
viewModel.getSearchPeople().observe(getViewLifecycleOwner(), new Observer<ForumPostResponse<List<String>>>() { viewModel.getSearchPeople().observe(getViewLifecycleOwner(), new Observer<ForumPostResponse<List<String>>>() {

@ -56,7 +56,7 @@ abstract class ForumPostContent extends BaseFragment {
@Override @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, 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(); showWordCount.showCount();
initParentView(); initParentView();
@ -74,7 +74,7 @@ abstract class ForumPostContent extends BaseFragment {
postContent = contentLayout.findViewById(R.id.post_content); postContent = contentLayout.findViewById(R.id.post_content);
} }
//监发帖状态 //监发帖状态
void sendPost(ForumPostViewModel viewModel) { void sendPost(ForumPostViewModel viewModel) {
viewModel.getForumPostResponse().observe(getViewLifecycleOwner(), new Observer<ForumPostResponse>() { viewModel.getForumPostResponse().observe(getViewLifecycleOwner(), new Observer<ForumPostResponse>() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @RequiresApi(api = Build.VERSION_CODES.KITKAT)

@ -32,7 +32,7 @@ public class ForumPostTopicFragment extends ForumPostContent {
viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostTopicViewModel.class); viewModel = new ViewModelProvider(this, new ForumPostViewModelFactory()).get(ForumPostTopicViewModel.class);
//监表单校验状态 //监表单校验状态
viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer<ForumPostFormState>() { viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer<ForumPostFormState>() {
@Override @Override
public void onChanged(ForumPostFormState forumPostFormState) { public void onChanged(ForumPostFormState forumPostFormState) {
@ -51,7 +51,7 @@ public class ForumPostTopicFragment extends ForumPostContent {
} }
}); });
//监发帖状态 //监发帖状态
sendPost(viewModel); sendPost(viewModel);
TextWatcher textWatcher = new MyTextChange() { TextWatcher textWatcher = new MyTextChange() {

@ -72,7 +72,7 @@ public class ResetPwdStep2 extends BaseFragment {
resetPwdViewModel = new ViewModelProvider(this, new ResetPwdViewModelFactory()).get(ResetPwdViewModel.class); resetPwdViewModel = new ViewModelProvider(this, new ResetPwdViewModelFactory()).get(ResetPwdViewModel.class);
//监表单数据校验状态 //监表单数据校验状态
resetPwdViewModel.getResetPwdFormStep2().observe(getViewLifecycleOwner(), new Observer<ResetPwdFormState.Step2>() { resetPwdViewModel.getResetPwdFormStep2().observe(getViewLifecycleOwner(), new Observer<ResetPwdFormState.Step2>() {
@Override @Override
public void onChanged(ResetPwdFormState.Step2 step2) { public void onChanged(ResetPwdFormState.Step2 step2) {

@ -5,5 +5,6 @@ package com.community.pocket.util;
*/ */
public enum Param { public enum Param {
username, username,
email email,
forumId
} }

@ -5,16 +5,32 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
tools:context=".ui.main.ui.forum.ForumDataActivity"> tools:context=".ui.main.ui.forum.data.ForumDataActivity">
<Button <LinearLayout
android:id="@+id/back" android:id="@+id/button_layout"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/action_back" android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/back"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/action_back" />
<Button
android:id="@+id/open_reply"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/forum_reply" />
</LinearLayout>
<include <include
android:id="@+id/first_layout" android:id="@+id/first_layout"
@ -23,7 +39,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/back" /> app:layout_constraintTop_toBottomOf="@id/button_layout" />
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"

@ -31,7 +31,7 @@
app:layout_constraintTop_toBottomOf="@id/show_count_top" /> app:layout_constraintTop_toBottomOf="@id/show_count_top" />
<TextView <TextView
android:id="@+id/show_count" android:id="@+id/show_count_bottom"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"

@ -0,0 +1,39 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/content_layout"
layout="@layout/forum_post_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/content_layout">
<Button
android:id="@+id/reply"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:enabled="false"
android:text="@string/forum_reply" />
<Button
android:id="@+id/close"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/action_close" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -127,4 +127,9 @@
<string name="dateformat_tip">date format must be %1s,such as %2s</string> <string name="dateformat_tip">date format must be %1s,such as %2s</string>
<string name="forum_search_people_ok">search OK</string> <string name="forum_search_people_ok">search OK</string>
<string name="forum_search_people_fail">search fail</string> <string name="forum_search_people_fail">search fail</string>
<string name="forum_reply">reply</string>
<string name="forum_reply_ok">reply OK</string>
<string name="forum_reply_fail">reply fail</string>
<string name="forum_data_ok">load success</string>
<string name="forum_data_fail">load error</string>
</resources> </resources>

@ -127,4 +127,9 @@
<string name="dateformat_tip">日期格式必须是:%1s,例如:%2s</string> <string name="dateformat_tip">日期格式必须是:%1s,例如:%2s</string>
<string name="forum_search_people_ok">检索投诉人成功</string> <string name="forum_search_people_ok">检索投诉人成功</string>
<string name="forum_search_people_fail">检索投诉人失败</string> <string name="forum_search_people_fail">检索投诉人失败</string>
<string name="forum_reply">回帖</string>
<string name="forum_reply_ok">" 回帖成功"</string>
<string name="forum_reply_fail">回帖失败</string>
<string name="forum_data_ok">帖子详情加载成功</string>
<string name="forum_data_fail">帖子详情加载失败</string>
</resources> </resources>

@ -128,6 +128,11 @@
<string name="dateformat_tip">date format must be %1s,such as %2s</string> <string name="dateformat_tip">date format must be %1s,such as %2s</string>
<string name="forum_search_people_ok">search OK</string> <string name="forum_search_people_ok">search OK</string>
<string name="forum_search_people_fail">search fail</string> <string name="forum_search_people_fail">search fail</string>
<string name="forum_reply">reply</string>
<string name="forum_reply_ok">reply OK</string>
<string name="forum_reply_fail">reply fail</string>
<string name="forum_data_ok">load success</string>
<string name="forum_data_fail">load error</string>
<!-- Strings used for fragments for navigation --> <!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation --> <!-- Strings used for fragments for navigation -->

Loading…
Cancel
Save