package kr.co.zumo.app.lifeplus.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

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.manager.ActionBarManager;
import kr.co.zumo.app.lifeplus.model.FAQModel;
import kr.co.zumo.app.lifeplus.view.IFAQView;
import kr.co.zumo.app.lifeplus.view.fragment.faq.FAQPagerAdapter;
import kr.co.zumo.app.lifeplus.view.presenter.FAQPresenter;

public class FAQActivity extends ActivityBase<FAQPresenter> implements IFAQView {

  public static final String CATEGORY_ALL = "전체";
  public static final String CATEGORY_MEMBER = "회원";
  public static final String CATEGORY_BENEFIT = "혜택";
  public static final String CATEGORY_ETC = "기타";
  public static final int CATEGORY_KEY_ALL = 0;
  public static final int CATEGORY_KEY_MEMBER = 1;
  public static final int CATEGORY_KEY_BENEFIT = 2;
  public static final int CATEGORY_KEY_ETC = 3;

  private TabLayout tabLayoutFaq;
  private ViewPager viewPagerFaq;
  private FAQPagerAdapter faqPagerAdapter;

  @Override
  void onAfterCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_faq);

    tabLayoutFaq = findViewById(R.id.faq_tab_layout);
    viewPagerFaq = findViewById(R.id.faq_view_pager);
    tabLayoutFaq.setTabGravity(TabLayout.GRAVITY_FILL);

  }

  @Override
  void defineActionBar() {
    ActionBarManager actionBarManager = ActionBarManager.getInstance();
    actionBarManager.setTitleVisible(true);
    actionBarManager.setBiVisible(false);
    actionBarManager.setMenuVisible(true);
    actionBarManager.setSearchVisible(true);
    actionBarManager.setBackVisible(true);
    actionBarManager.setTitle(R.string.faq);
    actionBarManager.setProgressVisible(false);
    actionBarManager.show();
  }

  @Override
  FAQPresenter definePresenter() {
    return new FAQPresenter(getModel(FAQModel.class), this);
  }

  @Override
  public void drawList(List<FAQBean> beans) {
    String[] tab = {CATEGORY_ALL, CATEGORY_MEMBER, CATEGORY_BENEFIT, CATEGORY_ETC};
    faqPagerAdapter = new FAQPagerAdapter(getSupportFragmentManager(), tab, beans);
    tabLayoutFaq.setupWithViewPager(viewPagerFaq, true);
    viewPagerFaq.setAdapter(faqPagerAdapter);
  }
}
