Browse Source

Animate search bar transition

Mario Danic 8 năm trước cách đây
mục cha
commit
e3cf4701f2

+ 9 - 3
src/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -20,6 +20,7 @@
 
 
 package com.owncloud.android.ui.fragment;
 package com.owncloud.android.ui.fragment;
 
 
+import android.animation.LayoutTransition;
 import android.os.Bundle;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Handler;
 import android.support.annotation.DrawableRes;
 import android.support.annotation.DrawableRes;
@@ -55,8 +56,6 @@ import java.util.ArrayList;
 
 
 import third_parties.in.srain.cube.GridViewWithHeaderAndFooter;
 import third_parties.in.srain.cube.GridViewWithHeaderAndFooter;
 
 
-import static com.owncloud.android.R.id.searchView;
-
 public class ExtendedListFragment extends Fragment
 public class ExtendedListFragment extends Fragment
         implements OnItemClickListener, OnEnforceableRefreshListener, SearchView.OnQueryTextListener {
         implements OnItemClickListener, OnEnforceableRefreshListener, SearchView.OnQueryTextListener {
 
 
@@ -179,6 +178,8 @@ public class ExtendedListFragment extends Fragment
             }
             }
         });
         });
 
 
+        LinearLayout searchBar = (LinearLayout) searchView.findViewById(R.id.search_bar);
+        searchBar.setLayoutTransition(new LayoutTransition());
     }
     }
 
 
     public boolean onQueryTextChange(final String query) {
     public boolean onQueryTextChange(final String query) {
@@ -381,6 +382,11 @@ public class ExtendedListFragment extends Fragment
 
 
     @Override
     @Override
     public void onRefresh() {
     public void onRefresh() {
+
+        if (searchView != null) {
+            searchView.onActionViewCollapsed();
+        }
+
         mRefreshListLayout.setRefreshing(false);
         mRefreshListLayout.setRefreshing(false);
         mRefreshGridLayout.setRefreshing(false);
         mRefreshGridLayout.setRefreshing(false);
         mRefreshEmptyLayout.setRefreshing(false);
         mRefreshEmptyLayout.setRefreshing(false);
@@ -389,6 +395,7 @@ public class ExtendedListFragment extends Fragment
             mOnRefreshListener.onRefresh();
             mOnRefreshListener.onRefresh();
         }
         }
     }
     }
+
     public void setOnRefreshListener(OnEnforceableRefreshListener listener) {
     public void setOnRefreshListener(OnEnforceableRefreshListener listener) {
         mOnRefreshListener = listener;
         mOnRefreshListener = listener;
     }
     }
@@ -489,7 +496,6 @@ public class ExtendedListFragment extends Fragment
     protected void onCreateSwipeToRefresh(SwipeRefreshLayout refreshLayout) {
     protected void onCreateSwipeToRefresh(SwipeRefreshLayout refreshLayout) {
         // Colors in animations
         // Colors in animations
         refreshLayout.setColorSchemeResources(R.color.color_accent, R.color.primary, R.color.primary_dark);
         refreshLayout.setColorSchemeResources(R.color.color_accent, R.color.primary, R.color.primary_dark);
-
         refreshLayout.setOnRefreshListener(this);
         refreshLayout.setOnRefreshListener(this);
     }
     }