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 com.google.android.exoplayer2.util; 17 18 import android.os.Handler; 19 import android.os.Looper; 20 import android.os.Message; 21 import androidx.annotation.Nullable; 22 23 /** 24 * An interface to call through to a {@link Handler}. Instances must be created by calling {@link 25 * Clock#createHandler(Looper, Handler.Callback)} on {@link Clock#DEFAULT} for all non-test cases. 26 */ 27 public interface HandlerWrapper { 28 29 /** @see Handler#getLooper() */ getLooper()30 Looper getLooper(); 31 32 /** @see Handler#obtainMessage(int) */ obtainMessage(int what)33 Message obtainMessage(int what); 34 35 /** @see Handler#obtainMessage(int, Object) */ obtainMessage(int what, @Nullable Object obj)36 Message obtainMessage(int what, @Nullable Object obj); 37 38 /** @see Handler#obtainMessage(int, int, int) */ obtainMessage(int what, int arg1, int arg2)39 Message obtainMessage(int what, int arg1, int arg2); 40 41 /** @see Handler#obtainMessage(int, int, int, Object) */ obtainMessage(int what, int arg1, int arg2, @Nullable Object obj)42 Message obtainMessage(int what, int arg1, int arg2, @Nullable Object obj); 43 44 /** @see Handler#sendEmptyMessage(int) */ sendEmptyMessage(int what)45 boolean sendEmptyMessage(int what); 46 47 /** @see Handler#sendEmptyMessageAtTime(int, long) */ sendEmptyMessageAtTime(int what, long uptimeMs)48 boolean sendEmptyMessageAtTime(int what, long uptimeMs); 49 50 /** @see Handler#removeMessages(int) */ removeMessages(int what)51 void removeMessages(int what); 52 53 /** @see Handler#removeCallbacksAndMessages(Object) */ removeCallbacksAndMessages(@ullable Object token)54 void removeCallbacksAndMessages(@Nullable Object token); 55 56 /** @see Handler#post(Runnable) */ post(Runnable runnable)57 boolean post(Runnable runnable); 58 59 /** @see Handler#postDelayed(Runnable, long) */ postDelayed(Runnable runnable, long delayMs)60 boolean postDelayed(Runnable runnable, long delayMs); 61 } 62