X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/1ecd2b61c5956f7e21ee85d5658f4bc83032656f..9aab2d26da38f26e7ff03a0b5db3bd01b51bce05:/src/com/owncloud/android/ui/FragmentListView.java diff --git a/src/com/owncloud/android/ui/FragmentListView.java b/src/com/owncloud/android/ui/FragmentListView.java index 4165afa8..3dbe16da 100644 --- a/src/com/owncloud/android/ui/FragmentListView.java +++ b/src/com/owncloud/android/ui/FragmentListView.java @@ -1,6 +1,26 @@ +/* ownCloud Android client application + * Copyright (C) 2012 Bartek Przybylski + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.ui; import com.actionbarsherlock.app.SherlockFragment; +import com.owncloud.android.R; +import com.owncloud.android.ui.fragment.LocalFileListFragment; import android.os.Bundle; import android.view.LayoutInflater; @@ -9,12 +29,12 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListAdapter; -import android.widget.ListView; import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListView; public class FragmentListView extends SherlockFragment implements OnItemClickListener, OnItemLongClickListener { - protected ListView mList; + protected ExtendedListView mList; @Override public void onCreate(Bundle savedInstanceState) { @@ -29,15 +49,19 @@ public class FragmentListView extends SherlockFragment implements public ListView getListView() { return mList; } - + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - mList = new ListView(getActivity()); + //mList = new ExtendedListView(getActivity()); + View v = inflater.inflate(R.layout.list_fragment, null); + mList = (ExtendedListView)(v.findViewById(R.id.list_root)); mList.setOnItemClickListener(this); mList.setOnItemLongClickListener(this); - return mList; - // return super.onCreateView(inflater, container, savedInstanceState); + //mList.setEmptyView(v.findViewById(R.id.empty_list_view)); // looks like it's not a cool idea + mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator)); + mList.setDividerHeight(1); + return v; } public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { @@ -49,4 +73,28 @@ public class FragmentListView extends SherlockFragment implements return false; } + + /** + * Calculates the position of the item that will be used as a reference to reposition the visible items in the list when + * the device is turned to other position. + * + * THe current policy is take as a reference the visible item in the center of the screen. + * + * @return The position in the list of the visible item in the center of the screen. + */ + protected int getReferencePosition() { + return (mList.getFirstVisiblePosition() + mList.getLastVisiblePosition()) / 2; + } + + + /** + * Sets the visible part of the list from the reference position. + * + * @param position Reference position previously returned by {@link LocalFileListFragment#getReferencePosition()} + */ + protected void setReferencePosition(int position) { + mList.setAndCenterSelection(position); + } + + }