package com.Utopia.utopia.app;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.CalendarView;


public class CalendarActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calendar);
        final CalendarView calendarView = (CalendarView)findViewById(R.id.calendar_view);
        Intent callerIntent = getIntent();
        long currentTime = callerIntent.getLongExtra("currentTime",0);
        calendarView.setDate(TimeUtil.getMillisFromTime(currentTime));
        calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            @Override
            public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
                Intent intent = new Intent(CalendarActivity.this,MainActivity.class);
                long millis = calendarView.getDate();
                intent.putExtra("millis",millis);
                setResult(RESULT_OK,intent);
                finish();
            }
        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_calendar, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

@@ -451,16 +451,17 @@
 endar);%0A
+%0A
         
@@ -668,71 +668,379 @@
     
-calendarView.setDate(TimeUtil.getMillisFromTime(currentTime)
+final long millis = TimeUtil.getMillisFromTime(currentTime);%0A        calendarView.setDate(millis);%0A%0A        Calendar cal = Calendar.getInstance();%0A        cal.setTime(new Date(millis));%0A        final int currentYear = cal.get(Calendar.YEAR);%0A        final int currentMonth = cal.get(Calendar.MONTH);%0A        final int currentDayOfMonth = cal.get(Calendar.DAY_OF_MONTH
 );%0A
+%0A
     
@@ -1242,24 +1242,183 @@
 yOfMonth) %7B%0A
+                long changedMillis = view.getDate();%0A                if(currentYear != year %7C%7C currentMonth != month %7C%7C currentDayOfMonth != dayOfMonth) %7B%0A    
             
@@ -1499,58 +1499,8 @@
     
-            long millis = calendarView.getDate();%0A
     
@@ -1536,25 +1536,33 @@
 millis%22,
-m
+ changedM
 illis);%0A
         
@@ -1549,24 +1549,28 @@
 gedMillis);%0A
+    
             
@@ -1593,16 +1593,17 @@
 SULT_OK,
+ 
 intent);
@@ -1603,16 +1603,20 @@
 ntent);%0A
+    
         
@@ -1629,24 +1629,42 @@
   finish();%0A
+                %7D%0A
             
@@ -1685,16 +1685,17 @@
     %7D%0A%0A%0A
+%0A
     @Ove

Update CalendarActivity.java