From: masensio Date: Thu, 29 May 2014 15:07:16 +0000 (+0200) Subject: Select the animation for the SwipeRefreshLayout X-Git-Tag: oc-android-1.7.0_signed~292^2~8 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/6451222f8d7297bc9136daf7d6b38112e7784347?ds=inline;hp=--cc Select the animation for the SwipeRefreshLayout --- 6451222f8d7297bc9136daf7d6b38112e7784347 diff --git a/res/layout/list_fragment.xml b/res/layout/list_fragment.xml index 8c578b79..c5dbef12 100644 --- a/res/layout/list_fragment.xml +++ b/res/layout/list_fragment.xml @@ -24,7 +24,7 @@ android:orientation="vertical" > diff --git a/res/values/setup.xml b/res/values/setup.xml index 932612ea..097ff48c 100644 --- a/res/values/setup.xml +++ b/res/values/setup.xml @@ -32,6 +32,11 @@ #1D2D44 #1D2D44 + #00ddff + #1D2D44 + #FFFFFF + #00ddff + #000000 diff --git a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 409c5e61..915e455f 100644 --- a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -25,6 +25,7 @@ import com.owncloud.android.utils.Log_OC; import android.os.Bundle; +import android.support.v4.widget.SwipeRefreshLayout; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,7 +37,7 @@ import android.widget.ListView; /** * TODO extending SherlockListFragment instead of SherlockFragment */ -public class ExtendedListFragment extends SherlockFragment implements OnItemClickListener { +public class ExtendedListFragment extends SherlockFragment implements OnItemClickListener, SwipeRefreshLayout.OnRefreshListener{ private static final String TAG = ExtendedListFragment.class.getSimpleName(); @@ -44,6 +45,8 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic protected ExtendedListView mList; + private SwipeRefreshLayout mRefreshLayout; + public void setListAdapter(ListAdapter listAdapter) { mList.setAdapter(listAdapter); mList.invalidate(); @@ -58,6 +61,7 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.e(TAG, "onCreateView"); //mList = new ExtendedListView(getActivity()); + View v = inflater.inflate(R.layout.list_fragment, null); mList = (ExtendedListView)(v.findViewById(R.id.list_root)); mList.setOnItemClickListener(this); @@ -70,6 +74,14 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic setReferencePosition(referencePosition); } + // Pull down refresh + mRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files); + mRefreshLayout.setColorScheme(R.color.refresh_color_start, + R.color.refresh_color_middle_1, + R.color.refresh_color_middle_2, + R.color.refresh_color_end); + mRefreshLayout.setOnRefreshListener(this); + return v; } @@ -115,5 +127,26 @@ public class ExtendedListFragment extends SherlockFragment implements OnItemClic // to be @overriden } + @Override + public void onRefresh() { + // to be @overriden + + } + + /** + * Enables swipe gesture + */ + public void enableSwipe() { + mRefreshLayout.setEnabled(true); + } + + /** + * Disables swipe gesture. It prevents manual gestures but keeps the option you show + * refreshing programmatically. + */ + public void disableSwipe() { + mRefreshLayout.setEnabled(false); + } + } diff --git a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java index 270a8d5c..bc466016 100644 --- a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java @@ -77,6 +77,7 @@ public class LocalFileListFragment extends ExtendedListFragment { Log_OC.i(TAG, "onCreateView() start"); View v = super.onCreateView(inflater, container, savedInstanceState); getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); + disableSwipe(); // Disable pull refresh Log_OC.i(TAG, "onCreateView() end"); return v; } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index a3bd3c2c..6b7d30a0 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -35,6 +35,7 @@ import com.owncloud.android.utils.Log_OC; import android.app.Activity; import android.os.Bundle; +import android.support.v4.widget.SwipeRefreshLayout; import android.view.ContextMenu; import android.view.MenuInflater; import android.view.MenuItem; @@ -106,6 +107,7 @@ public class OCFileListFragment extends ExtendedListFragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log_OC.e(TAG, "onActivityCreated() start"); + mAdapter = new FileListListAdapter(getSherlockActivity(), mContainerActivity); if (savedInstanceState != null) {