1 /* 2 * Copyright (C) 2020 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.view.View 20 import android.widget.Button 21 import android.widget.ImageView 22 23 /** 24 * Implementers of this interface are able to [configure the fab][.onUpdateFab] and associated 25 * [left/right buttons][.onUpdateFabButtons] including setting them [View.INVISIBLE] if 26 * they are unnecessary. Implementers also attach click handler logic to the 27 * [fab][.onFabClick], [left button][.onLeftButtonClick] and 28 * [right button][.onRightButtonClick]. 29 */ 30 interface FabController { 31 /** 32 * Configures the display of the fab component to match the current state of this controller. 33 * 34 * @param fab the fab component to be configured based on current state 35 */ onUpdateFabnull36 fun onUpdateFab(fab: ImageView) 37 38 /** 39 * Called before onUpdateFab when the fab should be animated. 40 * 41 * @param fab the fab component to be configured based on current state 42 */ 43 fun onMorphFab(fab: ImageView) 44 45 /** 46 * Configures the display of the buttons to the left and right of the fab to match the current 47 * state of this controller. 48 * 49 * @param left button to the left of the fab to configure based on current state 50 * @param right button to the right of the fab to configure based on current state 51 */ 52 fun onUpdateFabButtons(left: Button, right: Button) 53 54 /** 55 * Handles a click on the fab. 56 * 57 * @param fab the fab component on which the click occurred 58 */ 59 fun onFabClick(fab: ImageView) 60 61 /** 62 * Handles a click on the button to the left of the fab component. 63 * 64 * @param left the button to the left of the fab component 65 */ 66 fun onLeftButtonClick(left: Button) 67 68 /** 69 * Handles a click on the button to the right of the fab component. 70 * 71 * @param right the button to the right of the fab component 72 */ 73 fun onRightButtonClick(right: Button) 74 }