Home | History | Annotate | Download | only in media
      1 /*
      2  * Copyright (C) 2017 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 package androidx.leanback.media;
     17 
     18 import androidx.leanback.widget.PlaybackRowPresenter;
     19 import androidx.leanback.widget.Row;
     20 
     21 /**
     22  * Fake PlaybackGlueHost used by test.
     23  */
     24 public class PlaybackGlueHostImpl extends PlaybackGlueHost {
     25 
     26     protected HostCallback mHostCallback;
     27     protected Row mRow;
     28     protected PlaybackRowPresenter mPlaybackRowPresenter;
     29     protected PlayerCallback mPlayerCallback;
     30 
     31     @Override
     32     public void setHostCallback(HostCallback callback) {
     33         mHostCallback = callback;
     34     }
     35 
     36     void notifyOnStart() {
     37         if (mHostCallback != null) {
     38             mHostCallback.onHostStart();
     39         }
     40     }
     41 
     42     void notifyOnStop() {
     43         if (mHostCallback != null) {
     44             mHostCallback.onHostStop();
     45         }
     46     }
     47 
     48     void notifyOnResume() {
     49         if (mHostCallback != null) {
     50             mHostCallback.onHostResume();
     51         }
     52     }
     53 
     54     void notifyOnPause() {
     55         if (mHostCallback != null) {
     56             mHostCallback.onHostPause();
     57         }
     58     }
     59 
     60     void notifyOnDestroy() {
     61         if (mHostCallback != null) {
     62             mHostCallback.onHostDestroy();
     63         }
     64     }
     65 
     66     @Override
     67     public void setPlaybackRow(Row row) {
     68         mRow = row;
     69     }
     70 
     71     @Override
     72     public void setPlaybackRowPresenter(PlaybackRowPresenter presenter) {
     73         mPlaybackRowPresenter = presenter;
     74     }
     75 
     76     @Override
     77     public PlayerCallback getPlayerCallback() {
     78         return mPlayerCallback;
     79     }
     80 
     81     public void setPlayerCallback(PlayerCallback playerCallback) {
     82         mPlayerCallback = playerCallback;
     83     }
     84 }
     85