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();
    }
}

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 {

    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);
        hideTabLayout();
        fetchDataFromHuffPost();
        return v;
    }

    private void hideTabLayout() {
        TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tabLayout);
        tabLayout.setVisibility(View.VISIBLE);
        ViewPager 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();
    }
}

Refactor candidatelist