• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.documentsui.dirlist;
18 
19 import android.content.Context;
20 import android.content.res.TypedArray;
21 import android.support.annotation.ColorRes;
22 import android.support.v4.widget.SwipeRefreshLayout;
23 import android.util.AttributeSet;
24 import android.view.MotionEvent;
25 
26 /**
27  * A {@link SwipeRefreshLayout} that does not intercept any touch events. This relies on its nested
28  * view to scroll in order to cause a refresh. It is possible that it gets disabled by
29  * {@link ListeningGestureDetector} .
30  */
31 public class DocumentsSwipeRefreshLayout extends SwipeRefreshLayout {
32 
33     private static final int[] COLOR_RES = new int[] { android.R.attr.colorAccent };
34     private static int COLOR_ACCENT_INDEX = 0;
35 
DocumentsSwipeRefreshLayout(Context context)36     public DocumentsSwipeRefreshLayout(Context context) {
37         this(context, null);
38     }
39 
DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs)40     public DocumentsSwipeRefreshLayout(Context context, AttributeSet attrs) {
41         super(context, attrs);
42 
43         TypedArray a = context.obtainStyledAttributes(COLOR_RES);
44         @ColorRes int colorId = a.getResourceId(COLOR_ACCENT_INDEX, -1);
45         a.recycle();
46         setColorSchemeResources(colorId);
47     }
48 
49     @Override
onInterceptTouchEvent(MotionEvent e)50     public boolean onInterceptTouchEvent(MotionEvent e) {
51         return false;
52     }
53 }