package no.hyper.dateintervalpicker.sample;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import no.hyper.dateintervalpicker.DateIntervalPicker;


/**
 * Created by espenalmdahl on 31/10/14.
 *
 * This class is just a startup class for demo purpose.
 */
public class MainActivity extends Activity {

    private DateIntervalPicker picker;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        picker = (DateIntervalPicker) getFragmentManager().findFragmentById(R.id.picker_fragment);
    }

    /**
     * Called from the button in the main_activity layout.
     *
     * Shows how to access the to and from dates in the picker fragment and use them in your main activity
     */
    public void confirm(View v) {
        if ( picker.getFromDate() != null) {
            Intent intent = new Intent();

            intent.putExtra("from", picker.getFromDate().getTime());
            intent.putExtra("to", picker.getToDate().getTime());
            this.setResult(100, intent);
            Toast.makeText(this, picker.getFromDate() + " to " + picker.getToDate(), Toast.LENGTH_LONG).show();
        }
        else {
            this.setResult(-100);
            Toast.makeText(this, "No dates selected", Toast.LENGTH_LONG).show();
        }

        this.finish();
    }
}

@@ -57,12 +57,58 @@
 oid.
-app.
+os.Bundle;%0Aimport android.support.v7.app.ActionBar
 Acti
@@ -132,22 +132,17 @@
 oid.
-content.Intent
+view.Menu
 ;%0Aim
@@ -150,33 +150,37 @@
 ort android.
-os.Bundle
+view.MenuItem
 ;%0Aimport and
@@ -285,111 +285,111 @@
 r;%0A%0A
-%0A
 /**%0A * 
-Created by espenalmdahl on 31/10/14.%0A *%0A * This class is just a startup class for demo purpose.
+Demo activity for showing how to use the DateIntervalPicker fragment%0A *%0A * @author Espen Almdahl
 %0A */
@@ -423,16 +423,25 @@
 extends 
+ActionBar
 Activity
@@ -647,16 +647,17 @@
 ivity);%0A
+%0A
         
@@ -743,24 +743,25 @@
 _fragment);%0A
+%0A
     %7D%0A%0A    /
@@ -778,27 +778,33 @@
 Call
-ed
+back
  from 
-the
+confirm
  button 
 in t
@@ -803,669 +803,168 @@
 ton 
-in the main_activity
+declared in
  layout
-.
 %0A     *
-%0A     * Shows how to access the to and from dates in the picker fragment and use them in your main activity%0A     */%0A    public void confirm(View v) %7B%0A        if ( picker.getFromDate() != null) %7B%0A            Intent intent = new Intent();%0A%0A            intent.putExtra(%22from%22, picker.getFromDate().getTime());%0A            intent.putExtra(%22to%22, picker.getToDate().getTime());%0A            this.setResult(100, intent);%0A            Toast.makeText(this, picker.getFromDate() + %22 to %22 + picker.getToDate(), Toast.LENGTH_LONG).show();%0A        %7D%0A        else %7B%0A            this.setResult(-100);%0A            Toast.makeText(this, %22No dates
+ @param v%0A     */%0A    public void confirm(View v) %7B%0A        Toast.makeText(this, picker.getFromDate() + %22 to %22 + picker.getToDate() + %22
  sel
@@ -1006,42 +1006,9 @@
     
-    %7D%0A%0A        this.finish();%0A    
 %7D
+%0A
 %0A%7D%0A

add some comments to MainActivity