滚动问题修复
This commit is contained in:
parent
c15a420307
commit
19dfe093af
@ -6,18 +6,18 @@ import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.manager.SearchHistoryRecordManager;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.fragment.SearchRecommendFragment;
|
||||
import com.yunbao.main.fragment.SearchResultsFragment;
|
||||
import com.yunbao.main.fragment.SearchResultsItemFragment;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.utils.WordsTypeUtil;
|
||||
|
||||
|
||||
/**
|
||||
@ -48,15 +48,37 @@ public class SearchActivity extends AbsActivity {
|
||||
transaction.commit();
|
||||
mEditText = findViewById(R.id.edit);
|
||||
mEditText.addTextChangedListener(textWatcher);
|
||||
//退出检索页面保存搜索记录
|
||||
findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//检索关键字
|
||||
String searchKey = mEditText.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(searchKey)) {
|
||||
//保存检索历史记录
|
||||
SearchHistoryRecordManager.get(mContext).addHistoryRecord(WordsTypeUtil.changeSimplified(searchKey), WordsTypeUtil.changeTraditional(searchKey));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MainHttpUtil.cancel(MainHttpConsts.SEARCH);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//检索关键字
|
||||
String searchKey = mEditText.getText().toString().trim();
|
||||
if (!TextUtils.isEmpty(searchKey)) {
|
||||
//保存检索历史记录
|
||||
SearchHistoryRecordManager.get(mContext).addHistoryRecord(WordsTypeUtil.changeSimplified(searchKey), WordsTypeUtil.changeTraditional(searchKey));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
//輸入框監聽函數
|
||||
TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
@ -93,4 +115,5 @@ public class SearchActivity extends AbsActivity {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ public class SearchRecommendAdapter extends RecyclerView.Adapter {
|
||||
if (recommendModels.size() == 1 && recommendModels.get(position).getHistoryRecordMap().size() == 0){
|
||||
return BODY;
|
||||
}else {
|
||||
if (position == (recommendModels.size() - 1) ) {
|
||||
return HEAD;
|
||||
if (position == 0 ) {
|
||||
return HEAD;
|
||||
} else {
|
||||
return BODY;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (type == 1 && lists.size() > 1) {
|
||||
if (position == (lists.size() - 1)) {
|
||||
if (position ==0) {
|
||||
return ANCHOR;
|
||||
} else {
|
||||
return USER;
|
||||
|
@ -49,7 +49,7 @@ public class SearchRecommendFragment extends BaseFragment {
|
||||
searchRecommend = contentView.findViewById(R.id.search_recommend_list);
|
||||
|
||||
adapter = new SearchRecommendAdapter(getActivity());
|
||||
searchRecommend.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true));
|
||||
searchRecommend.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
searchRecommend.setAdapter(adapter);
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ public class SearchRecommendFragment extends BaseFragment {
|
||||
SearchRecommendModel model = new SearchRecommendModel();
|
||||
searchRecommendModels.add(model.setHistoryRecordMap(historyRecordMap));
|
||||
}
|
||||
searchRecommendModels.add(0, new SearchRecommendModel().setList(data.getList()));
|
||||
searchRecommendModels.add( new SearchRecommendModel().setList(data.getList()));
|
||||
adapter.addData(searchRecommendModels);
|
||||
|
||||
}
|
||||
@ -86,26 +86,7 @@ public class SearchRecommendFragment extends BaseFragment {
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onSearchRecommendEvent(SearchRecommendEvent event) {
|
||||
//展示网络请求弹窗
|
||||
LoadingDialog fragment = new LoadingDialog();
|
||||
fragment.show(getChildFragmentManager(), "LoadingDialog");
|
||||
MainNetManager.get(getActivity())
|
||||
.anchorRecommend("6", new HttpCallback<AnchorRecommendModel>() {
|
||||
@Override
|
||||
public void onSuccess(AnchorRecommendModel data) {
|
||||
fragment.dismiss();
|
||||
//组装搜索历史数据
|
||||
List<SearchRecommendModel> searchRecommendModels = new ArrayList<>();
|
||||
searchRecommendModels.add(0, new SearchRecommendModel().setList(data.getList()));
|
||||
adapter.addData(searchRecommendModels);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
fragment.dismiss();
|
||||
}
|
||||
});
|
||||
loadData();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class SearchResultsItemFragment extends BaseFragment {
|
||||
searchList = contentView.findViewById(R.id.search_list);
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
itemAdapter = new SearchResultsItemAdapter();
|
||||
searchList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true));
|
||||
searchList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
searchList.setAdapter(itemAdapter);
|
||||
}
|
||||
|
||||
@ -72,7 +72,6 @@ public class SearchResultsItemFragment extends BaseFragment {
|
||||
type, page, new HttpCallback<List<List<SearchModel>>>() {
|
||||
@Override
|
||||
public void onSuccess(List<List<SearchModel>> data) {
|
||||
Collections.reverse(data);
|
||||
itemAdapter.showData(data, type);
|
||||
loading.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class FlowLayout extends ViewGroup {
|
||||
|
||||
if (heightMode == MeasureSpec.EXACTLY) {
|
||||
measuredHeight = heightSize;
|
||||
} else if (heightMode == MeasureSpec.AT_MOST) {
|
||||
} else {
|
||||
measuredHeight = compute.get("allChildHeight");
|
||||
}
|
||||
//设置flow的宽高
|
||||
|
@ -6,6 +6,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -33,6 +34,7 @@ public class SearchRecommendHeardViewHolder extends RecyclerView.ViewHolder {
|
||||
* 展示搜索歷史
|
||||
*/
|
||||
public void setHistory(Map<String, String> historyMap) {
|
||||
searchHistory.removeAllViews();
|
||||
LinearLayout.LayoutParams layoutParams =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.setMargins(17, 10, 0, 10);
|
||||
|
@ -56,7 +56,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:onClick="backClick"
|
||||
android:text="@string/cancel"
|
||||
android:textColor="#FF000000"
|
||||
android:textSize="16sp" />
|
||||
|
@ -7,6 +7,12 @@
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2px"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/type_title"
|
||||
android:layout_width="match_parent"
|
||||
@ -44,5 +50,6 @@
|
||||
android:id="@+id/anchor_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
android:layout_marginTop="10dp"
|
||||
android:fadingEdge="none" />
|
||||
</LinearLayout>
|
@ -4,9 +4,15 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2px"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/search_recommend_list"
|
||||
android:layout_width="match_parent"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdge="none" />
|
||||
</LinearLayout>
|
@ -32,10 +32,17 @@
|
||||
android:textSize="16sp" />
|
||||
</FrameLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2px"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/live_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdge="none"
|
||||
android:layout_marginTop="24dp" />
|
||||
|
||||
</LinearLayout>
|
@ -5,6 +5,12 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="11dp">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2px"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
@ -13,8 +19,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_history"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="@string/search_history"
|
||||
android:textColor="#FF000000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
@ -29,7 +35,7 @@
|
||||
<com.yunbao.main.views.FlowLayout
|
||||
android:id="@+id/search_history"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:padding="5dp" />
|
||||
|
@ -5,14 +5,20 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2px"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="100dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.wang.avi.AVLoadingIndicatorView
|
||||
@ -34,5 +40,6 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/search_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdge="none" />
|
||||
</FrameLayout>
|
@ -6,6 +6,12 @@
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2px"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/type_title"
|
||||
android:layout_width="match_parent"
|
||||
@ -44,5 +50,6 @@
|
||||
android:id="@+id/anchor_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
android:layout_marginTop="10dp"
|
||||
android:fadingEdge="none" />
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user