diff --git a/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java b/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java index c0024cd..369973c 100644 --- a/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java +++ b/app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java @@ -28,12 +28,13 @@ public class ForumNewRequest { } @HttpRequest("/forum/new") - public void loadForumNew(MutableLiveData liveData, int page) { + public void loadForumNew(MutableLiveData liveData, int page, String title) { HttpUtil.getRequest(HttpUtil.Method.GET, new SimpleHttpParse(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()) diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java index bc0f51c..67767f5 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java @@ -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() { @@ -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()); } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java index 6b184ba..cc869c1 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java @@ -17,8 +17,8 @@ public class ForumNewViewModel extends BaseViewModel { return forumNewResponse; } - void loadForumNew(int page) { - getRequest().loadForumNew(forumNewResponse, page); + void loadForumNew(int page, String title) { + getRequest().loadForumNew(forumNewResponse, page, title); } @Override diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java index 7da9a63..78b219e 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java @@ -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); diff --git a/app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml b/app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml index 4717235..4d4ea76 100644 --- a/app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml +++ b/app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml @@ -16,10 +16,10 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:layout_height="37dp" /> \ No newline at end of file diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml index 15c3d8e..33b20f2 100644 --- a/app/src/main/res/values-en-rUS/strings.xml +++ b/app/src/main/res/values-en-rUS/strings.xml @@ -216,4 +216,5 @@ not match people complain:%1s 新密码不能与原密码相同 + yyyy-MM-dd HH:mm \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index ac51382..c86c72c 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -216,4 +216,5 @@ 无法匹配任何用户 投诉人:%1s 新密码不能与原密码相同 + yyyy-MM-dd HH:mm \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d9c0ff6..94cd63e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -217,6 +217,7 @@ not match people complain:%1s 新密码不能与原密码相同 + yyyy-MM-dd HH:mm