+
+
+ /**
+ * Public factory method to create a new fragment that shows the progress of a file download.
+ *
+ * Android strongly recommends keep the empty constructor of fragments as the only public constructor, and
+ * use {@link #setArguments(Bundle)} to set the needed arguments.
+ *
+ * This method hides to client objects the need of doing the construction in two steps.
+ *
+ * When 'file' is null creates a dummy layout (useful when a file wasn't tapped before).
+ *
+ * @param file An {@link OCFile} to show in the fragment
+ * @param account An OC account; needed to start downloads
+ * @param ignoreFirstSavedState Flag to work around an unexpected behaviour of {@link FragmentStatePagerAdapter}
+ * TODO better solution
+ */
+ public static Fragment newInstance(OCFile file, Account account, boolean ignoreFirstSavedState) {
+ FileDownloadFragment frag = new FileDownloadFragment();
+ Bundle args = new Bundle();
+ args.putParcelable(ARG_FILE, file);
+ args.putParcelable(ARG_ACCOUNT, account);
+ args.putBoolean(ARG_IGNORE_FIRST, ignoreFirstSavedState);
+ frag.setArguments(args);
+ return frag;
+ }
+