Browse Source

[검색][New] 태그 기능 추가 - 검색 결과 없을 때 표시

hyodong.min 7 years ago
parent
commit
b36cf9cc88

+ 1 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/search/ISearchResultView.java

@@ -24,5 +24,5 @@ interface ISearchResultView extends IView {
 
   void setVisibleCategory(boolean isVisible);
 
-  void drawTags(List<TagCheckBean> tagBeans);
+  void drawTags(List<TagCheckBean> tagBeans, boolean isInteraction);
 }

+ 3 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/search/SearchResultFragment.java

@@ -121,15 +121,13 @@ public class SearchResultFragment extends FragmentBase<SearchResultPresenter> im
   }
 
   @Override
-  public void drawTags(List<TagCheckBean> tagBeans) {
+  public void drawTags(List<TagCheckBean> tagBeans, boolean isInteraction) {
     if (null == tagAdapter) {
-      tagAdapter = new SearchResultTagAdapter(tagBeans, event -> {
+      tagAdapter = new SearchResultTagAdapter(tagBeans, isInteraction, event -> {
         presenter.onEvent(event);
       });
       recyclerViewTags.setAdapter(tagAdapter);
     }
-    else {
-      tagAdapter.update(tagBeans);
-    }
   }
+
 }

+ 4 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/search/SearchResultModel.java

@@ -274,4 +274,8 @@ public class SearchResultModel extends Model {
   public String[] getSearchTags() {
     return searchTags;
   }
+
+  public boolean hasResult() {
+    return getTagResultBeans().size() > 0;
+  }
 }

+ 2 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/search/SearchResultPresenter.java

@@ -40,9 +40,9 @@ public class SearchResultPresenter extends Presenter<SearchResultModel, ISearchR
   private void render() {
     if (doubleCheckerSearch.isCompleted() == false) {
       // 처음에만 태그 그려줌
-      view.drawTags(model.getTagCheckBeans());
+      view.drawTags(model.getTagCheckBeans(), model.hasResult());
     }
-    view.setVisibleCategory(model.getTagResultBeans().size() > 0);
+    view.setVisibleCategory(model.hasResult());
     List<SearchContentsBean> list = model.getResultContentsBeans();
     view.drawResultContents(list);
   }

+ 11 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/search/SearchResultTagAdapter.java

@@ -29,17 +29,25 @@ public class SearchResultTagAdapter extends RecyclerView.Adapter<SearchResultTag
 
   protected List<TagCheckBean> tagCheckBeans;
   protected IEventListener listener;
+  protected boolean isInteraction;
 
-  public SearchResultTagAdapter(List<TagCheckBean> tagBeans, IEventListener listener) {
+  public SearchResultTagAdapter(List<TagCheckBean> tagBeans, boolean isInteraction, IEventListener listener) {
     this.tagCheckBeans = tagBeans;
+    this.isInteraction = isInteraction;
     this.listener = listener;
   }
 
   @NonNull
   @Override
   public SearchResultTagHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
-    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_square_check_box, parent, false);
-    return new SearchResultTagHolder(view);
+    if(isInteraction) {
+      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_square_check_box, parent, false);
+      return new SearchResultTagHolder(view);
+    }
+    else {
+      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_nothing_check_box, parent, false);
+      return new SearchResultTagNothingHolder(view);
+    }
   }
 
   @Override

+ 31 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/search/SearchResultTagNothingHolder.java

@@ -0,0 +1,31 @@
+/*
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
+ */
+package kr.co.zumo.app.lifeplus.view.screen.search;
+
+import android.view.View;
+
+import kr.co.zumo.app.lifeplus.view.IEventListener;
+
+/**
+ * SearchResultTagNothingHolder
+ * <pre>
+ * </pre>
+ *
+ * @author 민효동
+ * @version 1.0
+ * @history 민효동   [2019. 1. 14.]   [최초 작성]
+ * @since 2019. 1. 14.
+ */
+public class SearchResultTagNothingHolder extends SearchResultTagHolder {
+
+  public SearchResultTagNothingHolder(View itemView) {
+    super(itemView);
+  }
+
+  public void bind(String tag, boolean isChecked, IEventListener listener) {
+    if (null != tag) {
+      checkTag.setText(tag);
+    }
+  }
+}

+ 28 - 0
app/src/main/res/layout/search_nothing_check_box.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.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="wrap_content"
+  android:layout_height="wrap_content">
+
+  <CheckBox
+    android:id="@+id/check_box"
+    android:layout_width="wrap_content"
+    android:layout_height="26dp"
+    android:background="@null"
+    android:button="@android:color/transparent"
+    android:lineSpacingExtra="4sp"
+    android:saveEnabled="false"
+    android:textAlignment="center"
+    android:textColor="@color/CC5C5C5"
+    android:textSize="16dp"
+    app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintEnd_toEndOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    app:layout_constraintTop_toTopOf="parent"
+    tools:checked="true"
+    tools:text="#산책부터목욕까지"
+    />
+
+</android.support.constraint.ConstraintLayout>