完善加载更多帖子逻辑

0515
panqihua 5 years ago
parent 6c43376443
commit 174661a375
  1. 2
      app/src/main/java/com/community/pocket/data/main/forum/ForumMyRequest.java
  2. 2
      app/src/main/java/com/community/pocket/data/main/forum/ForumNewRequest.java
  3. 13
      app/src/main/java/com/community/pocket/ui/BaseFragment.java
  4. 5
      app/src/main/java/com/community/pocket/ui/main/ui/forum/FormLoad.java
  5. 49
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java
  6. 39
      app/src/main/java/com/community/pocket/ui/main/ui/forum/main/ForumFragment.java
  7. 43
      app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyFragment.java
  8. 2
      app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyResponse.java
  9. 11
      app/src/main/java/com/community/pocket/ui/main/ui/forum/my/ForumMyViewModel.java
  10. 51
      app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewFragment.java
  11. 2
      app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewResponse.java
  12. 6
      app/src/main/java/com/community/pocket/ui/main/ui/forum/news/ForumNewViewModel.java
  13. 27
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java
  14. 76
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java
  15. 1
      app/src/main/res/layout/main/layout/forum/layout/forum.xml
  16. 124
      app/src/main/res/layout/main/layout/forum/layout/forum_hot_fragment.xml
  17. 32
      app/src/main/res/layout/main/layout/forum/layout/forum_my_fragment.xml
  18. 32
      app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml
  19. 80
      app/src/main/res/layout/main/layout/forum/layout/forum_post_fragment.xml
  20. 263
      app/src/main/res/layout/main/layout/visitor/layout/visitor_appointment_fragment.xml
  21. 1
      app/src/main/res/values-en-rUS/strings.xml
  22. 1
      app/src/main/res/values-zh-rCN/strings.xml
  23. 1
      app/src/main/res/values/strings.xml

@ -31,7 +31,7 @@ public class ForumMyRequest {
* 加载我的帖子
*/
@HttpRequest("/forum/my")
public void loadForumMy(MutableLiveData<ForumMyResponse> liveData, int page, String title) {
public void loadForumMy(MutableLiveData<ForumMyResponse> liveData, Long page, String title) {
HttpUtil.getRequest(HttpUtil.Method.GET,
new SimpleHttpParse<ForumMyResponse>(liveData).getInterface(ForumMyResponse.class),
new FormBody.Builder()

@ -28,7 +28,7 @@ public class ForumNewRequest {
}
@HttpRequest("/forum/new")
public void loadForumNew(MutableLiveData<ForumNewResponse> liveData, int page, String title) {
public void loadForumNew(MutableLiveData<ForumNewResponse> liveData, Long page, String title) {
HttpUtil.getRequest(HttpUtil.Method.GET,
new SimpleHttpParse<ForumNewResponse>(liveData).getInterface(ForumNewResponse.class),
new FormBody.Builder()

@ -27,8 +27,8 @@ public abstract class BaseFragment extends Fragment {
}
//获取父级Fragment
protected <T extends Fragment> T getParentFragment(int level) {
return getParentFragment(level, null);
protected <T extends Fragment> T getParentFragment(Class<T> tClass) {
return getParentFragment(tClass, null);
}
//校验token失败跳转到登陆页
@ -38,17 +38,18 @@ public abstract class BaseFragment extends Fragment {
//获取父级Fragment
@SuppressWarnings("unchecked")
private <T extends Fragment> T getParentFragment(int level, Fragment fragment) {
if (level-- > 0) {
private <T extends Fragment> T getParentFragment(Class<T> tClass, Fragment fragment) {
if (fragment == null) {
fragment = getParentFragment();
} else {
fragment = fragment.getParentFragment();
}
return getParentFragment(level, fragment);
if (fragment != null) {
return fragment.getClass().isAssignableFrom(tClass) ? (T) fragment : getParentFragment(tClass, fragment);
} else {
return (T) fragment;
throw new RuntimeException("not fround parent Fragment for " + tClass);
}
}
//格式化日期

@ -0,0 +1,5 @@
package com.community.pocket.ui.main.ui.forum;
public interface FormLoad {
void loadForumNew(Long page, String title);
}

@ -1,18 +1,23 @@
package com.community.pocket.ui.main.ui.forum;
import android.content.Intent;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.SearchView;
import androidx.core.widget.NestedScrollView;
import com.community.pocket.R;
import com.community.pocket.data.model.Forum;
import com.community.pocket.data.model.Page;
import com.community.pocket.ui.BaseFragment;
import com.community.pocket.ui.main.ui.forum.data.ForumDataActivity;
import com.community.pocket.ui.main.ui.forum.main.ForumFragment;
import com.community.pocket.util.Param;
import org.xutils.view.annotation.ViewInject;
@ -33,10 +38,9 @@ public abstract class ForumPost extends BaseFragment {
*/
protected void loadPost(Page<Forum> forumList) {
if (forumList.isEmpty()) {
Toast.makeText(getContext(), R.string.no_more_forum, Toast.LENGTH_LONG).show();
} else {
layout.removeViews(1, layout.getChildCount() - 1);
if (forumList.getCurrentPage() == 1) {
layout.removeAllViews();
}
for (int i = 0; i < forumList.getList().size(); i++) {
final Forum forum = forumList.getList().get(i);
@ -74,19 +78,36 @@ public abstract class ForumPost extends BaseFragment {
//打开帖子
Button button = childView.findViewById(R.id.showAll);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), ForumDataActivity.class);
intent.putExtra(Param.forumId.name(), forum.getId());
startActivityForResult(intent, 1);
// startActivity(intent);
}
button.setOnClickListener(v -> {
Intent intent = new Intent(getContext(), ForumDataActivity.class);
intent.putExtra(Param.forumId.name(), forum.getId());
startActivityForResult(intent, 1);
});
layout.addView(childView);
}
}
}
protected abstract FormLoad getViewModel();
protected abstract Long getCurrentPage();
protected abstract SearchView searchView();
protected void load(Long page) {
getViewModel().loadForumNew(page, searchView().getQuery().toString());
}
//滚动加载更多帖子
@RequiresApi(api = Build.VERSION_CODES.M)
protected void loadMore() {
//滚动加载更多帖子
ForumFragment forumFragment = getParentFragment(ForumFragment.class);
forumFragment.getScrollView().setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
load(getCurrentPage() + 1);
}
});
}
}

@ -3,6 +3,7 @@ package com.community.pocket.ui.main.ui.forum.main;
import android.annotation.SuppressLint;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
@ -12,6 +13,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.widget.NestedScrollView;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModelProvider;
import com.community.pocket.R;
@ -26,6 +28,7 @@ import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 论坛框架
@ -37,7 +40,7 @@ public class ForumFragment extends MainFragment {
private MyBanner banner;
@ViewInject(R.id.scroll_body)
private NestedScrollView nestedScrollView;
private NestedScrollView scrollView;
@ViewInject(R.id.forum_new)
private Button newButton;
@ -47,6 +50,9 @@ public class ForumFragment extends MainFragment {
@ViewInject(R.id.notice_next)
private ImageView noticeNext;
//触发自动滚动
private MutableLiveData<Boolean> autoScroll = new MutableLiveData<>();
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
@ -69,6 +75,8 @@ public class ForumFragment extends MainFragment {
initNotice(forumNoticeResponse.getNoticeList());
}
});
resumeAutoScroll();
}
//初始化公告箭头事件
@ -79,6 +87,10 @@ public class ForumFragment extends MainFragment {
initClickListener(noticeNext);
}
public NestedScrollView getScrollView() {
return scrollView;
}
//箭头随焦点改变透明度
@SuppressLint("ClickableViewAccessibility")
private void initFocusListener(ImageView imageView) {
@ -103,6 +115,24 @@ public class ForumFragment extends MainFragment {
} else {
banner.setCurrentItem(banner.getCurrentItem() < banner.getItemCount() - 1 ? banner.getCurrentItem() + 1 : 0);
}
new Thread(() -> {
try {
TimeUnit.SECONDS.sleep(3);
autoScroll.postValue(true);
} catch (InterruptedException e) {
e.printStackTrace();
Log.e(ForumFragment.class.getName(), e.toString());
}
}).start();
});
}
//恢复自动滚动
private void resumeAutoScroll() {
this.autoScroll.observe(getViewLifecycleOwner(), aBoolean -> {
if (aBoolean) {
banner.start();
}
});
}
@ -127,10 +157,11 @@ public class ForumFragment extends MainFragment {
}
private void scrollTop() {
nestedScrollView.fling(0);
nestedScrollView.smoothScrollTo(0, 0);
scrollView.fling(0);
scrollView.smoothScrollTo(0, 0);
}
//跳转热榜界面
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Event(value = R.id.forum_hot)

@ -7,10 +7,10 @@ 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;
import com.community.pocket.R;
import com.community.pocket.ui.main.ui.forum.FormLoad;
import com.community.pocket.ui.main.ui.forum.ForumPost;
import com.community.pocket.ui.main.ui.share.Response;
@ -28,19 +28,21 @@ public class ForumMyFragment extends ForumPost {
@ViewInject(R.id.search)
private SearchView searchView;
private Long currentPage = 1L;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(ForumMyViewModel.class);
viewModel.loadForumMy(1, "");
load(1L);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (!query.isEmpty()) {
viewModel.loadForumMy(1, searchView.getQuery().toString());
load(1L);
return true;
} else {
return false;
@ -55,18 +57,16 @@ public class ForumMyFragment extends ForumPost {
});
//监听我的帖子加载状态
viewModel.getForumMyResponse().observe(getViewLifecycleOwner(), new Observer<ForumMyResponse>() {
@Override
public void onChanged(ForumMyResponse forumMyResponse) {
if (forumMyResponse == null) {
return;
}
viewModel.getForumMyResponse().observe(getViewLifecycleOwner(), forumMyResponse -> {
if (forumMyResponse == null) {
return;
}
forumMyResponse.toast(getContext());
forumMyResponse.toast(getContext());
if (forumMyResponse.getResult() == Response.Result.OK) {
loadPost(forumMyResponse.getForumList());
}
if (forumMyResponse.getResult() == Response.Result.OK) {
this.currentPage = forumMyResponse.getForumList().getCurrentPage();
loadPost(forumMyResponse.getForumList());
}
});
}
@ -81,10 +81,25 @@ public class ForumMyFragment extends ForumPost {
return View.VISIBLE;
}
@Override
protected FormLoad getViewModel() {
return viewModel;
}
@Override
protected Long getCurrentPage() {
return currentPage;
}
@Override
protected SearchView searchView() {
return searchView;
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
viewModel.loadForumMy(1, "");
load(1L);
}
}

@ -23,6 +23,8 @@ public class ForumMyResponse extends Response<ForumMyResponse.Msg> {
enum Msg implements CustomMessage {
ok(R.string.load_forum_my_ok),
ok_empty(R.string.no_more_forum),
ok_more(R.string.load_more_forum_ok),
fail(R.string.load_forum_my_fail),
token(R.string.invalid_token);

@ -3,10 +3,11 @@ package com.community.pocket.ui.main.ui.forum.my;
import androidx.lifecycle.MutableLiveData;
import com.community.pocket.data.main.forum.ForumMyRequest;
import com.community.pocket.ui.main.ui.forum.FormLoad;
import com.community.pocket.ui.main.ui.share.BaseViewModel;
//我的帖子UI数据管理
public class ForumMyViewModel extends BaseViewModel<ForumMyRequest> {
public class ForumMyViewModel extends BaseViewModel<ForumMyRequest> implements FormLoad {
//我的帖子请求状态
private MutableLiveData<ForumMyResponse> forumMyResponse = new MutableLiveData<>();
@ -15,12 +16,14 @@ public class ForumMyViewModel extends BaseViewModel<ForumMyRequest> {
return forumMyResponse;
}
void loadForumMy(int page, String title) {
getRequest().loadForumMy(forumMyResponse, page, title);
}
@Override
protected ForumMyRequest getRequest() {
return ForumMyRequest.getInstance();
}
@Override
public void loadForumNew(Long page, String title) {
getRequest().loadForumMy(forumMyResponse, page, title);
}
}

@ -1,16 +1,17 @@
package com.community.pocket.ui.main.ui.forum.news;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
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;
import com.community.pocket.R;
import com.community.pocket.ui.main.ui.forum.FormLoad;
import com.community.pocket.ui.main.ui.forum.ForumPost;
import com.community.pocket.ui.main.ui.share.Response;
@ -28,19 +29,21 @@ public class ForumNewFragment extends ForumPost {
@ViewInject(R.id.search)
private SearchView searchView;
private Long currentPage = 1L;
@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, searchView.getQuery().toString());
load(1L);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (!query.isEmpty()) {
viewModel.loadForumNew(1, searchView.getQuery().toString());
load(1L);
return true;
} else {
return false;
@ -54,21 +57,25 @@ public class ForumNewFragment extends ForumPost {
}
});
//监听最新帖子请求状态
viewModel.getForumNewResponse().observe(getViewLifecycleOwner(), new Observer<ForumNewResponse>() {
@Override
public void onChanged(ForumNewResponse forumNewResponse) {
if (forumNewResponse == null) {
return;
}
viewModel.getForumNewResponse().observe(getViewLifecycleOwner(), forumNewResponse -> {
if (forumNewResponse == null) {
return;
}
forumNewResponse.toast(getContext());
forumNewResponse.toast(getContext());
if (forumNewResponse.getResult() == Response.Result.OK) {
loadPost(forumNewResponse.getForumList());
}
if (forumNewResponse.getResult() == Response.Result.OK) {
this.currentPage = forumNewResponse.getForumList().getCurrentPage();
loadPost(forumNewResponse.getForumList());
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
loadMore();
}
}
@Override
@ -81,10 +88,24 @@ public class ForumNewFragment extends ForumPost {
return View.GONE;
}
@Override
protected FormLoad getViewModel() {
return viewModel;
}
@Override
protected Long getCurrentPage() {
return currentPage;
}
@Override
protected SearchView searchView() {
return searchView;
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
viewModel.loadForumNew(1, searchView.getQuery().toString());
load(1L);
}
}

@ -18,6 +18,8 @@ public class ForumNewResponse extends Response<ForumNewResponse.Msg> {
enum Msg implements CustomMessage {
ok(R.string.load_forum_new_ok),
ok_empty(R.string.no_more_forum),
ok_more(R.string.load_more_forum_ok),
fail(R.string.load_forum_new_fail);

@ -3,12 +3,13 @@ package com.community.pocket.ui.main.ui.forum.news;
import androidx.lifecycle.MutableLiveData;
import com.community.pocket.data.main.forum.ForumNewRequest;
import com.community.pocket.ui.main.ui.forum.FormLoad;
import com.community.pocket.ui.main.ui.share.BaseViewModel;
/**
* 最新帖子
*/
public class ForumNewViewModel extends BaseViewModel<ForumNewRequest> {
public class ForumNewViewModel extends BaseViewModel<ForumNewRequest> implements FormLoad {
//最新帖子请求状态
private MutableLiveData<ForumNewResponse> forumNewResponse = new MutableLiveData<>();
@ -17,7 +18,8 @@ public class ForumNewViewModel extends BaseViewModel<ForumNewRequest> {
return forumNewResponse;
}
void loadForumNew(int page, String title) {
@Override
public void loadForumNew(Long page, String title) {
getRequest().loadForumNew(forumNewResponse, page, title);
}

@ -10,7 +10,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.Observer;
import com.community.pocket.R;
import com.community.pocket.ui.BaseFragment;
@ -58,7 +57,7 @@ abstract class ForumPostContent extends BaseFragment {
//初始化父级布局组件
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void initParentView() {
ForumPostFragment forumPostFragment = getParentFragment(2);
ForumPostFragment forumPostFragment = getParentFragment(ForumPostFragment.class);
View parentView = Objects.requireNonNull(Objects.requireNonNull(forumPostFragment).getView());
postTitle = parentView.findViewById(R.id.post_title);
postButton = parentView.findViewById(R.id.post_button);
@ -67,20 +66,16 @@ abstract class ForumPostContent extends BaseFragment {
//监听发帖状态
void sendPost(ForumPostViewModel viewModel) {
viewModel.getForumPostResponse().observe(getViewLifecycleOwner(), new Observer<ForumPostResponse>() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onChanged(ForumPostResponse forumPostResponse) {
if (forumPostResponse == null) {
return;
}
forumPostResponse.toast(getContext());
if (forumPostResponse.getResult() == Response.Result.OK) {
ForumFragment forumFragment = getParentFragment(4);
Button button = Objects.requireNonNull(forumFragment.getView()).findViewById(R.id.forum_new);
forumFragment._new(button);
}
viewModel.getForumPostResponse().observe(getViewLifecycleOwner(), forumPostResponse -> {
if (forumPostResponse == null) {
return;
}
forumPostResponse.toast(getContext());
if (forumPostResponse.getResult() == Response.Result.OK) {
ForumFragment forumFragment = getParentFragment(ForumFragment.class);
Button button = Objects.requireNonNull(forumFragment.getView()).findViewById(R.id.forum_new);
forumFragment._new(button);
}
});
}

@ -19,7 +19,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.community.pocket.R;
@ -99,63 +98,54 @@ public class VisitorAppointmentFragment extends BaseFragment {
myAutoCompleteTextView = new MyAutoCompleteTextView(appointment, appointmentViewModel);
//监听访客预约表单校验状态
appointmentViewModel.getVisitorFormState().observe(getViewLifecycleOwner(), new Observer<VisitorFormState>() {
@Override
public void onChanged(VisitorFormState visitorFormState) {
if (visitorFormState == null) {
return;
}
submit.setEnabled(visitorFormState.isDataValid());
if (visitorFormState.getAppointmentError() != null) {
appointment.setError(getString(visitorFormState.getAppointmentError(), PropertiesUtil.getIntValue("username.length")));
}
appointmentViewModel.getVisitorFormState().observe(getViewLifecycleOwner(), visitorFormState -> {
if (visitorFormState == null) {
return;
}
submit.setEnabled(visitorFormState.isDataValid());
if (visitorFormState.getAppointmentError() != null) {
appointment.setError(getString(visitorFormState.getAppointmentError(), PropertiesUtil.getIntValue("username.length")));
}
if (visitorFormState.getDateError() != null) {
if (visitorFormState.getDateError() == R.string.visitor_invalid_date) {
chooseDate.setError(getString(visitorFormState.getDateError(), today));
} else {
chooseDate.setError(getString(visitorFormState.getDateError()));
}
if (visitorFormState.getDateError() != null) {
if (visitorFormState.getDateError() == R.string.visitor_invalid_date) {
chooseDate.setError(getString(visitorFormState.getDateError(), today));
} else {
chooseDate.setError(getString(visitorFormState.getDateError()));
}
}
if (visitorFormState.getNotesError() != null) {
notes.setError(getString(visitorFormState.getNotesError()));
}
if (visitorFormState.getNotesError() != null) {
notes.setError(getString(visitorFormState.getNotesError()));
}
});
//监听预约请求结果
appointmentViewModel.getVisitorResponse().observe(getViewLifecycleOwner(), new Observer<VisitorResponse>() {
@Override
public void onChanged(VisitorResponse visitorResponse) {
if (visitorResponse == null) {
return;
}
appointmentViewModel.getVisitorResponse().observe(getViewLifecycleOwner(), visitorResponse -> {
if (visitorResponse == null) {
return;
}
visitorResponse.toast(getContext());
visitorResponse.toast(getContext());
if (visitorResponse.getResult() == Response.Result.OK) {
VisitorFragment visitorFragment = getParentFragment(2);
Button button = Objects.requireNonNull(visitorFragment.getView()).findViewById(R.id.visitor_reservation);
visitorFragment.reservation(button);
}
if (visitorResponse.getResult() == Response.Result.OK) {
VisitorFragment visitorFragment = getParentFragment(VisitorFragment.class);
Button button = Objects.requireNonNull(visitorFragment.getView()).findViewById(R.id.visitor_reservation);
visitorFragment.reservation(button);
}
});
//检索预约人请求结果
appointmentViewModel.getSearchPeopleReq().observe(getViewLifecycleOwner(), new Observer<VisitorPeopleResponse>() {
@Override
public void onChanged(VisitorPeopleResponse visitorResponse) {
if (visitorResponse == null) {
return;
}
appointmentViewModel.getSearchPeopleReq().observe(getViewLifecycleOwner(), visitorResponse -> {
if (visitorResponse == null) {
return;
}
visitorResponse.toast(getContext());
visitorResponse.toast(getContext());
if (visitorResponse.getResult() == Response.Result.OK) {
if (!visitorResponse.getVisitorPeopleList().isEmpty()) {
initSearch(visitorResponse.getVisitorPeopleList());
}
if (visitorResponse.getResult() == Response.Result.OK) {
if (!visitorResponse.getVisitorPeopleList().isEmpty()) {
initSearch(visitorResponse.getVisitorPeopleList());
}
}
});

@ -67,7 +67,6 @@
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/size_100"
android:background="@color/colorAccent"
app:defaultNavHost="true"
app:navGraph="@navigation/forum_navigation" />

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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"
@ -7,78 +7,76 @@
tools:context=".ui.main.ui.forum.hot.ForumHotFragment">
<androidx.core.widget.NestedScrollView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UselessParent">
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/active_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/active_user"
android:layout_width="match_parent"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
<TextView
android:id="@+id/active_user_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/active_user"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/active_user_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/active_user"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/hot_topic"
android:layout_width="match_parent"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/hot_topic"
android:layout_width="match_parent"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
<TextView
android:id="@+id/hot_topic_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/hot_topic"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/hot_topic_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/hot_topic"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/hot_events"
android:layout_width="match_parent"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/hot_events"
android:layout_width="match_parent"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
<TextView
android:id="@+id/hot_events_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/hot_events"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/hot_events_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/hot_events"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,25 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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.my.ForumMyFragment">
<androidx.core.widget.NestedScrollView
<androidx.appcompat.widget.SearchView
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/post_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.SearchView
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
<LinearLayout
android:id="@+id/post_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/search" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,25 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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.news.ForumNewFragment">
<androidx.core.widget.NestedScrollView
<androidx.appcompat.widget.SearchView
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/post_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.SearchView
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="37dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
<LinearLayout
android:id="@+id/post_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/search" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,57 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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.ForumPostFragment">
<androidx.core.widget.NestedScrollView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
<EditText
android:id="@+id/post_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/post_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/prompt_title"
android:importantForAutofill="no"
android:inputType="none|text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/post_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/post_type_list"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/post_title" />
android:ems="10"
android:hint="@string/prompt_title"
android:importantForAutofill="no"
android:inputType="none|text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/post_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/post_type_list"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/post_title" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/post_type_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_8"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_forum_post_type" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/post_type_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_8"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_forum_post_type" />
<Button
android:id="@+id/post_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/forum_post" />
<Button
android:id="@+id/post_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/forum_post" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,153 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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.visitor.appointment.VisitorAppointmentFragment">
<androidx.core.widget.NestedScrollView
<AutoCompleteTextView
android:id="@+id/appointment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:gravity="center"
android:hint="@string/prompt_appointment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/button_group_layout" />
<TextView
android:id="@+id/tip"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appointment" />
<EditText
android:id="@+id/chooseDate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ems="10"
android:gravity="center"
android:hint="@string/prompt_choose_date"
android:importantForAutofill="no"
android:inputType="date"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tip" />
<LinearLayout
android:id="@+id/choose_time_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chooseDate">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/prompt_choose_time" />
<LinearLayout
<Spinner
android:id="@+id/choose_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_weight="1" />
</LinearLayout>
<EditText
android:id="@+id/notes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:hint="@string/prompt_input_notes"
android:importantForAutofill="no"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/choose_time_layout" />
<LinearLayout
android:id="@+id/button_group_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/visitor_is_people"
android:textSize="18sp" />
<RadioGroup
android:id="@+id/button_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<RadioButton
android:id="@+id/is_outpeople"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/size_8"
android:checked="true"
android:text="@string/visitor_is_outpeole" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
<RadioButton
android:id="@+id/not_outpeolle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<AutoCompleteTextView
android:id="@+id/appointment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:gravity="center"
android:hint="@string/prompt_appointment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/button_group_layout" />
<TextView
android:id="@+id/tip"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/appointment" />
<EditText
android:id="@+id/chooseDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ems="10"
android:gravity="center"
android:hint="@string/prompt_choose_date"
android:importantForAutofill="no"
android:inputType="date"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tip" />
<LinearLayout
android:id="@+id/choose_time_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chooseDate">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/prompt_choose_time" />
<Spinner
android:id="@+id/choose_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<EditText
android:id="@+id/notes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:hint="@string/prompt_input_notes"
android:importantForAutofill="no"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/choose_time_layout" />
<LinearLayout
android:id="@+id/button_group_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/visitor_is_people"
android:textSize="18sp" />
<RadioGroup
android:id="@+id/button_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<RadioButton
android:id="@+id/is_outpeople"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/size_8"
android:checked="true"
android:text="@string/visitor_is_outpeole" />
<RadioButton
android:id="@+id/not_outpeolle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/visitor_not_outpeole" />
</RadioGroup>
</LinearLayout>
<Button
android:id="@+id/submit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:enabled="false"
android:text="@string/submit_appointment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/notes" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
android:text="@string/visitor_not_outpeole" />
</RadioGroup>
</LinearLayout>
<Button
android:id="@+id/submit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:enabled="false"
android:text="@string/submit_appointment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/notes" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -227,4 +227,5 @@
<string name="server_address_error_2">服务端地址的冒号句号应该是半角符号,\":\"、\".\",而不是全角符号\":\"、\"。\"</string>
<string name="server_address_error_3">服务端地址应该以http开头</string>
<string name="server_address_error_4">恭喜你发现了新的错误,请联系管理员解决问题</string>
<string name="load_more_forum_ok">load more forum OK</string>
</resources>

@ -227,4 +227,5 @@
<string name="server_address_error_2">服务端地址的冒号句号应该是半角符号,\":\"、\".\",而不是全角符号\":\"、\"。\"</string>
<string name="server_address_error_3">服务端地址应该以http开头</string>
<string name="server_address_error_4">恭喜你发现了新的错误,请联系管理员解决问题</string>
<string name="load_more_forum_ok">成功加载更多帖子</string>
</resources>

@ -228,6 +228,7 @@
<string name="server_address_error_2">服务端地址的冒号句号应该是半角符号,\":\"、\".\",而不是全角符号\":\"、\"。\"</string>
<string name="server_address_error_3">服务端地址应该以http开头</string>
<string name="server_address_error_4">恭喜你发现了新的错误,请联系管理员解决问题</string>
<string name="load_more_forum_ok">load more forum OK</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

Loading…
Cancel
Save