|
51 | 51 | import android.widget.TextView;
|
52 | 52 |
|
53 | 53 | import org.dmfs.android.bolts.color.colors.ValueColor;
|
| 54 | + |
| 55 | +import org.dmfs.android.contentpal.RowDataSnapshot; |
| 56 | + |
54 | 57 | import org.dmfs.android.retentionmagic.SupportFragment;
|
55 | 58 | import org.dmfs.android.retentionmagic.annotations.Parameter;
|
56 | 59 | import org.dmfs.android.retentionmagic.annotations.Retain;
|
| 60 | +import org.dmfs.tasks.contract.TaskContract; |
57 | 61 | import org.dmfs.tasks.contract.TaskContract.Tasks;
|
| 62 | +import org.dmfs.tasks.data.SubtasksSource; |
58 | 63 | import org.dmfs.tasks.model.ContentSet;
|
59 | 64 | import org.dmfs.tasks.model.Model;
|
60 | 65 | import org.dmfs.tasks.model.OnContentChangeListener;
|
|
63 | 68 | import org.dmfs.tasks.notification.TaskNotificationHandler;
|
64 | 69 | import org.dmfs.tasks.share.ShareIntentFactory;
|
65 | 70 | import org.dmfs.tasks.utils.ContentValueMapper;
|
| 71 | +import org.dmfs.tasks.utils.Darkened; |
66 | 72 | import org.dmfs.tasks.utils.OnModelLoadedListener;
|
| 73 | +import org.dmfs.tasks.widget.SubtasksView; |
67 | 74 | import org.dmfs.tasks.widget.TaskView;
|
68 | 75 |
|
69 | 76 | import java.util.Arrays;
|
70 | 77 | import java.util.HashSet;
|
71 | 78 | import java.util.Set;
|
72 | 79 |
|
| 80 | +import io.reactivex.disposables.CompositeDisposable; |
| 81 | +import io.reactivex.functions.Consumer; |
| 82 | + |
73 | 83 |
|
74 | 84 | /**
|
75 | 85 | * A fragment representing a single Task detail screen. This fragment is either contained in a {@link TaskListActivity} in two-pane mode (on tablets) or in a
|
@@ -130,6 +140,8 @@ public class ViewTaskFragment extends SupportFragment
|
130 | 140 | */
|
131 | 141 | private TaskView mDetailView;
|
132 | 142 |
|
| 143 | + private CompositeDisposable mDisposables; |
| 144 | + |
133 | 145 | private int mListColor;
|
134 | 146 | private int mOldStatus = -1;
|
135 | 147 | private boolean mPinned = false;
|
@@ -207,14 +219,6 @@ public static ViewTaskFragment newInstance(Uri uri)
|
207 | 219 | }
|
208 | 220 |
|
209 | 221 |
|
210 |
| - /** |
211 |
| - * Mandatory empty constructor for the fragment manager to instantiate the fragment (e.g. upon screen orientation changes). |
212 |
| - */ |
213 |
| - public ViewTaskFragment() |
214 |
| - { |
215 |
| - } |
216 |
| - |
217 |
| - |
218 | 222 | @Override
|
219 | 223 | public void onCreate(Bundle savedInstanceState)
|
220 | 224 | {
|
@@ -265,6 +269,7 @@ public void onDestroyView()
|
265 | 269 | mDetailView.setValues(null);
|
266 | 270 | }
|
267 | 271 |
|
| 272 | + mDisposables.dispose(); |
268 | 273 | }
|
269 | 274 |
|
270 | 275 |
|
@@ -319,6 +324,8 @@ else if (mTaskUri != null)
|
319 | 324 | loadUri(uri);
|
320 | 325 | }
|
321 | 326 |
|
| 327 | + mDisposables = new CompositeDisposable(); |
| 328 | + |
322 | 329 | return mRootView;
|
323 | 330 | }
|
324 | 331 |
|
@@ -400,6 +407,7 @@ public void loadUri(Uri uri)
|
400 | 407 | if ((oldUri == null) != (uri == null))
|
401 | 408 | {
|
402 | 409 | /*
|
| 410 | +
|
403 | 411 | * getActivity().invalidateOptionsMenu() doesn't work in Android 2.x so use the compat lib
|
404 | 412 | */
|
405 | 413 | ActivityCompat.invalidateOptionsMenu(getActivity());
|
@@ -715,6 +723,23 @@ public void onContentLoaded(ContentSet contentSet)
|
715 | 723 | postUpdateView();
|
716 | 724 | }
|
717 | 725 | }
|
| 726 | + |
| 727 | + mDisposables.add( |
| 728 | + new SubtasksSource(mAppContext, mTaskUri) |
| 729 | + .subscribe(new Consumer<Iterable<RowDataSnapshot<TaskContract.Tasks>>>() |
| 730 | + { |
| 731 | + @Override |
| 732 | + public void accept(Iterable<RowDataSnapshot<TaskContract.Tasks>> subTasks) |
| 733 | + { |
| 734 | + if (subTasks.iterator().hasNext()) |
| 735 | + { |
| 736 | + new SubtasksView(mContent).update(subTasks); |
| 737 | + ((TextView) mContent.findViewById(R.id.opentasks_view_item_task_details_subtitles_section_header)) |
| 738 | + .setTextColor(new Darkened(mListColor).argb()); |
| 739 | + mContent.requestLayout(); |
| 740 | + } |
| 741 | + } |
| 742 | + })); |
718 | 743 | }
|
719 | 744 |
|
720 | 745 |
|
|
0 commit comments