ItemTouchUIUtil.java revision 7149a63961c5fe6706160bc717a3b6cbb083ca54
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
17package com.android.internal.widget.helper;
18
19import android.graphics.Canvas;
20import android.view.View;
21
22import 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 */
37public interface ItemTouchUIUtil {
38
39    /**
40     * The default implementation for {@link ItemTouchHelper.Callback#onChildDraw(Canvas,
41     * RecyclerView, RecyclerView.ViewHolder, float, float, int, boolean)}
42     */
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     */
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     */
57    void clearView(View view);
58
59    /**
60     * The default implementation for {@link ItemTouchHelper.Callback#onSelectedChanged(
61     * RecyclerView.ViewHolder, int)}
62     */
63    void onSelected(View view);
64}
65
66