package com.lumivote.lumivote.ui.candidate_tab;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lumivote.lumivote.R;
import com.lumivote.lumivote.api.HuffPostPollRESTClient;

/**
 * Created by Alex Dao on May 23, 2015.
 */
public class CandidateListFragment extends Fragment {

    TabLayout tabLayout;
    ViewPager mViewPager;

    public CandidateListFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_candidatelist, container, false);
        initInstances(v);
        fetchDataFromHuffPost();
        return v;
    }

    private void initInstances(View v) {
        tabLayout = (TabLayout) getActivity().findViewById(R.id.tabLayout);
        tabLayout.setVisibility(View.VISIBLE);
        mViewPager = (ViewPager) getActivity().findViewById(R.id.viewpager);
        mViewPager.setVisibility(View.VISIBLE);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

    private void fetchDataFromHuffPost() {
        HuffPostPollRESTClient client = HuffPostPollRESTClient.getInstance();
        client.fetchDemocratPrimaryPolls();
        client.fetchRepublicanPrimaryPolls();
    }
}

@@ -489,60 +489,8 @@
  %7B%0A%0A
-    TabLayout tabLayout;%0A    ViewPager mViewPager;%0A%0A
     
@@ -893,23 +893,22 @@
     
-initInstances(v
+hideTabLayout(
 );%0A 
@@ -985,28 +985,22 @@
 oid 
-initInstances(View v
+hideTabLayout(
 ) %7B%0A
@@ -998,32 +998,42 @@
 yout() %7B%0A       
+ 
+TabLayout
  tabLayout = (Ta
@@ -1132,24 +1132,24 @@
 SIBLE);%0A
-
         
 mViewPag
@@ -1132,32 +1132,42 @@
 SIBLE);%0A        
+ViewPager 
 mViewPager = (Vi

Refactor candidatelist