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