parent
aa20cb47d5
commit
107a24f1ec
@ -1,7 +1,15 @@ |
|||||||
package com.community.pocket.data.model; |
package com.community.pocket.data.model; |
||||||
|
|
||||||
|
/** |
||||||
|
* 帖子类型 |
||||||
|
*/ |
||||||
public enum ForumType { |
public enum ForumType { |
||||||
|
//悬赏
|
||||||
active, |
active, |
||||||
|
//话题
|
||||||
topic, |
topic, |
||||||
complan |
//投诉
|
||||||
|
complan, |
||||||
|
//结算
|
||||||
|
score |
||||||
} |
} |
||||||
|
@ -0,0 +1,26 @@ |
|||||||
|
package com.community.pocket.data.model; |
||||||
|
|
||||||
|
/** |
||||||
|
* 结算贴 |
||||||
|
*/ |
||||||
|
public class Score { |
||||||
|
private String id; |
||||||
|
//结算分数
|
||||||
|
private Integer activeScore; |
||||||
|
|
||||||
|
public String getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(String id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public Integer getActiveScore() { |
||||||
|
return activeScore; |
||||||
|
} |
||||||
|
|
||||||
|
public void setActiveScore(Integer activeScore) { |
||||||
|
this.activeScore = activeScore; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
package com.community.pocket.ui.main.ui.forum.post; |
||||||
|
|
||||||
|
import android.os.Bundle; |
||||||
|
import android.text.Editable; |
||||||
|
import android.text.TextWatcher; |
||||||
|
import android.view.View; |
||||||
|
import android.widget.EditText; |
||||||
|
|
||||||
|
import androidx.annotation.Nullable; |
||||||
|
import androidx.lifecycle.Observer; |
||||||
|
import androidx.lifecycle.ViewModelProvider; |
||||||
|
|
||||||
|
import com.community.pocket.R; |
||||||
|
import com.community.pocket.ui.listener.MyTextChange; |
||||||
|
import com.community.pocket.util.PropertiesUtil; |
||||||
|
|
||||||
|
import org.xutils.view.annotation.ContentView; |
||||||
|
import org.xutils.view.annotation.ViewInject; |
||||||
|
|
||||||
|
/** |
||||||
|
* 悬赏贴布局 |
||||||
|
*/ |
||||||
|
@ContentView(R.layout.forum_post_score_fragment) |
||||||
|
public class ForumPostScore extends ForumPostContent { |
||||||
|
|
||||||
|
private ForumPostScoreViewModel viewModel; |
||||||
|
|
||||||
|
@ViewInject(R.id.active_score) |
||||||
|
private EditText activeScore; |
||||||
|
|
||||||
|
public static ForumPostScore newInstance() { |
||||||
|
return new ForumPostScore(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) { |
||||||
|
super.onActivityCreated(savedInstanceState); |
||||||
|
viewModel = new ViewModelProvider.NewInstanceFactory().create(ForumPostScoreViewModel.class); |
||||||
|
|
||||||
|
//监听表单校验状态
|
||||||
|
viewModel.getForumPostFormState().observe(getViewLifecycleOwner(), new Observer<ForumPostFormState.Score>() { |
||||||
|
@Override |
||||||
|
public void onChanged(ForumPostFormState.Score forumPostFormState) { |
||||||
|
if (forumPostFormState == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (forumPostFormState.getTitleError() != null) { |
||||||
|
postTitle.setError(getString(forumPostFormState.getTitleError())); |
||||||
|
} |
||||||
|
if (forumPostFormState.getContentError() != null) { |
||||||
|
postContent.setError(getString(forumPostFormState.getContentError())); |
||||||
|
} |
||||||
|
if (forumPostFormState.getScoreError() != null) { |
||||||
|
activeScore.setError(getString(forumPostFormState.getScoreError(), PropertiesUtil.getIntValue("score.max"))); |
||||||
|
} |
||||||
|
|
||||||
|
postButton.setEnabled(forumPostFormState.isDataValid()); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
//监听发帖状态
|
||||||
|
sendPost(viewModel); |
||||||
|
|
||||||
|
TextWatcher textWatcher = new MyTextChange() { |
||||||
|
@Override |
||||||
|
public void afterTextChanged(Editable s) { |
||||||
|
viewModel.scoreFormChanged(postTitle.getText().toString(), postContent.getText().toString(), activeScore.getText().toString()); |
||||||
|
} |
||||||
|
}; |
||||||
|
postTitle.addTextChangedListener(textWatcher); |
||||||
|
postContent.addTextChangedListener(textWatcher); |
||||||
|
activeScore.addTextChangedListener(textWatcher); |
||||||
|
|
||||||
|
//发帖操作
|
||||||
|
postButton.setOnClickListener(new View.OnClickListener() { |
||||||
|
@Override |
||||||
|
public void onClick(View v) { |
||||||
|
viewModel.sendScore(postTitle.getText().toString(), postContent.getText().toString(), activeScore.getText().toString()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.community.pocket.ui.main.ui.forum.post; |
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData; |
||||||
|
|
||||||
|
import com.community.pocket.R; |
||||||
|
import com.community.pocket.util.ValidUtil; |
||||||
|
|
||||||
|
public class ForumPostScoreViewModel extends ForumPostViewModel { |
||||||
|
private MutableLiveData<ForumPostFormState.Score> forumPostFormState = new MutableLiveData<>(); |
||||||
|
|
||||||
|
MutableLiveData<ForumPostFormState.Score> getForumPostFormState() { |
||||||
|
return forumPostFormState; |
||||||
|
} |
||||||
|
|
||||||
|
//结算表单校验
|
||||||
|
void scoreFormChanged(String title, String content, String activeScore) { |
||||||
|
if (!ValidUtil.titleValid(title)) { |
||||||
|
forumPostFormState.setValue(new ForumPostFormState.Score(R.string.invalid_title, null, null)); |
||||||
|
} else if (!ValidUtil.notesValid(content)) { |
||||||
|
forumPostFormState.setValue(new ForumPostFormState.Score(null, R.string.invalid_post, null)); |
||||||
|
} else if (!ValidUtil.scoreValid(activeScore)) { |
||||||
|
forumPostFormState.setValue(new ForumPostFormState.Score(null, null, R.string.invalid_score)); |
||||||
|
} else { |
||||||
|
forumPostFormState.setValue(new ForumPostFormState.Score(true)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//发送结算贴贴
|
||||||
|
void sendScore(String title, String content, String activeScore) { |
||||||
|
getRequest().sendScore(forumPostResponse, title, content, activeScore); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package com.community.pocket.util; |
||||||
|
|
||||||
|
public enum BuildType { |
||||||
|
rap2debug("rap2"), |
||||||
|
serverdebug("springboot"); |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
BuildType(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
<vector android:height="50dp" |
||||||
|
android:viewportHeight="1024" |
||||||
|
android:viewportWidth="1024" |
||||||
|
android:width="50dp" |
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"> |
||||||
|
<path |
||||||
|
android:fillColor="#FF000000" |
||||||
|
android:pathData="M810.67,273.49L750.51,213.33 512,451.84 273.49,213.33 213.33,273.49 451.84,512 213.33,750.51 273.49,810.67 512,572.16 750.51,810.67 810.67,750.51 572.16,512z" /> |
||||||
|
</vector> |
@ -0,0 +1,74 @@ |
|||||||
|
<?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"> |
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:fillViewport="true" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent"> |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:id="@+id/my_layout" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:orientation="vertical"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/build_type" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/mode" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/url" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="18sp" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/error" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:text="@string/connect_server_error" |
||||||
|
android:textSize="24sp" /> |
||||||
|
|
||||||
|
<Button |
||||||
|
android:id="@+id/open_url" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="@dimen/size_30" |
||||||
|
android:text="@string/open_url" |
||||||
|
android:textSize="24sp" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="@dimen/size_30" |
||||||
|
android:gravity="center" |
||||||
|
android:text="@string/error_log" |
||||||
|
android:textSize="24sp" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/detailError" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:singleLine="false" |
||||||
|
android:textColor="#F44336" /> |
||||||
|
</LinearLayout> |
||||||
|
</androidx.core.widget.NestedScrollView> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
@ -0,0 +1,42 @@ |
|||||||
|
<?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"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/confirm" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:text="@string/exit_app" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="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/confirm"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/yes" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_weight="1" |
||||||
|
android:gravity="center" |
||||||
|
android:text="@string/YES" |
||||||
|
android:textSize="24sp" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/no" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_weight="1" |
||||||
|
android:gravity="center" |
||||||
|
android:text="@string/NO" |
||||||
|
android:textSize="24sp" /> |
||||||
|
</LinearLayout> |
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
@ -0,0 +1,24 @@ |
|||||||
|
<?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="wrap_content"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="50dp" |
||||||
|
android:gravity="center" |
||||||
|
android:text="@string/debug" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
|
||||||
|
<ImageView |
||||||
|
android:id="@+id/close" |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:contentDescription="@string/headimg" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" |
||||||
|
app:srcCompat="@drawable/ic_close" /> |
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
@ -0,0 +1,45 @@ |
|||||||
|
<?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="wrap_content"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/registration_deadline" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/active_start_time" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@id/registration_deadline" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/active_end_time" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@id/active_start_time" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/active_score" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@id/active_end_time" /> |
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
@ -0,0 +1,15 @@ |
|||||||
|
<?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"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/complain" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
@ -0,0 +1,15 @@ |
|||||||
|
<?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"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:id="@+id/active_score" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:gravity="center" |
||||||
|
android:textSize="24sp" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toTopOf="parent" /> |
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
@ -0,0 +1,34 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<FrameLayout 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" |
||||||
|
tools:context=".ui.main.ui.forum.post.ForumPostScore"> |
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent"> |
||||||
|
|
||||||
|
<include |
||||||
|
android:id="@+id/post_content_layout" |
||||||
|
layout="@layout/forum_post_content" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" /> |
||||||
|
|
||||||
|
<EditText |
||||||
|
android:id="@+id/active_score" |
||||||
|
android:layout_width="0dp" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="8dp" |
||||||
|
android:ems="10" |
||||||
|
android:hint="@string/prompt_active_score" |
||||||
|
android:importantForAutofill="no" |
||||||
|
android:inputType="number" |
||||||
|
app:layout_constraintEnd_toEndOf="parent" |
||||||
|
app:layout_constraintStart_toStartOf="parent" |
||||||
|
app:layout_constraintTop_toBottomOf="@id/post_content_layout" /> |
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout> |
||||||
|
|
||||||
|
</FrameLayout> |
Loading…
Reference in new issue