summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/conversation_list.xml4
-rw-r--r--src/com/android/mail/ui/ConversationListFragment.java7
-rw-r--r--src/com/android/mail/ui/MailSwipeRefreshLayout.java47
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 */);
+ }
+}