Rotation During Compression

82 views
Skip to first unread message

Ayush Verma

unread,
Mar 26, 2013, 2:40:18 AM3/26/13
to openi...@googlegroups.com
Hello !

I have fixed the rotation problem during compression.
Now we can freely rotate our device without worrying about application crash.
The basic idea is to use retained fragments.

The main changes are-
  1. CompressManager now extends DialogFragment (this is the fragment to be retained). ProgressDialog for compression has been moved out of CompressTask to CompressManager.
  2. OnCompressFinishedListener is now present in CompressManager's onCreate rather than in Single and Multi CompressDialogs.
  3. Target fragment of CompressManager is SimpleFileListFragment. In its onCreate we perform a check for retained fragments using FragmentManager.
  4. SimpleFileListFragment also has a CallBack mechanism to get easy callbacks to the activity. The Toast after compression is displayed using this callback mechanism.

The Files Changed are-

  1. CompressManager.java
  2. SingleCompressDialog.java
  3. MultiCompressDialog.java
  4. SimpleFileListFragment.java
  5. FileManagerActivity.java
I got the idea using this Link.

The code can be viewed Here.

Cheers.

George Venios

unread,
Mar 29, 2013, 4:24:09 AM3/29/13
to openi...@googlegroups.com
Hey,

The concept of the compression manager is that it is a central component that handles all compression tasks (think of it kind of like a singleton).
By making it a fragment (essentially a view/controller component) you tie it to navigation and application lifecycle constraints.
A solution that would be much cleaner both in code and design would be to make the compression manager a Service and have the compression dialog fragments bind to it to provide asynchronous task progress updates and controlling.

Hope this helps,
George.

George Venios

unread,
Mar 29, 2013, 4:34:43 AM3/29/13
to openi...@googlegroups.com
I just had a look at the compression manager and have to admit I was wrong in mentioning that it acted like a singleton. It certainly gets instantiated once for each compression dialog. Sorry about the misunderstanding.

That being said, the reasons stated above are still valid and I strongly suggest that it becomes a Service that handles all compression tasks.

Ayush Verma

unread,
Mar 30, 2013, 3:30:30 AM3/30/13
to openi...@googlegroups.com
That is certainly a valid point. I'll look into it.


Reply all
Reply to author
Forward
0 new messages