package com.thebluealliance.androidclient.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.thebluealliance.androidclient.fragments.event.EventAwardsFragment;
import com.thebluealliance.androidclient.fragments.event.EventMatchesFragment;
import com.thebluealliance.androidclient.fragments.teamAtEvent.TeamAtEventStatsFragment;
import com.thebluealliance.androidclient.fragments.teamAtEvent.TeamAtEventSummaryFragment;

public class TeamAtEventFragmentPagerAdapter extends FragmentPagerAdapter {

    public static final String[] TITLES = {"Summary", "Matches", "Stats", "Awards"};

    private String teamKey, eventKey;

    public TeamAtEventFragmentPagerAdapter(FragmentManager fm, String teamKey, String eventKey) {
        super(fm);
        this.teamKey = teamKey;
        this.eventKey = eventKey;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLES[position];
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment;
        switch (position) {
            default:
            case 0: //summary
                fragment = TeamAtEventSummaryFragment.newInstance(teamKey, eventKey);
                break;
            case 1:
                //matches
                fragment = EventMatchesFragment.newInstance(eventKey, teamKey);
                break;
            case 2: //stats
                fragment = TeamAtEventStatsFragment.newInstance(teamKey, eventKey);
                break;
            case 3: //awards
                fragment = EventAwardsFragment.newInstance(eventKey, teamKey);
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return TITLES.length;
    }
}

@@ -335,32 +335,107 @@
 atchesFragment;%0A
+import com.thebluealliance.androidclient.fragments.team.TeamMediaFragment;%0A
 import com.thebl
@@ -597,16 +597,78 @@
 ragment;
+%0Aimport com.thebluealliance.androidclient.helpers.EventHelper;
 %0A%0Apublic
@@ -802,16 +802,25 @@
 atches%22,
+ %22Media%22,
  %22Stats%22
@@ -831,16 +831,172 @@
 wards%22%7D;
+%0A    public static final int TAB_SUMMARY = 0,%0A            TAB_MATCHES = 1,%0A            TAB_MEDIA = 2,%0A            TAB_STATS = 3,%0A            TAB_AWARDS = 4;
 %0A%0A    pr
@@ -1008,25 +1008,26 @@
  String 
-t
+mT
 eamKey, 
 eventKey
@@ -1014,25 +1014,26 @@
 g mTeamKey, 
-e
+mE
 ventKey;%0A%0A  
@@ -1159,14 +1159,10 @@
     
-this.t
+mT
 eamK
@@ -1187,14 +1187,10 @@
     
-this.e
+mE
 vent
@@ -1311,32 +1311,111 @@
 sition%5D;%0A    %7D%0A%0A
+    @Override%0A    public int getCount() %7B%0A        return TITLES.length;%0A    %7D%0A%0A
     @Override%0A  
@@ -1460,35 +1460,8 @@
 ) %7B%0A
-        Fragment fragment;%0A
     
@@ -1500,46 +1500,25 @@
     
-default:%0A            case 0: //summary
+case TAB_SUMMARY:
 %0A   
@@ -1526,34 +1526,30 @@
             
-fragment =
+return
  TeamAtEvent
@@ -1572,33 +1572,34 @@
 newInstance(
-t
+mT
 eamKey, 
 eventKey);%0A 
@@ -1578,33 +1578,34 @@
 tance(mTeamKey, 
-e
+mE
 ventKey);%0A      
@@ -1614,91 +1614,48 @@
     
-    break;%0A            case 1:%0A                //matches%0A                fragment =
+case TAB_MATCHES:%0A                return
  Eve
@@ -1676,33 +1676,34 @@
 ent.newInstance(
-e
+mE
 ventKey, teamKey
@@ -1687,33 +1687,34 @@
 ance(mEventKey, 
-t
+mT
 eamKey);%0A       
@@ -1714,33 +1714,134 @@
             
-    break
+case TAB_MEDIA:%0A                return TeamMediaFragment.newInstance(mTeamKey, EventHelper.getYear(mEventKey))
 ;%0A          
@@ -1851,18 +1851,18 @@
 ase 
-2: //stats
+TAB_STATS:
 %0A   
@@ -1874,26 +1874,22 @@
         
-fragment =
+return
  TeamAtE
@@ -1918,25 +1918,26 @@
 nstance(
-t
+mT
 eamKey, 
 eventKey
@@ -1928,17 +1928,18 @@
 eamKey, 
-e
+mE
 ventKey)
@@ -1956,47 +1956,24 @@
     
-    break;%0A            case 3: //awards
+case TAB_AWARDS:
 %0A   
@@ -1989,18 +1989,14 @@
     
-fragment =
+return
  Eve
@@ -2024,17 +2024,18 @@
 nstance(
-e
+mE
 ventKey,
@@ -2035,17 +2035,18 @@
 entKey, 
-t
+mT
 eamKey);
@@ -2062,18 +2062,16 @@
     
-    break;
+default:
 %0A   
@@ -2075,18 +2075,16 @@
         
-%7D%0A
         
@@ -2094,101 +2094,39 @@
 urn 
-f
+new F
 ragment
-;%0A    %7D%0A%0A    @Override%0A    public int getCount() %7B%0A        return TITLES.length;
+();%0A        %7D
 %0A    %7D%0A
+%0A
 %7D%0A

Add Media tab to Team at Event (#882)