فهرست منبع

Merge branch 'develop' of https://github.com/swict/LifePlusAndroid into develop

hyodong.min 7 سال پیش
والد
کامیت
ae5d2e6ace

+ 10 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/bean/api/FAQBean.java

@@ -44,6 +44,8 @@ public class FAQBean extends JsonBeanBase {
   @SerializedName("reg_dt")
   private String date;  // "yyyy-mm-dd"
 
+  private boolean isExpanded;
+
   public FAQBean(int id, String category, String title, String contents, String date) {
     this.id = id;
     this.category = category;
@@ -91,4 +93,12 @@ public class FAQBean extends JsonBeanBase {
   public void setDate(String date) {
     this.date = date;
   }
+
+  public boolean isExpanded() {
+    return isExpanded;
+  }
+
+  public void setExpanded(boolean expanded) {
+    isExpanded = expanded;
+  }
 }

+ 36 - 113
app/src/main/java/kr/co/zumo/app/lifeplus/view/fragment/faq/FAQExpandableListViewAdapter.java

@@ -1,18 +1,18 @@
 package kr.co.zumo.app.lifeplus.view.fragment.faq;
 
-import android.content.Context;
 import android.support.annotation.NonNull;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import kr.co.zumo.app.R;
+import kr.co.zumo.app.lifeplus.bean.api.FAQBean;
 
 /**
  * FaqExpandableListViewAdapter
@@ -26,142 +26,65 @@ import kr.co.zumo.app.R;
  */
 public class FAQExpandableListViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
 
-  public static final int QUESTION = 1;
-  public static final int ANSWER = 2;
-  private List<Item> faqList;
-  private LayoutInflater inflater;
+  private List<FAQBean> data;
+  private TextView textViewCategory;
+  private TextView textViewQuestion;
+  private ImageView buttonArrow;
+  private LinearLayout layoutAnswer;
+  private TextView textViewAnswer;
 
-
-  public FAQExpandableListViewAdapter(List<Item> faqList) {
-    this.faqList = faqList;
+  public FAQExpandableListViewAdapter(List<FAQBean> data) {
+    this.data = data;
   }
 
   @NonNull
   @Override
   public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
-    View view = null;
-    Context context = parent.getContext();
-
-    float dp = context.getResources().getDisplayMetrics().density;
-    int subItemPaddingLeft = (int) (18 * dp);
-    int subItemPaddingTopAndBottom = (int) (5 * dp);
-
-    switch (viewType) {
-      //카테고리 들어오면 question layout 부터 세팅
-      case QUESTION:
-        inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-        view = inflater.inflate(R.layout.faq_question_list, parent, false);
-        FAQExpandableListViewViewHolder questionViewHolder = new FAQExpandableListViewViewHolder(view);
-        return questionViewHolder;
-      case ANSWER:
-        TextView textViewAnswer = new TextView(context);
-        textViewAnswer.setPadding(subItemPaddingLeft, subItemPaddingTopAndBottom, 0, subItemPaddingTopAndBottom);
-        textViewAnswer.setTextColor(0x88000000);
-        textViewAnswer.setLayoutParams(
-          new ViewGroup.LayoutParams(
-            ViewGroup.LayoutParams.MATCH_PARENT,
-            ViewGroup.LayoutParams.WRAP_CONTENT));
-        return new RecyclerView.ViewHolder(textViewAnswer) {};
-      default:
-        break;
-
-    }
-    return null;
+    View view = LayoutInflater
+      .from(parent.getContext())
+      .inflate(R.layout.faq_question_list, parent, false);
+    return new FAQExpandableViewHolder(view);
   }
 
   @Override
   public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
-    final Item item = faqList.get(position);
-    switch (item.type) {
-      case QUESTION:
-        final FAQExpandableListViewViewHolder viewHolder = (FAQExpandableListViewViewHolder) holder;
-        viewHolder.refferalItem = item;
-        viewHolder.textViewCategory.setText(item.category);
-        viewHolder.textViewQuestion.setText(item.contents);
-        if (item.invisibleChildren == null) {
-          viewHolder.buttonOpenArrow.setImageResource(R.drawable.icon_openarrow);
-        }
-        else {
-          viewHolder.buttonOpenArrow.setImageResource(R.drawable.icon_closearrow);
-        }
-        viewHolder.buttonOpenArrow.setOnClickListener(new View.OnClickListener() {
-          @Override
-          public void onClick(View view) {
-            if (item.invisibleChildren == null) {
-              item.invisibleChildren = new ArrayList<Item>();
-              int count = 0;
-              int pos = faqList.indexOf(viewHolder.refferalItem);
-              while (faqList.size() > pos + 1 && faqList.get(pos + 1).type == ANSWER) {
-                item.invisibleChildren.add(faqList.remove(pos + 1));
-                count++;
-              }
-              notifyItemRangeRemoved(pos + 1, count);
-              viewHolder.buttonOpenArrow.setImageResource(R.drawable.icon_openarrow);
-            }
-            else {
-              int pos = faqList.indexOf(viewHolder.refferalItem);
-              int index = pos + 1;
-              for (Item i : item.invisibleChildren) {
-                faqList.add(index, i);
-                index++;
-              }
-              notifyItemRangeInserted(pos + 1, index - pos - 1);
-              viewHolder.buttonOpenArrow.setImageResource(R.drawable.icon_closearrow);
-              item.invisibleChildren = null;
-
-            }
-          }
-        });
-        break;
-      case ANSWER:
-        TextView textViewAnswer = (TextView) holder.itemView;
-        textViewAnswer.setText(faqList.get(position).contents);
-        break;
-      default:
-        break;
-    }
-  }
+    FAQBean bean = data.get(position);
+    ((FAQExpandableViewHolder)holder).bind(bean);
+    ((FAQExpandableViewHolder)holder).itemView.setOnClickListener(new View.OnClickListener() {
+      @Override
+      public void onClick(View view) {
+        boolean isExpand = bean.isExpanded();
+        bean.setExpanded(!isExpand);
+        notifyItemChanged(position);
+      }
+    });
 
 
-  @Override
-  public int getItemViewType(int position) {
-    return faqList.get(position).type;
   }
 
   @Override
   public int getItemCount() {
-    return faqList.size();
+    return data.size();
   }
 
-  private static class FAQExpandableListViewViewHolder extends RecyclerView.ViewHolder {
-    public TextView textViewCategory;
-    public TextView textViewQuestion;
-    public TextView textViewAnswer;
-    public ImageView buttonOpenArrow;
-    public Item refferalItem;
+  private class FAQExpandableViewHolder extends RecyclerView.ViewHolder {
+
 
-    public FAQExpandableListViewViewHolder(View itemView) {
+    public FAQExpandableViewHolder(View itemView) {
       super(itemView);
       textViewCategory = itemView.findViewById(R.id.faq_category);
       textViewQuestion = itemView.findViewById(R.id.faq_question);
-      textViewAnswer = itemView.findViewById(R.id.faq_answer);
-      buttonOpenArrow = itemView.findViewById(R.id.button_open_arrow);
-    }
-  }
-
-  public static class Item {
-    public int type;
-    public String category;
-    public String contents;
-    public List<Item> invisibleChildren;
+      buttonArrow =itemView.findViewById(R.id.button_open_arrow);
+      layoutAnswer = itemView.findViewById(R.id.layout_answer);
+      textViewAnswer =itemView.findViewById(R.id.faq_answer);
 
-    public Item() {
     }
 
-    public Item(int type, String category, String contents) {
-      this.type = type;
-      this.category = category;
-      this.contents = contents;
+    private void bind(FAQBean faqBean) {
+      boolean expanded = faqBean.isExpanded();
+      layoutAnswer.setVisibility(expanded ? View.VISIBLE : View.GONE);
+      buttonArrow.setImageResource(expanded ? R.drawable.icon_closearrow : R.drawable.icon_openarrow);
+      textViewAnswer.setText(faqBean.getContents());
     }
   }
 }

+ 16 - 10
app/src/main/java/kr/co/zumo/app/lifeplus/view/fragment/faq/FAQFragment.java

@@ -1,5 +1,6 @@
 package kr.co.zumo.app.lifeplus.view.fragment.faq;
 
+import android.graphics.Rect;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
@@ -14,6 +15,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import kr.co.zumo.app.R;
+import kr.co.zumo.app.lifeplus.bean.api.FAQBean;
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 
 /**
  * FaqFragment
@@ -40,18 +43,21 @@ public class FAQFragment extends Fragment {
 
     expandableListViewFaq = (RecyclerView) view.findViewById(R.id.expandable_list_view_faq);
     expandableListViewFaq.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL ,false));
-    List<FAQExpandableListViewAdapter.Item> data = new ArrayList<>();
-
-
-    data.add(new FAQExpandableListViewAdapter.Item(FAQExpandableListViewAdapter.QUESTION, "회원","비밀번호는 어떻게 변경하나요?"));
-    data.add(new FAQExpandableListViewAdapter.Item(FAQExpandableListViewAdapter.ANSWER, "회원","답변1"));
-    data.add(new FAQExpandableListViewAdapter.Item(FAQExpandableListViewAdapter.QUESTION, "회원","비밀번호는 어떻게 변경하나요?"));
-    data.add(new FAQExpandableListViewAdapter.Item(FAQExpandableListViewAdapter.ANSWER, "회원","답변1"));
-    data.add(new FAQExpandableListViewAdapter.Item(FAQExpandableListViewAdapter.QUESTION, "회원","비밀번호는 어떻게 변경하나요?"));
-    data.add(new FAQExpandableListViewAdapter.Item(FAQExpandableListViewAdapter.ANSWER, "회원","답변1"));
-
+    List<FAQBean> data = new ArrayList<>();
+    data.add(new FAQBean(1, "카테고리", "타이틀", "콘텐츠", "날짜"));
+    data.add(new FAQBean(1, "카테고리", "타이틀", "콘텐츠", "날짜"));
+    data.add(new FAQBean(1, "카테고리", "타이틀", "콘텐츠", "날짜"));
+    data.add(new FAQBean(1, "카테고리", "타이틀", "콘텐츠", "날짜"));
+    data.add(new FAQBean(1, "카테고리", "타이틀", "콘텐츠", "날짜"));
     FAQExpandableListViewAdapter adapter = new FAQExpandableListViewAdapter(data);
     expandableListViewFaq.setAdapter(adapter);
+    expandableListViewFaq.addItemDecoration(new RecyclerView.ItemDecoration() {
+      @Override
+      public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
+        super.getItemOffsets(outRect, view, parent, state);
+        outRect.top = ResourceUtil.dpToPx(12);
+      }
+    });
 
     return view;
   }

+ 29 - 15
app/src/main/res/layout/activity_faq.xml

@@ -10,22 +10,36 @@
   tools:context="kr.co.zumo.app.lifeplus.activity.TutorialActivity">
 
   <android.support.design.widget.TabLayout
-  android:id="@+id/faq_tab_layout"
-  android:layout_width="match_parent"
-  android:layout_marginRight="25dp"
-  android:layout_marginLeft="25dp"
-  android:layout_height="55dp"
-  app:tabGravity="center"/>
+    android:id="@+id/faq_tab_layout"
+    android:layout_width="match_parent"
+    android:layout_height="55dp"
+    android:layout_marginLeft="25dp"
+    android:layout_marginRight="25dp"
+    app:tabGravity="center"/>
 
-  <android.support.v4.view.ViewPager
-  android:id="@+id/faq_view_pager"
-  android:layout_width="match_parent"
-  android:layout_height="match_parent"/>
-  <LinearLayout
-    android:id="@+id/faq_container"
+  <RelativeLayout
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical"
-    />
+    android:layout_height="match_parent">
+
+    <android.support.v4.view.ViewPager
+      android:id="@+id/faq_view_pager"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"/>
+
+    <android.support.design.widget.FloatingActionButton
+      android:id="@+id/button_write_faq"
+      android:layout_width="44dp"
+      android:layout_height="44dp"
+      android:layout_alignParentBottom="true"
+      android:layout_alignParentEnd="true"
+      android:layout_gravity="bottom|end"
+      android:layout_marginBottom="22dp"
+      android:layout_marginEnd="22dp"
+      android:src="@drawable/icon_inqurebtn"
+      android:scaleType="center"
+      />
+
+  </RelativeLayout>
+
 
 </LinearLayout>

+ 82 - 35
app/src/main/res/layout/faq_question_list.xml

@@ -3,57 +3,104 @@
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
-  android:orientation="horizontal">
+  android:background="@drawable/faq_answer_border"
+  android:orientation="vertical">
 
 
   <LinearLayout
-    android:layout_width="wrap_content"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:paddingLeft="23dp"
-    android:paddingTop="23dp"
-    android:paddingBottom="23dp"
-    android:orientation="vertical">
+    android:orientation="horizontal">
 
-    <TextView
-      android:id="@+id/faq_category"
+    <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
-      android:layout_marginBottom="5dp"
-      android:lineSpacingExtra="4sp"
-      android:text="회원"
-      android:textColor="#999999"
-      android:textSize="10sp"/>
-
-    <TextView
-      android:id="@+id/faq_question"
-      android:layout_width="wrap_content"
+      android:orientation="vertical"
+      android:paddingBottom="23dp"
+      android:paddingLeft="23dp"
+      android:paddingTop="23dp">
+
+      <TextView
+        android:id="@+id/faq_category"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="5dp"
+        android:lineSpacingExtra="4sp"
+        android:text="회원"
+        android:textColor="#999999"
+        android:textSize="10sp"/>
+
+      <TextView
+        android:id="@+id/faq_question"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:lineSpacingExtra="5sp"
+        android:text="비밀번호는 어떻게 변경하나요?"
+        android:textColor="#333333"
+        android:textSize="14sp"
+        />
+
+    </LinearLayout>
+
+    <Space
+      android:layout_width="0dp"
       android:layout_height="wrap_content"
-      android:lineSpacingExtra="5sp"
-      android:text="비밀번호는 어떻게 변경하나요?"
-      android:textColor="#333333"
-      android:textSize="14sp"
+      android:layout_weight="1"
       />
 
+    <LinearLayout
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:orientation="horizontal">
+
+      <ImageView
+        android:id="@+id/button_open_arrow"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:paddingTop="47dp"
+        android:paddingBottom="47dp"
+        android:paddingRight="23dp"
+        android:src="@drawable/icon_openarrow"
+
+        />
+
+    </LinearLayout>
   </LinearLayout>
 
   <LinearLayout
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:orientation="horizontal">
-
-    <ImageView
-      android:id="@+id/button_open_arrow"
-      android:layout_width="wrap_content"
-      android:layout_height="match_parent"
-      android:paddingTop="40dp"
-      android:paddingBottom="40dp"
-      android:layout_marginLeft="86dp"
-      android:src="@drawable/icon_openarrow"
+    android:id="@+id/layout_answer"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
 
-      />
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:orientation="vertical"
+      android:paddingBottom="23dp"
+      android:paddingLeft="23dp"
+      android:paddingRight="23dp"
+      >
 
+      <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:layout_marginBottom="23dp"
+        android:background="#e5e5e5"
+        />
 
-  </LinearLayout>
+      <TextView
+        android:id="@+id/faq_answer"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:lineSpacingExtra="9sp"
+        android:text="개인인증을 위한 정보(이름, 휴대폰 번호)를 입력 받고, 당첨 시 입력하신 번호로 경품 당첨 내용을 전송하오니 정확한 본인의 이름과 전화번호를 입력해 주시기 바랍니다. 당첨자는 추첨을 통해 선정되며 9월 28일자 발표일에 경품이 주어집니다."
+        android:textColor="#999999"
+        android:textSize="12sp"
+        />
 
+    </LinearLayout>
 
+  </LinearLayout>
 </LinearLayout>

+ 1 - 1
app/src/main/res/layout/fragment_faq.xml

@@ -15,7 +15,7 @@
     android:layout_marginLeft="25dp"
     android:layout_marginRight="25dp"
     android:layout_marginTop="25dp"
-    android:dividerHeight="12dp"
+    android:dividerHeight="50dp"
     android:divider="@color/CFFFFFF">
 
   </android.support.v7.widget.RecyclerView>