package com.localhop.activities.event;

import android.media.Image;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageButton;

import com.localhop.swipe.createevent.CreateEventSwipeAdapter;
import com.localhop.R;
import com.localhop.swipe.viewpagersupport.ZoomOutPageTransformer;
import com.localhop.utils.ViewUtils;

/**
 * Activity for the Create Event tab in the main navigation tabs.
 */
public class ActivityTabCreateEvent extends FragmentActivity {

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

        setContentView(R.layout.tab_create_event_swipe);

        // Set up the custom Swipe View for Create Event Details and Invite Pages
        ViewPager pager = (ViewPager) findViewById(R.id.pCreateEventDetailInvite);
        FragmentManager fm = getSupportFragmentManager();
        CreateEventSwipeAdapter pagerAdapter = new CreateEventSwipeAdapter(fm);
        pager.setAdapter(pagerAdapter);
        pager.setCurrentItem(0);
        pager.setPageTransformer(true, new ZoomOutPageTransformer());

        // Setup the back button to get out of the create new event page
        setupBackButton();


    } // end of function onCreate()

    /**
     * Setup the Back button that allows the user to navigate back from the create event page
     */
    private void setupBackButton() {
        ImageButton backImageButton = (ImageButton) findViewById(R.id.ib_create_event_back_button);
        backImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO: Once the favorites/recent events page is complete, set this to finish
            }
        });
    } // end of function setupBackButton()

} // end of class ActivityTabCreateEvent

@@ -272,27 +272,88 @@
 .widget.
-ImageButton
+EditText;%0Aimport android.widget.ImageButton;%0Aimport android.widget.Toast
 ;%0A%0Aimpor
@@ -937,16 +937,22 @@
         
+final 
 ViewPage
@@ -1229,16 +1229,56 @@
 tem(0);%0A
+        pager.setOffscreenPageLimit(2);%0A
         
@@ -1336,24 +1336,1872 @@
 former());%0A%0A
+        // On the invite page, we need to grab the data from the Details page.%0A        // Unfortunately, we cannot do this from within CreateEventSwipe.java because%0A        // the fragment gets blown away and the UI components are null.%0A        // However, this seems to work fine for the time being.%0A        pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() %7B%0A            @Override%0A            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) %7B%0A                // Not Used%0A            %7D%0A%0A            @Override%0A            public void onPageSelected(int position) %7B%0A                if(position == 1)%0A                %7B%0A                    ImageButton createEventImageButton = (ImageButton)pager.findViewById(R.id.ib_create_event);%0A                    createEventImageButton.setOnClickListener(new View.OnClickListener() %7B%0A                        @Override%0A                        public void onClick(View v) %7B%0A%0A                            EditText eventNameEditText = (EditText)pager.findViewById(R.id.et_create_event_name);%0A                            // TODO: Get other UI Components from Details page%0A%0A                            if(!eventNameEditText.getText().toString().isEmpty())%0A                            %7B%0A                               // TODO: Query the DB (This query is already in CreateEventSwipe.java)%0A                            %7D%0A                            else%0A                            %7B%0A                                Toast.makeText(getBaseContext(), R.string.missing_event_name_error, Toast.LENGTH_SHORT).show();%0A                            %7D%0A                        %7D%0A                    %7D);%0A                %7D%0A            %7D%0A%0A            @Override%0A            public void onPageScrollStateChanged(int state) %7B%0A                // Not Used%0A            %7D%0A        %7D);%0A%0A
         // S

Fix CreateEvent Swipe Null Data Issue