1/* 2 * Copyright (C) 2018 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 */ 16package com.android.quickstep; 17 18import android.annotation.TargetApi; 19import android.os.Build; 20import android.support.annotation.IntDef; 21import android.view.Choreographer; 22import android.view.MotionEvent; 23 24import java.lang.annotation.Retention; 25import java.lang.annotation.RetentionPolicy; 26import java.util.function.Consumer; 27 28@TargetApi(Build.VERSION_CODES.O) 29@FunctionalInterface 30public interface TouchConsumer extends Consumer<MotionEvent> { 31 32 @IntDef(flag = true, value = { 33 INTERACTION_NORMAL, 34 INTERACTION_QUICK_SCRUB 35 }) 36 @Retention(RetentionPolicy.SOURCE) 37 @interface InteractionType {} 38 int INTERACTION_NORMAL = 0; 39 int INTERACTION_QUICK_SCRUB = 1; 40 41 default void reset() { } 42 43 default void updateTouchTracking(@InteractionType int interactionType) { } 44 45 default void onQuickScrubEnd() { } 46 47 default void onQuickScrubProgress(float progress) { } 48 49 default void onQuickStep(MotionEvent ev) { } 50 51 default void onCommand(int command) { } 52 53 /** 54 * Called on the binder thread to allow the consumer to process the motion event before it is 55 * posted on a handler thread. 56 */ 57 default void preProcessMotionEvent(MotionEvent ev) { } 58 59 default Choreographer getIntrimChoreographer(MotionEventQueue queue) { 60 return null; 61 } 62 63 default void deferInit() { } 64 65 default boolean deferNextEventToMainThread() { 66 return false; 67 } 68 69 default boolean forceToLauncherConsumer() { 70 return false; 71 } 72 73 default void onShowOverviewFromAltTab() {} 74} 75