From ae9f15d96372ad535eb5ed54f97d245de8ccd1bd Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Sat, 6 Aug 2022 17:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/SearchResultsItemAdapter.java | 2 +- .../fragment/SearchResultsItemFragment.java | 20 +++++++++---------- ...view_anchor_search_results_item_holder.xml | 11 ++++++---- .../view_user_search_results_item_holder.xml | 7 +++++-- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/main/src/main/java/com/yunbao/main/adapter/SearchResultsItemAdapter.java b/main/src/main/java/com/yunbao/main/adapter/SearchResultsItemAdapter.java index cfecad618..4da41c1eb 100644 --- a/main/src/main/java/com/yunbao/main/adapter/SearchResultsItemAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/SearchResultsItemAdapter.java @@ -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; diff --git a/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java b/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java index 34adaeb27..82bac2af4 100644 --- a/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java @@ -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> 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> 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); diff --git a/main/src/main/res/layout/view_anchor_search_results_item_holder.xml b/main/src/main/res/layout/view_anchor_search_results_item_holder.xml index 1c8bebec6..22878c096 100644 --- a/main/src/main/res/layout/view_anchor_search_results_item_holder.xml +++ b/main/src/main/res/layout/view_anchor_search_results_item_holder.xml @@ -2,9 +2,7 @@ + android:layout_height="wrap_content" + android:layout_marginLeft="20dp" + android:layout_marginTop="20dp" + android:layout_marginRight="20dp"> \ No newline at end of file diff --git a/main/src/main/res/layout/view_user_search_results_item_holder.xml b/main/src/main/res/layout/view_user_search_results_item_holder.xml index 12b3837d9..bc464c291 100644 --- a/main/src/main/res/layout/view_user_search_results_item_holder.xml +++ b/main/src/main/res/layout/view_user_search_results_item_holder.xml @@ -2,8 +2,7 @@ \ No newline at end of file