1 /* 2 * Copyright (C) 2012 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.deskclock; 18 19 import android.app.Activity; 20 import android.app.Fragment; 21 import android.os.Bundle; 22 import android.view.View; 23 import android.widget.ImageButton; 24 import android.widget.ImageView; 25 26 public class DeskClockFragment extends Fragment { 27 28 protected ImageView mFab; 29 protected ImageButton mLeftButton; 30 protected ImageButton mRightButton; 31 onPageChanged(int page)32 public void onPageChanged(int page) { 33 // Do nothing here , only in derived classes 34 } 35 onFabClick(View view)36 public void onFabClick(View view){ 37 // Do nothing here , only in derived classes 38 } 39 40 @Override onActivityCreated(Bundle savedInstanceState)41 public void onActivityCreated(Bundle savedInstanceState) { 42 super.onActivityCreated(savedInstanceState); 43 final Activity activity = getActivity(); 44 if (activity instanceof DeskClock) { 45 final DeskClock deskClockActivity = (DeskClock) activity; 46 mFab = deskClockActivity.getFab(); 47 mLeftButton = deskClockActivity.getLeftButton(); 48 mRightButton = deskClockActivity.getRightButton(); 49 } 50 } 51 setFabAppearance()52 public void setFabAppearance() { 53 // Do nothing here , only in derived classes 54 } 55 setLeftRightButtonAppearance()56 public void setLeftRightButtonAppearance() { 57 // Do nothing here , only in derived classes 58 } 59 onLeftButtonClick(View view)60 public void onLeftButtonClick(View view) { 61 // Do nothing here , only in derived classes 62 } 63 onRightButtonClick(View view)64 public void onRightButtonClick(View view) { 65 // Do nothing here , only in derived classes 66 } 67 getDeskClock()68 protected final DeskClock getDeskClock() { 69 return (DeskClock) getActivity(); 70 } 71 getSelectedTab()72 protected final int getSelectedTab() { 73 final DeskClock deskClock = getDeskClock(); 74 return deskClock == null ? -1 : deskClock.getSelectedTab(); 75 } 76 } 77