界面优化,数据整理
This commit is contained in:
parent
19dfe093af
commit
ae9f15d963
@ -63,7 +63,7 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (type == 1 && lists.size() > 1) {
|
||||
if (position ==0) {
|
||||
if (position == 0) {
|
||||
return ANCHOR;
|
||||
} else {
|
||||
return USER;
|
||||
|
@ -4,12 +4,12 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.SearchModel;
|
||||
import com.yunbao.common.dialog.LoadingDialog;
|
||||
import com.yunbao.common.fragment.BaseFragment;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
@ -19,7 +19,6 @@ import com.yunbao.main.adapter.SearchResultsItemAdapter;
|
||||
import com.yunbao.main.utils.WordsTypeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -28,7 +27,6 @@ import java.util.List;
|
||||
public class SearchResultsItemFragment extends BaseFragment {
|
||||
private String searchKey = "";
|
||||
private int page = 1;
|
||||
private LinearLayout loading;
|
||||
private RecyclerView searchList;
|
||||
private SearchResultsItemAdapter itemAdapter;
|
||||
|
||||
@ -44,9 +42,7 @@ public class SearchResultsItemFragment extends BaseFragment {
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState, View contentView) {
|
||||
loading = contentView.findViewById(R.id.loading);
|
||||
searchList = contentView.findViewById(R.id.search_list);
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
itemAdapter = new SearchResultsItemAdapter();
|
||||
searchList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
searchList.setAdapter(itemAdapter);
|
||||
@ -64,6 +60,9 @@ public class SearchResultsItemFragment extends BaseFragment {
|
||||
* @param type 類型
|
||||
*/
|
||||
public void setSearchKey(String searchKey, int type) {
|
||||
//展示网络请求弹窗
|
||||
LoadingDialog fragment = new LoadingDialog();
|
||||
fragment.show(getChildFragmentManager(), "LoadingDialog");
|
||||
this.searchKey = searchKey;
|
||||
if (type == 1) {
|
||||
MainNetManager.get(getActivity())
|
||||
@ -73,12 +72,12 @@ public class SearchResultsItemFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onSuccess(List<List<SearchModel>> data) {
|
||||
itemAdapter.showData(data, type);
|
||||
loading.setVisibility(View.GONE);
|
||||
fragment.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
loading.setVisibility(View.GONE);
|
||||
fragment.dismiss();
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
@ -92,12 +91,12 @@ public class SearchResultsItemFragment extends BaseFragment {
|
||||
List<List<SearchModel>> listList = new ArrayList<>();
|
||||
listList.add(data);
|
||||
itemAdapter.showData(listList, type);
|
||||
loading.setVisibility(View.GONE);
|
||||
fragment.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
loading.setVisibility(View.GONE);
|
||||
fragment.dismiss();
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
@ -136,7 +135,8 @@ public class SearchResultsItemFragment extends BaseFragment {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public static SearchResultsItemFragment newInstance(String searchKey,int type){
|
||||
|
||||
public static SearchResultsItemFragment newInstance(String searchKey, int type) {
|
||||
SearchResultsItemFragment searchRecommendFragment = new SearchResultsItemFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("searchKey", searchKey);
|
||||
|
@ -2,9 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
@ -16,7 +14,10 @@
|
||||
<FrameLayout
|
||||
android:id="@+id/type_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
@ -50,6 +51,8 @@
|
||||
android:id="@+id/anchor_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:fadingEdge="none" />
|
||||
</LinearLayout>
|
@ -2,8 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
@ -16,6 +15,8 @@
|
||||
android:id="@+id/type_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginTop="20dp">
|
||||
|
||||
<LinearLayout
|
||||
@ -51,5 +52,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:fadingEdge="none" />
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user