Home | History | Annotate | Download | only in calendar
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.calendar;
     18 
     19 import android.os.Bundle;
     20 import android.view.View;
     21 import android.view.ViewGroup.LayoutParams;
     22 import android.widget.ProgressBar;
     23 import android.widget.ViewSwitcher;
     24 
     25 public class DayActivity extends CalendarActivity implements ViewSwitcher.ViewFactory {
     26     /**
     27      * The view id used for all the views we create. It's OK to have all child
     28      * views have the same ID. This ID is used to pick which view receives
     29      * focus when a view hierarchy is saved / restore
     30      */
     31     private static final int VIEW_ID = 1;
     32 
     33     @Override
     34     protected void onCreate(Bundle icicle) {
     35         super.onCreate(icicle);
     36         setContentView(R.layout.day_activity);
     37 
     38         mSelectedDay = Utils.timeFromIntent(getIntent());
     39         mViewSwitcher = (ViewSwitcher) findViewById(R.id.switcher);
     40         mViewSwitcher.setFactory(this);
     41         mViewSwitcher.getCurrentView().requestFocus();
     42         mProgressBar = (ProgressBar) findViewById(R.id.progress_circular);
     43     }
     44 
     45     public View makeView() {
     46         DayView view = new DayView(this);
     47         view.setId(VIEW_ID);
     48         view.setLayoutParams(new ViewSwitcher.LayoutParams(
     49                 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
     50         view.setSelectedDay(mSelectedDay);
     51         return view;
     52     }
     53 
     54     @Override
     55     protected void onPause() {
     56         super.onPause();
     57         CalendarView view = (CalendarView) mViewSwitcher.getCurrentView();
     58         mSelectedDay = view.getSelectedDay();
     59     }
     60 
     61     @Override
     62     protected void onResume() {
     63         super.onResume();
     64         // Record Day View as the (new) default detailed view.
     65         Utils.setDefaultView(this, CalendarApplication.DAY_VIEW_ID);
     66     }
     67 }
     68