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 17 package com.android.internal.widget.helper; 18 19 import android.graphics.Canvas; 20 import android.view.View; 21 22 import com.android.internal.widget.RecyclerView; 23 24 /** 25 * Utility class for {@link ItemTouchHelper} which handles item transformations for different 26 * API versions. 27 * <p/> 28 * This class has methods that map to {@link ItemTouchHelper.Callback}'s drawing methods. Default 29 * implementations in {@link ItemTouchHelper.Callback} call these methods with 30 * {@link RecyclerView.ViewHolder#itemView} and {@link ItemTouchUIUtil} makes necessary changes 31 * on the View depending on the API level. You can access the instance of {@link ItemTouchUIUtil} 32 * via {@link ItemTouchHelper.Callback#getDefaultUIUtil()} and call its methods with the children 33 * of ViewHolder that you want to apply default effects. 34 * 35 * @see ItemTouchHelper.Callback#getDefaultUIUtil() 36 */ 37 public interface ItemTouchUIUtil { 38 39 /** 40 * The default implementation for {@link ItemTouchHelper.Callback#onChildDraw(Canvas, 41 * RecyclerView, RecyclerView.ViewHolder, float, float, int, boolean)} 42 */ onDraw(Canvas c, RecyclerView recyclerView, View view, float dX, float dY, int actionState, boolean isCurrentlyActive)43 void onDraw(Canvas c, RecyclerView recyclerView, View view, 44 float dX, float dY, int actionState, boolean isCurrentlyActive); 45 46 /** 47 * The default implementation for {@link ItemTouchHelper.Callback#onChildDrawOver(Canvas, 48 * RecyclerView, RecyclerView.ViewHolder, float, float, int, boolean)} 49 */ onDrawOver(Canvas c, RecyclerView recyclerView, View view, float dX, float dY, int actionState, boolean isCurrentlyActive)50 void onDrawOver(Canvas c, RecyclerView recyclerView, View view, 51 float dX, float dY, int actionState, boolean isCurrentlyActive); 52 53 /** 54 * The default implementation for {@link ItemTouchHelper.Callback#clearView(RecyclerView, 55 * RecyclerView.ViewHolder)} 56 */ clearView(View view)57 void clearView(View view); 58 59 /** 60 * The default implementation for {@link ItemTouchHelper.Callback#onSelectedChanged( 61 * RecyclerView.ViewHolder, int)} 62 */ onSelected(View view)63 void onSelected(View view); 64 } 65 66