diff options
author | Andrew Sapperstein <asapperstein@google.com> | 2014-02-13 09:52:19 -0800 |
---|---|---|
committer | Andrew Sapperstein <asapperstein@google.com> | 2014-02-13 10:14:15 -0800 |
commit | b6910bdf08ce931a1df5d392272014e32a2cf8b6 (patch) | |
tree | 468de4f3b6c69a3be4c77b9340ae910171624af6 | |
parent | a0fd4303d7e3ac9b539799a290cc186dbbadbe60 (diff) | |
download | android_packages_apps_UnifiedEmail-b6910bdf08ce931a1df5d392272014e32a2cf8b6.tar.gz android_packages_apps_UnifiedEmail-b6910bdf08ce931a1df5d392272014e32a2cf8b6.tar.bz2 android_packages_apps_UnifiedEmail-b6910bdf08ce931a1df5d392272014e32a2cf8b6.zip |
Fix scrolling in conversation list. b/12996192.
Change-Id: I59b5f87742314811772aef847ffc08837a2aefee
-rw-r--r-- | res/layout/conversation_list.xml | 4 | ||||
-rw-r--r-- | src/com/android/mail/ui/ConversationListFragment.java | 7 | ||||
-rw-r--r-- | src/com/android/mail/ui/MailSwipeRefreshLayout.java | 47 |
3 files changed, 53 insertions, 5 deletions
diff --git a/res/layout/conversation_list.xml b/res/layout/conversation_list.xml index 85f5fb1e0..4abb1f160 100644 --- a/res/layout/conversation_list.xml +++ b/res/layout/conversation_list.xml @@ -24,7 +24,7 @@ <include layout="@layout/search_results_view"/> - <android.support.v4.widget.SwipeRefreshLayout + <com.android.mail.ui.MailSwipeRefreshLayout android:id="@+id/swipe_refresh_widget" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -52,5 +52,5 @@ android:fadingEdge="none" style="@style/ConversationListFade" /> </FrameLayout> - </android.support.v4.widget.SwipeRefreshLayout> + </com.android.mail.ui.MailSwipeRefreshLayout> </RelativeLayout> diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java index e55701de0..8127fed71 100644 --- a/src/com/android/mail/ui/ConversationListFragment.java +++ b/src/com/android/mail/ui/ConversationListFragment.java @@ -26,7 +26,6 @@ import android.database.DataSetObserver; import android.os.Bundle; import android.os.Handler; import android.os.Parcelable; -import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; import android.text.format.DateUtils; import android.view.LayoutInflater; @@ -156,7 +155,7 @@ public final class ConversationListFragment extends ListFragment implements * from when we were last on this conversation list. */ private boolean mScrollPositionRestored = false; - private SwipeRefreshLayout mSwipeRefreshWidget; + private MailSwipeRefreshLayout mSwipeRefreshWidget; /** * Constructor needs to be public to handle orientation changes and activity @@ -437,11 +436,13 @@ public final class ConversationListFragment extends ListFragment implements if (savedState != null && savedState.containsKey(LIST_STATE_KEY)) { mListView.onRestoreInstanceState(savedState.getParcelable(LIST_STATE_KEY)); } - mSwipeRefreshWidget = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_widget); + mSwipeRefreshWidget = + (MailSwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_widget); mSwipeRefreshWidget.setColorScheme(R.color.swipe_refresh_color1, R.color.swipe_refresh_color2, R.color.swipe_refresh_color3, R.color.swipe_refresh_color4); mSwipeRefreshWidget.setOnRefreshListener(this); + mSwipeRefreshWidget.setScrollableChild(mListView); return rootView; } diff --git a/src/com/android/mail/ui/MailSwipeRefreshLayout.java b/src/com/android/mail/ui/MailSwipeRefreshLayout.java new file mode 100644 index 000000000..9a2f68c2c --- /dev/null +++ b/src/com/android/mail/ui/MailSwipeRefreshLayout.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2014 Google Inc. + * Licensed to 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.mail.ui; + +import android.content.Context; +import android.support.v4.widget.SwipeRefreshLayout; +import android.util.AttributeSet; +import android.view.View; + +/** + * Overrides {@code SwipeRefreshLayout} to enable swiping the empty state. + */ +public class MailSwipeRefreshLayout extends SwipeRefreshLayout { + + private View mScrollableChild; + public MailSwipeRefreshLayout(Context context) { + this(context, null); + } + + public MailSwipeRefreshLayout(Context context, AttributeSet attr) { + super(context, attr); + } + + public void setScrollableChild(View scrollableChild) { + mScrollableChild = scrollableChild; + } + + @Override + public boolean canChildScrollUp() { + return mScrollableChild.canScrollVertically(-1 /* up direction */); + } +} |