增加按标题检索帖子

0515
panqihua 5 years ago
parent c9db460d93
commit 0d4e25ee02
  1. 3
      app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java
  2. 27
      app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java
  3. 4
      app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java
  4. 2
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java
  5. 4
      app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml
  6. 1
      app/src/main/res/values-en-rUS/strings.xml
  7. 1
      app/src/main/res/values-zh-rCN/strings.xml
  8. 1
      app/src/main/res/values/strings.xml

@ -28,12 +28,13 @@ public class ForumNewRequest {
}
@HttpRequest("/forum/new")
public void loadForumNew(MutableLiveData<ForumNewResponse> liveData, int page) {
public void loadForumNew(MutableLiveData<ForumNewResponse> liveData, int page, String title) {
HttpUtil.getRequest(HttpUtil.Method.GET,
new SimpleHttpParse<ForumNewResponse>(liveData).getInterface(ForumNewResponse.class),
new FormBody.Builder()
.add("status", ForumStatus.ok.name())
.add("currentPage", String.valueOf(page))
.add("title", title)
.add("forumType", ForumType.active.name())
.add("forumType", ForumType.score.name())
.add("forumType", ForumType.topic.name())

@ -6,6 +6,7 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
@ -14,6 +15,7 @@ import com.community.pocket.ui.main.ui.forum.ForumPost;
import com.community.pocket.ui.main.ui.share.Response;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
/**
* 最新帖子
@ -23,13 +25,34 @@ public class ForumNewFragment extends ForumPost {
private ForumNewViewModel viewModel;
@ViewInject(R.id.search)
private SearchView searchView;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumNewViewModel.class);
viewModel.loadForumNew(1);
viewModel.loadForumNew(1, searchView.getQuery().toString());
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (!query.isEmpty()) {
viewModel.loadForumNew(1, searchView.getQuery().toString());
return true;
} else {
return false;
}
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
//监听最新帖子请求状态
viewModel.getForumNewResponse().observe(getViewLifecycleOwner(), new Observer<ForumNewResponse>() {
@ -62,6 +85,6 @@ public class ForumNewFragment extends ForumPost {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
viewModel.loadForumNew(1);
viewModel.loadForumNew(1, searchView.getQuery().toString());
}
}

@ -17,8 +17,8 @@ public class ForumNewViewModel extends BaseViewModel<ForumNewRequest> {
return forumNewResponse;
}
void loadForumNew(int page) {
getRequest().loadForumNew(forumNewResponse, page);
void loadForumNew(int page, String title) {
getRequest().loadForumNew(forumNewResponse, page, title);
}
@Override

@ -136,7 +136,7 @@ public abstract class VisitorMyVisitor extends BaseFragment {
TextView name = view.findViewById(R.id.name);
name.setText(getString(R.string.visitor_show_name, visitor.getName()));
TextView time = view.findViewById(R.id.time);
time.setText(getString(R.string.visitor_show_time, DateFormat.format(getString(R.string.dateformat), visitor.getTime())));
time.setText(getString(R.string.visitor_show_time, DateFormat.format(getString(R.string.dateformat_visitor), visitor.getTime())));
TextView notes = view.findViewById(R.id.notes);
notes.setText(getString(R.string.visitor_show_notes, visitor.getNotes()));
TextView admin = view.findViewById(R.id.admin);

@ -16,10 +16,10 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<SearchView
<androidx.appcompat.widget.SearchView
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="37dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>

@ -216,4 +216,5 @@
<string name="not_match_people">not match people</string>
<string name="forum_show_complain">complain:%1s</string>
<string name="password_diff">新密码不能与原密码相同</string>
<string name="dateformat_visitor">yyyy-MM-dd HH:mm</string>
</resources>

@ -216,4 +216,5 @@
<string name="not_match_people">无法匹配任何用户</string>
<string name="forum_show_complain">投诉人:%1s</string>
<string name="password_diff">新密码不能与原密码相同</string>
<string name="dateformat_visitor">yyyy-MM-dd HH:mm</string>
</resources>

@ -217,6 +217,7 @@
<string name="not_match_people">not match people</string>
<string name="forum_show_complain">complain:%1s</string>
<string name="password_diff">新密码不能与原密码相同</string>
<string name="dateformat_visitor">yyyy-MM-dd HH:mm</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

Loading…
Cancel
Save