1 package com
.owncloud
.android
.ui
;
3 import com
.actionbarsherlock
.app
.SherlockFragment
;
4 import com
.owncloud
.android
.R
;
5 import com
.owncloud
.android
.ui
.fragment
.LocalFileListFragment
;
7 import android
.os
.Bundle
;
8 import android
.view
.LayoutInflater
;
9 import android
.view
.View
;
10 import android
.view
.ViewGroup
;
11 import android
.widget
.AdapterView
;
12 import android
.widget
.AdapterView
.OnItemLongClickListener
;
13 import android
.widget
.ListAdapter
;
14 import android
.widget
.AdapterView
.OnItemClickListener
;
15 import android
.widget
.ListView
;
17 public class FragmentListView
extends SherlockFragment
implements
18 OnItemClickListener
, OnItemLongClickListener
{
19 protected ExtendedListView mList
;
22 public void onCreate(Bundle savedInstanceState
) {
23 super.onCreate(savedInstanceState
);
26 public void setListAdapter(ListAdapter listAdapter
) {
27 mList
.setAdapter(listAdapter
);
31 public ListView
getListView() {
36 public View
onCreateView(LayoutInflater inflater
, ViewGroup container
,
37 Bundle savedInstanceState
) {
38 //mList = new ExtendedListView(getActivity());
39 View v
= inflater
.inflate(R
.layout
.list_fragment
, null
);
40 mList
= (ExtendedListView
)(v
.findViewById(R
.id
.list_root
));
41 mList
.setOnItemClickListener(this);
42 mList
.setOnItemLongClickListener(this);
43 mList
.setEmptyView(v
.findViewById(R
.id
.empty_list_view
));
44 mList
.setDivider(getResources().getDrawable(R
.drawable
.uploader_list_separator
));
45 mList
.setDividerHeight(1);
49 public void onItemClick(AdapterView
<?
> arg0
, View arg1
, int arg2
, long arg3
) {
53 public boolean onItemLongClick(AdapterView
<?
> arg0
, View arg1
, int arg2
,
60 * Calculates the position of the item that will be used as a reference to reposition the visible items in the list when
61 * the device is turned to other position.
63 * THe current policy is take as a reference the visible item in the center of the screen.
65 * @return The position in the list of the visible item in the center of the screen.
67 protected int getReferencePosition() {
68 return (mList
.getFirstVisiblePosition() + mList
.getLastVisiblePosition()) / 2;
73 * Sets the visible part of the list from the reference position.
75 * @param position Reference position previously returned by {@link LocalFileListFragment#getReferencePosition()}
77 protected void setReferencePosition(int position
) {
78 mList
.setAndCenterSelection(position
);