blob: b5c1806c5414644558efef0c2ef1869f7f2f1034 [file] [log] [blame]
Garfield, Tanca7c0882016-07-18 16:45:27 -07001/*
2 * Copyright (C) 2016 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.documentsui.dirlist;
18
19import android.content.Context;
Garfield, Tan8b6b35d2016-07-20 14:36:42 -070020import android.content.res.TypedArray;
21import android.support.annotation.ColorRes;
Garfield, Tanca7c0882016-07-18 16:45:27 -070022import android.support.v4.widget.SwipeRefreshLayout;
23import android.util.AttributeSet;
24import android.view.MotionEvent;
25
Garfield, Tanca7c0882016-07-18 16:45:27 -070026/**
Ben Lin40f44882016-08-04 10:42:59 -070027 * A {@link SwipeRefreshLayout} that does not intercept any touch events. This relies on its nested
Ben Lind79edd12017-03-14 17:39:36 -070028 * view to scroll in order to cause a refresh. It is possible that it gets disabled by
29 * {@link ListeningGestureDetector} .
Garfield, Tanca7c0882016-07-18 16:45:27 -070030 */
Ben Lin40f44882016-08-04 10:42:59 -070031public class DocumentsSwipeRefreshLayout extends SwipeRefreshLayout {
Garfield, Tanca7c0882016-07-18 16:45:27 -070032
Garfield, Tan8b6b35d2016-07-20 14:36:42 -070033 private static final int[] COLOR_RES = new int[] { android.R.attr.colorAccent };
34 private static int COLOR_ACCENT_INDEX = 0;
35
Ben Lin40f44882016-08-04 10:42:59 -070036 public DocumentsSwipeRefreshLayout(Context context) {
Garfield, Tanca7c0882016-07-18 16:45:27 -070037 this(context, null);
38 }
39
Ben Lin40f44882016-08-04 10:42:59 -070040 public DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs) {
Garfield, Tanca7c0882016-07-18 16:45:27 -070041 super(context, attrs);
Garfield, Tan8b6b35d2016-07-20 14:36:42 -070042
43 TypedArray a = context.obtainStyledAttributes(COLOR_RES);
44 @ColorRes int colorId = a.getResourceId(COLOR_ACCENT_INDEX, -1);
45 a.recycle();
46 setColorSchemeResources(colorId);
Garfield, Tanca7c0882016-07-18 16:45:27 -070047 }
48
49 @Override
50 public boolean onInterceptTouchEvent(MotionEvent e) {
Ben Lin40f44882016-08-04 10:42:59 -070051 return false;
Garfield, Tanca7c0882016-07-18 16:45:27 -070052 }
Ben Lind79edd12017-03-14 17:39:36 -070053}