1 // CHECKSTYLE:OFF Generated code 2 /* This file is auto-generated from PlaybackTransportControlActivity.java. DO NOT MODIFY. */ 3 4 /* 5 * Copyright (C) 2016 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package com.example.android.leanback; 21 22 import android.os.Bundle; 23 24 import androidx.fragment.app.FragmentActivity; 25 26 import java.util.ArrayList; 27 import java.util.List; 28 29 /** 30 * Host PlaybackFragment and provide PIP events. 31 */ 32 public class PlaybackTransportControlSupportActivity extends FragmentActivity { 33 private List<PictureInPictureListener> mListeners = new ArrayList<>(); 34 35 /** Called when the activity is first created. */ 36 @Override onCreate(Bundle savedInstanceState)37 public void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 setContentView(R.layout.playback_transportcontrol_activity_support); 40 } 41 42 @Override onPictureInPictureModeChanged(boolean isInPictureInPictureMode)43 public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) { 44 for (PictureInPictureListener listener : mListeners) { 45 listener.onPictureInPictureModeChanged(isInPictureInPictureMode); 46 } 47 } 48 49 /** 50 * Register a PIP listener. 51 */ registerPictureInPictureListener(PictureInPictureListener listener)52 public void registerPictureInPictureListener(PictureInPictureListener listener) { 53 mListeners.add(listener); 54 } 55 56 /** 57 * Unregister a PIP listener. 58 */ unregisterPictureInPictureListener(PictureInPictureListener listener)59 public void unregisterPictureInPictureListener(PictureInPictureListener listener) { 60 mListeners.remove(listener); 61 } 62 63 /** 64 * Interface of PIP event on Activity. 65 */ 66 public interface PictureInPictureListener { 67 /** 68 * Called when Activity's PIP mode is changed. 69 */ onPictureInPictureModeChanged(boolean isInPictureInPictureMode)70 void onPictureInPictureModeChanged(boolean isInPictureInPictureMode); 71 } 72 } 73