private String[] mDirs = null;\r
\r
private SyncBroadcastReceiver syncBroadcastRevceiver;\r
-\r
+ \r
+ private View mLayoutView = null;\r
+ \r
private static final String KEY_DIR_ARRAY = "DIR_ARRAY";\r
private static final String KEY_CURRENT_DIR = "DIR";\r
\r
if(savedInstanceState != null){\r
mCurrentDir = (OCFile) savedInstanceState.getParcelable(KEY_CURRENT_DIR);\r
}\r
+ \r
+ if (findViewById(R.id.file_list_view) == null) \r
+ mLayoutView = getLayoutInflater().inflate(R.layout.files, null); // always inflate this at onCreate() ; just once!\r
+ \r
+ //TODO: Dialog useless -> get rid of this\r
+ if (!accountsAreSetup()) {\r
+ setContentView(R.layout.no_account_available);\r
+ setProgressBarIndeterminateVisibility(false);\r
+ getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE);\r
+ findViewById(R.id.setup_account).setOnClickListener(this);\r
+ \r
+ } else if (findViewById(R.id.file_list_view) == null) {\r
+ setContentView(mLayoutView);\r
+ }\r
+ \r
}\r
\r
@Override\r
protected void onResume() {\r
super.onResume();\r
\r
- //TODO: Dialog useless -> get rid of this\r
- if (!accountsAreSetup()) {\r
- setContentView(R.layout.no_account_available);\r
- setProgressBarIndeterminateVisibility(false);\r
- getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE);\r
- findViewById(R.id.setup_account).setOnClickListener(this);\r
- return;\r
- } else if (findViewById(R.id.file_list_view) == null) {\r
- setContentView(R.layout.files);\r
- }\r
+ if (accountsAreSetup()) {\r
+ \r
+ setContentView(mLayoutView); // this should solve the crash by repeated inflating in big screens (DROIDCLOUD-27)\r
\r
- // Listen for sync messages\r
- IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE);\r
- syncBroadcastRevceiver = new SyncBroadcastReceiver();\r
- registerReceiver(syncBroadcastRevceiver, syncIntentFilter);\r
+ // Listen for sync messages\r
+ IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE);\r
+ syncBroadcastRevceiver = new SyncBroadcastReceiver();\r
+ registerReceiver(syncBroadcastRevceiver, syncIntentFilter);\r
\r
- // Storage manager initialization\r
- mStorageManager = new FileDataStorageManager(\r
- AccountUtils.getCurrentOwnCloudAccount(this),\r
- getContentResolver());\r
+ // Storage manager initialization\r
+ mStorageManager = new FileDataStorageManager(\r
+ AccountUtils.getCurrentOwnCloudAccount(this),\r
+ getContentResolver());\r
\r
- // File list\r
- mFileList = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);\r
+ // File list\r
+ mFileList = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);\r
+ mFileList.updateAccount();\r
\r
- // Figure out what directory to list. \r
- // Priority: Intent (here), savedInstanceState (onCreate), root dir (dir is null)\r
- if(getIntent().hasExtra(FileDetailFragment.EXTRA_FILE)){\r
- mCurrentDir = (OCFile) getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
- if(!mCurrentDir.isDirectory()){\r
- mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());\r
- }\r
+ // Figure out what directory to list. \r
+ // Priority: Intent (here), savedInstanceState (onCreate), root dir (dir is null)\r
+ if(getIntent().hasExtra(FileDetailFragment.EXTRA_FILE)){\r
+ mCurrentDir = (OCFile) getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
+ if(!mCurrentDir.isDirectory()){\r
+ mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());\r
+ }\r
\r
- // Clear intent extra, so rotating the screen will not return us to this directory\r
- getIntent().removeExtra(FileDetailFragment.EXTRA_FILE);\r
- } else {\r
- mCurrentDir = mStorageManager.getFileByPath("/");\r
- }\r
+ // Clear intent extra, so rotating the screen will not return us to this directory\r
+ getIntent().removeExtra(FileDetailFragment.EXTRA_FILE);\r
+ } else {\r
+ mCurrentDir = mStorageManager.getFileByPath("/");\r
+ }\r
\r
- // Drop-Down navigation and file list restore\r
- mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
+ // Drop-Down navigation and file list restore\r
+ mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
\r
\r
- // Given the case we have a file to display:\r
- if(mCurrentDir != null){\r
- ArrayList<OCFile> files = new ArrayList<OCFile>();\r
- OCFile currFile = mCurrentDir;\r
- while(currFile != null){\r
- files.add(currFile);\r
- currFile = mStorageManager.getFileById(currFile.getParentId());\r
- }\r
+ // Given the case we have a file to display:\r
+ if(mCurrentDir != null){\r
+ ArrayList<OCFile> files = new ArrayList<OCFile>();\r
+ OCFile currFile = mCurrentDir;\r
+ while(currFile != null){\r
+ files.add(currFile);\r
+ currFile = mStorageManager.getFileById(currFile.getParentId());\r
+ }\r
\r
- // Insert in mDirs\r
- mDirs = new String[files.size()];\r
- for(int i = files.size() - 1; i >= 0; i--){\r
- mDirs[i] = files.get(i).getFileName();\r
+ // Insert in mDirs\r
+ mDirs = new String[files.size()];\r
+ for(int i = files.size() - 1; i >= 0; i--){\r
+ mDirs[i] = files.get(i).getFileName();\r
+ }\r
}\r
- }\r
\r
- if (mDirs != null) {\r
- for (String s : mDirs)\r
- mDirectories.add(s);\r
- } else {\r
- mDirectories.add("/");\r
- }\r
+ if (mDirs != null) {\r
+ for (String s : mDirs)\r
+ mDirectories.add(s);\r
+ } else {\r
+ mDirectories.add("/");\r
+ }\r
\r
- // Actionbar setup\r
- ActionBar action_bar = getSupportActionBar();\r
- action_bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);\r
- action_bar.setDisplayShowTitleEnabled(false);\r
- action_bar.setListNavigationCallbacks(mDirectories, this);\r
- if(mCurrentDir != null && mCurrentDir.getParentId() != 0){\r
- action_bar.setDisplayHomeAsUpEnabled(true);\r
- } else {\r
- action_bar.setDisplayHomeAsUpEnabled(false);\r
- }\r
+ // Actionbar setup\r
+ ActionBar action_bar = getSupportActionBar();\r
+ action_bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);\r
+ action_bar.setDisplayShowTitleEnabled(false);\r
+ action_bar.setListNavigationCallbacks(mDirectories, this);\r
+ if(mCurrentDir != null && mCurrentDir.getParentId() != 0){\r
+ action_bar.setDisplayHomeAsUpEnabled(true);\r
+ } else {\r
+ action_bar.setDisplayHomeAsUpEnabled(false);\r
+ }\r
\r
- // List dir here\r
- mFileList.listDirectory(mCurrentDir);\r
+ // List dir here\r
+ mFileList.listDirectory(mCurrentDir);\r
+ }\r
}\r
\r
@Override\r
import android.os.Bundle;\r
import android.support.v4.app.FragmentTransaction;\r
import android.util.Log;\r
+import android.view.LayoutInflater;\r
import android.view.View;\r
+import android.view.ViewGroup;\r
import android.widget.AdapterView;\r
import android.widget.Toast;\r
import eu.alefzero.owncloud.AccountUtils;\r
\r
mAccount = AccountUtils.getCurrentOwnCloudAccount(getActivity());\r
mStorageManager = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
- getListView().setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));\r
- getListView().setDividerHeight(1);\r
\r
Intent intent = getActivity().getIntent();\r
OCFile directory = intent.getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
mFile = directory;\r
- \r
- listDirectory(directory);\r
+ \r
}\r
+ \r
+ @Override\r
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
+ Bundle savedInstanceState) {\r
+ super.onCreateView(inflater, container, savedInstanceState);\r
+ getListView().setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));\r
+ getListView().setDividerHeight(1);\r
+ \r
+ //listDirectory(mFile);\r
+ \r
+ return getListView();\r
+ } \r
\r
@Override\r
public void onStart() {\r
outState.putParcelable("ACCOUNT", mAccount);\r
}\r
\r
+ /**\r
+ * This should be called every time the current account changes, in order to synchronize mStorageManager without create a new FileListFragment\r
+ */\r
+ public void updateAccount() {\r
+ Account old = mAccount;\r
+ mAccount = AccountUtils.getCurrentOwnCloudAccount(getActivity());\r
+ if (old != mAccount)\r
+ mStorageManager = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
+ // dvelasco : a better solution can be provided change the flow between states "wiht account" and "without account", in terms of interactions between AuthenticatorActivity and FileDisplayActivity\r
+ }\r
+\r
}\r