*/\r
package eu.alefzero.owncloud.ui.fragment;\r
\r
-import android.app.FragmentTransaction;\r
import android.content.BroadcastReceiver;\r
import android.content.Context;\r
import android.content.Intent;\r
\r
public static final String FILE = "FILE";\r
\r
- private Intent mIntent;\r
- //private View mView;\r
private DownloadFinishReceiver mDownloadFinishReceiver;\r
- private OCFile mFile;\r
-\r
+ private Intent mIntent;\r
private int mLayout;\r
- private boolean mEmptyLayout;\r
+ private View mView;\r
+ private OCFile mFile;\r
\r
/**\r
- * Default constructor. When inflated by android -> display empty layout\r
+ * Default constructor - contains real layout\r
*/\r
- public FileDetailFragment() {\r
- mLayout = R.layout.file_details_empty;\r
- mEmptyLayout = true;\r
+ public FileDetailFragment(){\r
+ mLayout = R.layout.file_details_fragment;\r
}\r
-\r
+ \r
/**\r
- * Custom construtor. Use with a {@link FragmentTransaction}. The intent has\r
- * to contain {@link FileDetailFragment#FILE} with an OCFile and also\r
- * {@link FileDownloader#EXTRA_ACCOUNT} with the account.\r
+ * Creates a dummy layout. For use if the user never has\r
+ * tapped on a file before\r
* \r
- * @param intent Intent with an account and a file in it for rendering\r
+ * @param useEmptyView If true, use empty layout\r
*/\r
- public FileDetailFragment(Intent intent) {\r
- mLayout = R.layout.file_details_fragment;\r
- mIntent = intent;\r
- mEmptyLayout = false;\r
+ public FileDetailFragment(boolean useEmptyView){\r
+ if(useEmptyView){\r
+ mLayout = R.layout.file_details_empty;\r
+ } else {\r
+ mLayout = R.layout.file_details_fragment;\r
+ }\r
}\r
-\r
+ \r
@Override\r
public void onResume() {\r
super.onResume();\r
downloadButton.setOnClickListener(this);\r
}\r
}\r
-\r
- @Override\r
- public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
- Bundle savedInstanceState) {\r
- View view = null;\r
- view = inflater.inflate(mLayout, container, false);\r
- return view;\r
- }\r
-\r
- @Override\r
- public void onStart() {\r
- super.onStart();\r
- \r
- // Fill in required information about file displaying\r
- if(mIntent == null){\r
- mIntent = getActivity().getIntent();\r
- }\r
- \r
- // Fill in the details if the layout is not empty\r
- if(!mEmptyLayout){\r
- updateFileDetails();\r
- }\r
- \r
- }\r
-\r
+ \r
private void setFilename(String filename) {\r
TextView tv = (TextView) getView().findViewById(R.id.fdFilename);\r
if (tv != null)\r
tv.setText(DisplayUtils.bitsToHumanReadable(filesize));\r
}\r
\r
- /**\r
- * Use this to check if the correct layout is loaded. When android\r
- * instanciates this class using the default constructor, the layout will be\r
- * empty.\r
- * \r
- * Once a user touches a file for the first time, you must instanciate a new\r
- * Fragment with the new FileDetailFragment(true) to inflate the actual\r
- * details\r
- * \r
- * @return If the layout is empty, this method will return true, otherwise\r
- * false\r
- */\r
- public boolean isEmptyLayout() {\r
- return mEmptyLayout;\r
+ @Override\r
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
+ Bundle savedInstanceState) {\r
+ View view = null;\r
+ view = inflater.inflate(mLayout, container, false);\r
+ mView = view;\r
+ if(mLayout == R.layout.file_details_fragment){\r
+ mIntent = getActivity().getIntent();\r
+ updateFileDetails();\r
+ }\r
+ \r
+ return view;\r
+ }\r
+ \r
+ \r
+\r
+ @Override\r
+ public View getView() {\r
+ return super.getView() == null ? mView : super.getView();\r
}\r
\r
@Override\r