update 排行榜 筛选 搜索
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.shayu.onetoone.widget.flexboxradiogroup.FlexBoxRadioGroup;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_HOME_SCREEN)
|
||||
public class HomeScreenActivity extends AbsOTOActivity {
|
||||
EditText etSearch;
|
||||
TextView tvSearch;
|
||||
LinearLayout ageLayout;
|
||||
LinearLayout sexLayout;
|
||||
LinearLayout authLayout;
|
||||
FlexBoxRadioGroup ageRadioGroup;
|
||||
FlexBoxRadioGroup sexRadioGroup;
|
||||
FlexBoxRadioGroup authRadioGroup;
|
||||
Button apply;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_screen;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
etSearch = findViewById(R.id.edit);
|
||||
tvSearch = findViewById(R.id.search);
|
||||
ageLayout = findViewById(R.id.age_layout);
|
||||
sexLayout = findViewById(R.id.sex_layout);
|
||||
authLayout = findViewById(R.id.auth_layout);
|
||||
ageRadioGroup = findViewById(R.id.age_radio_group);
|
||||
sexRadioGroup = findViewById(R.id.sex_radio_group);
|
||||
authRadioGroup = findViewById(R.id.auth_radio_group);
|
||||
apply = findViewById(R.id.apply);
|
||||
|
||||
|
||||
apply.setOnClickListener(v -> {
|
||||
String age = getRadioButtonValue(ageRadioGroup);
|
||||
String sex = getRadioButton(sexRadioGroup).getTag().toString();
|
||||
String auth = getRadioButtonValue(authRadioGroup);
|
||||
if (isRadioButtonEmpty(ageRadioGroup)) {
|
||||
age = "";
|
||||
}
|
||||
if (isRadioButtonEmpty(authRadioGroup)) {
|
||||
auth = "";
|
||||
}
|
||||
if (sex.equals("all")) {
|
||||
sex = "";
|
||||
}
|
||||
if (StringUtil.isEmptyAll(age, auth, sex)) {
|
||||
RouteManager.forwardMainActivity();
|
||||
} else {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("age", age);
|
||||
bundle.putString("sex", sex);
|
||||
bundle.putString("auth", auth);
|
||||
RouteManager.forwardMainActivityForScreen(bundle);
|
||||
}
|
||||
});
|
||||
tvSearch.setOnClickListener(v -> {
|
||||
String search = etSearch.getText().toString();
|
||||
if(StringUtil.isEmpty(search)){
|
||||
ToastUtil.show("空的不能搜索");
|
||||
return;
|
||||
}
|
||||
Bundle bundle=new Bundle();
|
||||
bundle.putString("search",search);
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_SEARCH,bundle);
|
||||
});
|
||||
}
|
||||
|
||||
String getRadioButtonValue(FlexBoxRadioGroup group) {
|
||||
return ((RadioButton) findViewById(group.getCheckedRadioButtonId())).getText().toString();
|
||||
}
|
||||
|
||||
boolean isRadioButtonEmpty(FlexBoxRadioGroup group) {
|
||||
RadioButton button = (RadioButton) findViewById(group.getCheckedRadioButtonId());
|
||||
if (button.getTag() == null) {
|
||||
return false;
|
||||
}
|
||||
return button.getTag().toString().equals("all");
|
||||
}
|
||||
|
||||
RadioButton getRadioButton(FlexBoxRadioGroup group) {
|
||||
return findViewById(group.getCheckedRadioButtonId());
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,44 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.HomeHotListAdapter;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_HOME_SEARCH)
|
||||
public class HomeSearchActivity extends AbsOTOActivity {
|
||||
View viewEmpty;
|
||||
View refresh;
|
||||
SmartRefreshLayout swipeRefreshLayout;
|
||||
RecyclerView searchList;
|
||||
RecyclerView recommendList;
|
||||
EditText edit;
|
||||
TextView searchBtn;
|
||||
int page = 1;
|
||||
HomeRecommendListAdapter searchListAdapter;
|
||||
HomeHotListAdapter recommendListAdapter;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_search;
|
||||
@@ -15,6 +46,94 @@ public class HomeSearchActivity extends AbsOTOActivity {
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
viewEmpty = findViewById(R.id.view_empty);
|
||||
refresh = findViewById(R.id.refresh);
|
||||
swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
searchList = findViewById(R.id.searchList);
|
||||
recommendList = findViewById(R.id.recommendList);
|
||||
edit = findViewById(R.id.edit);
|
||||
searchBtn = findViewById(R.id.search);
|
||||
|
||||
searchListAdapter = new HomeRecommendListAdapter(this);
|
||||
recommendListAdapter = new HomeHotListAdapter(this);
|
||||
|
||||
swipeRefreshLayout.autoLoadMore();
|
||||
swipeRefreshLayout.setEnableRefresh(false);
|
||||
swipeRefreshLayout.setRefreshFooter(new RongRefreshHeader(this));
|
||||
swipeRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
search(edit.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
searchList.setAdapter(searchListAdapter);
|
||||
recommendList.setAdapter(recommendListAdapter);
|
||||
|
||||
|
||||
refresh.setOnClickListener(v -> refresh());
|
||||
|
||||
searchBtn.setOnClickListener(v -> search(edit.getText().toString()));
|
||||
|
||||
edit.setText(getIntent().getBundleExtra("bundle").getString("search"));
|
||||
search(edit.getText().toString());
|
||||
refresh();
|
||||
}
|
||||
|
||||
private void search(String key) {
|
||||
if (StringUtil.isEmpty(key)) {
|
||||
ToastUtil.show("不能为空");
|
||||
return;
|
||||
}
|
||||
OTONetManager.getInstance(mContext)
|
||||
.search(key,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
page + "",
|
||||
new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
if (page == 1 && data.isEmpty()) {
|
||||
searchList.setVisibility(View.GONE);
|
||||
viewEmpty.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
viewEmpty.setVisibility(View.GONE);
|
||||
searchList.setVisibility(View.VISIBLE);
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
swipeRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page == 1) {
|
||||
searchListAdapter.setList(data);
|
||||
} else {
|
||||
searchListAdapter.addLst(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
OTONetManager.getInstance(this)
|
||||
.getSearchRecommend(new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
recommendListAdapter.setList(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,13 @@ public class FriendsFragment extends BaseFragment {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_top).setOnClickListener(v ->{
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_RANK);
|
||||
findViewById(R.id.btn_top).setOnClickListener(v -> RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_RANK));
|
||||
findViewById(R.id.btn_filter).setOnClickListener(v -> RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_SCREEN));
|
||||
|
||||
});
|
||||
Bundle screen = getActivity().getIntent().getBundleExtra("screen");
|
||||
if(screen!=null){
|
||||
viewPager2.setCurrentItem(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ public class HotFragment extends BaseFragment {
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
SwipeRecyclerView recyclerView;
|
||||
HomeHotListAdapter adapter;
|
||||
private int page = 1;
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
@@ -47,24 +48,37 @@ public class HotFragment extends BaseFragment {
|
||||
onConversationListLoadMore();
|
||||
}
|
||||
});
|
||||
page = 1;
|
||||
initData();
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
page++;
|
||||
initData();
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
initData();
|
||||
refreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeHot(new HttpCallback<List<HomeItemBean>>() {
|
||||
.getHomeHot(page + "", new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
adapter.setList(data);
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
adapter.addList(data);
|
||||
} else {
|
||||
adapter.setList(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.shayu.onetoone.activity.fragments.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -9,9 +8,7 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.HomeSearchActivity;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.activity.HomepageRankingActivity;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
@@ -31,6 +28,9 @@ public class RecommendFragment extends BaseFragment {
|
||||
SwipeRecyclerView recyclerView;
|
||||
HomeRecommendListAdapter adapter;
|
||||
View top;
|
||||
private int page = 1;
|
||||
private boolean isScreen;
|
||||
Bundle screen;
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
@@ -42,8 +42,10 @@ public class RecommendFragment extends BaseFragment {
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
recyclerView.setEmptyView(itemView.findViewById(R.id.view_empty));
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
onConversationListRefresh(refreshLayout);
|
||||
}
|
||||
});
|
||||
@@ -53,13 +55,63 @@ public class RecommendFragment extends BaseFragment {
|
||||
}
|
||||
});
|
||||
top.setOnClickListener(view -> {
|
||||
// recyclerView.scrollToPosition(0);
|
||||
startActivity(new Intent(getContext(), HomeSearchActivity.class));
|
||||
recyclerView.scrollToPosition(0);
|
||||
});
|
||||
initData();
|
||||
screen = getActivity().getIntent().getBundleExtra("screen");
|
||||
if (screen != null) {
|
||||
if (!isScreen) {
|
||||
page = 1;
|
||||
}
|
||||
isScreen = true;
|
||||
screen(screen);
|
||||
mRefreshLayout.setEnableRefresh(false);
|
||||
} else {
|
||||
if (isScreen) {
|
||||
page = 1;
|
||||
}
|
||||
isScreen = false;
|
||||
initData();
|
||||
}
|
||||
}
|
||||
|
||||
private void screen(Bundle screen) {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.search("",
|
||||
screen.getString("age", ""),
|
||||
screen.getString("auth", ""),
|
||||
screen.getString("sex", ""),
|
||||
page + "",
|
||||
new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
adapter.addLst(data);
|
||||
} else {
|
||||
adapter.setList(data);
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void onConversationListLoadMore() {
|
||||
page++;
|
||||
if (isScreen) {
|
||||
screen(screen);
|
||||
} else {
|
||||
initData();
|
||||
}
|
||||
mRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@@ -69,10 +121,19 @@ public class RecommendFragment extends BaseFragment {
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeRecommend(new HttpCallback<List<HomeItemBean>>() {
|
||||
.getHomeRecommend(page + "", new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeItemBean> data) {
|
||||
adapter.setList(data);
|
||||
if (page != 1 && data.isEmpty()) {
|
||||
page--;
|
||||
mRefreshLayout.finishLoadMore();
|
||||
return;
|
||||
}
|
||||
if (page != 1) {
|
||||
adapter.addLst(data);
|
||||
} else {
|
||||
adapter.setList(data);
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
.getTargetUserInfo(Integer.parseInt(targetId), new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
public void onSuccess(UserBean data) {
|
||||
if (data.getInfo().getSage_auth() == 1) {
|
||||
if (data.getInfo().getName_auth() == 1) {
|
||||
listener.onError(0, "");
|
||||
} else {
|
||||
listener.onSuccess("");
|
||||
|
||||
Reference in New Issue
Block a user