1241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng/* 2241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * Copyright (C) 2013 The Android Open Source Project 3241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * 4241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 5241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * you may not use this file except in compliance with the License. 6241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * You may obtain a copy of the License at 7241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * 8241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 9241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * 10241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * Unless required by applicable law or agreed to in writing, software 11241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 12241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * See the License for the specific language governing permissions and 14241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * limitations under the License 15241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng */ 16241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng 17241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Chengpackage com.android.incallui; 18241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng 19241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng/** 20241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * Base class for Presenters. 21241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng */ 22241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Chengpublic abstract class Presenter<U extends Ui> { 23241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng 24241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng private U mUi; 25241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng 26241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng /** 27241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * Called after the UI view has been created. That is when fragment.onViewCreated() is called. 28241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * 29241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng * @param ui The Ui implementation that is now ready to be used. 30241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng */ 31241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng public void onUiReady(U ui) { 32241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng mUi = ui; 33241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng } 34241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng 35dab149c9b2185be82cbca63cc3980e41444900c0Santos Cordon /** 36dab149c9b2185be82cbca63cc3980e41444900c0Santos Cordon * Called when the UI view is destroyed in Fragment.onDestroyView(). 37dab149c9b2185be82cbca63cc3980e41444900c0Santos Cordon */ 38b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon public final void onUiDestroy(U ui) { 39b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon onUiUnready(ui); 40dab149c9b2185be82cbca63cc3980e41444900c0Santos Cordon mUi = null; 41dab149c9b2185be82cbca63cc3980e41444900c0Santos Cordon } 42dab149c9b2185be82cbca63cc3980e41444900c0Santos Cordon 43b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon /** 44b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon * To be overriden by Presenter implementations. Called when the fragment is being 45b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon * destroyed but before ui is set to null. 46b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon */ 47b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon public void onUiUnready(U ui) { 48b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon } 49b0d08a16da088e01f416f52a7b74ee9630c1493aSantos Cordon 50241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng public U getUi() { 51241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng return mUi; 52241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng } 53241d50d5f523eb0b644d8a9c1cf7fd2eb418ab88Chiao Cheng} 54