Loading res/layout/fragment_directory.xml +56 −51 Original line number Diff line number Diff line Loading @@ -39,6 +39,14 @@ android:background="@color/material_grey_50" android:visibility="gone"/> <com.android.documentsui.dirlist.TouchSwipeRefreshLayout android:id="@+id/refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!-- The empty container view --> <FrameLayout android:id="@android:id/empty" Loading @@ -49,7 +57,8 @@ android:background="@color/directory_background" android:focusable="true" android:focusableInTouchMode="true" android:visibility="gone"> android:visibility="gone" android:clickable="true"> <LinearLayout android:id="@+id/content" Loading Loading @@ -80,11 +89,6 @@ </LinearLayout> </FrameLayout> <!-- This FrameLayout works around b/24189541 --> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/dir_list" android:scrollbars="vertical" Loading @@ -97,7 +101,8 @@ android:clipToPadding="false" android:scrollbarStyle="outsideOverlay" android:drawSelectorOnTop="true"/> </FrameLayout> </com.android.documentsui.dirlist.TouchSwipeRefreshLayout> </com.android.documentsui.dirlist.AnimationView> src/com/android/documentsui/dirlist/DirectoryFragment.java +15 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.os.Parcelable; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Document; import android.support.v13.view.DragStartHelper; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; import android.support.v7.widget.RecyclerView; Loading Loading @@ -118,7 +119,7 @@ import javax.annotation.Nullable; */ public class DirectoryFragment extends Fragment implements DocumentsAdapter.Environment, LoaderCallbacks<DirectoryResult>, ItemDragListener.DragHost { ItemDragListener.DragHost, SwipeRefreshLayout.OnRefreshListener { @IntDef(flag = true, value = { TYPE_NORMAL, Loading Loading @@ -148,6 +149,7 @@ public class DirectoryFragment extends Fragment private IconHelper mIconHelper; private SwipeRefreshLayout mRefreshLayout; private View mEmptyView; private RecyclerView mRecView; private ListeningGestureDetector mGestureDetector; Loading Loading @@ -192,6 +194,10 @@ public class DirectoryFragment extends Fragment mMessageBar = MessageBar.create(getChildFragmentManager()); mProgressBar = view.findViewById(R.id.progressbar); mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout); mRefreshLayout.setOnRefreshListener(this); mEmptyView = view.findViewById(android.R.id.empty); mRecView = (RecyclerView) view.findViewById(R.id.dir_list); mRecView.setRecyclerListener( Loading Loading @@ -1601,6 +1607,11 @@ public class DirectoryFragment extends Fragment return R.id.container_directory; } @Override public void onRefresh() { getLoaderManager().restartLoader(LOADER_ID, null, this); } @Override public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) { Context context = getActivity(); Loading Loading @@ -1667,10 +1678,13 @@ public class DirectoryFragment extends Fragment mTuner.onModelLoaded(mModel, mType, mSearchMode); mRefreshLayout.setRefreshing(false); } @Override public void onLoaderReset(Loader<DirectoryResult> loader) { mModel.update(null); mRefreshLayout.setRefreshing(false); } } src/com/android/documentsui/dirlist/TouchSwipeRefreshLayout.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.documentsui.dirlist; import android.content.Context; import android.support.v4.widget.SwipeRefreshLayout; import android.util.AttributeSet; import android.view.MotionEvent; import com.android.documentsui.Events; /** * A {@link SwipeRefreshLayout} that only refresh on touch events. */ public class TouchSwipeRefreshLayout extends SwipeRefreshLayout { public TouchSwipeRefreshLayout(Context context) { this(context, null); } public TouchSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent e) { return Events.isMouseEvent(e) ? false : super.onInterceptTouchEvent(e); } } Loading
res/layout/fragment_directory.xml +56 −51 Original line number Diff line number Diff line Loading @@ -39,6 +39,14 @@ android:background="@color/material_grey_50" android:visibility="gone"/> <com.android.documentsui.dirlist.TouchSwipeRefreshLayout android:id="@+id/refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!-- The empty container view --> <FrameLayout android:id="@android:id/empty" Loading @@ -49,7 +57,8 @@ android:background="@color/directory_background" android:focusable="true" android:focusableInTouchMode="true" android:visibility="gone"> android:visibility="gone" android:clickable="true"> <LinearLayout android:id="@+id/content" Loading Loading @@ -80,11 +89,6 @@ </LinearLayout> </FrameLayout> <!-- This FrameLayout works around b/24189541 --> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/dir_list" android:scrollbars="vertical" Loading @@ -97,7 +101,8 @@ android:clipToPadding="false" android:scrollbarStyle="outsideOverlay" android:drawSelectorOnTop="true"/> </FrameLayout> </com.android.documentsui.dirlist.TouchSwipeRefreshLayout> </com.android.documentsui.dirlist.AnimationView>
src/com/android/documentsui/dirlist/DirectoryFragment.java +15 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.os.Parcelable; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Document; import android.support.v13.view.DragStartHelper; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; import android.support.v7.widget.RecyclerView; Loading Loading @@ -118,7 +119,7 @@ import javax.annotation.Nullable; */ public class DirectoryFragment extends Fragment implements DocumentsAdapter.Environment, LoaderCallbacks<DirectoryResult>, ItemDragListener.DragHost { ItemDragListener.DragHost, SwipeRefreshLayout.OnRefreshListener { @IntDef(flag = true, value = { TYPE_NORMAL, Loading Loading @@ -148,6 +149,7 @@ public class DirectoryFragment extends Fragment private IconHelper mIconHelper; private SwipeRefreshLayout mRefreshLayout; private View mEmptyView; private RecyclerView mRecView; private ListeningGestureDetector mGestureDetector; Loading Loading @@ -192,6 +194,10 @@ public class DirectoryFragment extends Fragment mMessageBar = MessageBar.create(getChildFragmentManager()); mProgressBar = view.findViewById(R.id.progressbar); mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout); mRefreshLayout.setOnRefreshListener(this); mEmptyView = view.findViewById(android.R.id.empty); mRecView = (RecyclerView) view.findViewById(R.id.dir_list); mRecView.setRecyclerListener( Loading Loading @@ -1601,6 +1607,11 @@ public class DirectoryFragment extends Fragment return R.id.container_directory; } @Override public void onRefresh() { getLoaderManager().restartLoader(LOADER_ID, null, this); } @Override public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) { Context context = getActivity(); Loading Loading @@ -1667,10 +1678,13 @@ public class DirectoryFragment extends Fragment mTuner.onModelLoaded(mModel, mType, mSearchMode); mRefreshLayout.setRefreshing(false); } @Override public void onLoaderReset(Loader<DirectoryResult> loader) { mModel.update(null); mRefreshLayout.setRefreshing(false); } }
src/com/android/documentsui/dirlist/TouchSwipeRefreshLayout.java 0 → 100644 +43 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.documentsui.dirlist; import android.content.Context; import android.support.v4.widget.SwipeRefreshLayout; import android.util.AttributeSet; import android.view.MotionEvent; import com.android.documentsui.Events; /** * A {@link SwipeRefreshLayout} that only refresh on touch events. */ public class TouchSwipeRefreshLayout extends SwipeRefreshLayout { public TouchSwipeRefreshLayout(Context context) { this(context, null); } public TouchSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent e) { return Events.isMouseEvent(e) ? false : super.onInterceptTouchEvent(e); } }