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