diff options
author | calderwoodra <calderwoodra@google.com> | 2018-02-02 12:22:13 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-02 14:17:44 -0800 |
commit | 3a398a5adf0feae1f6dafe629a6c7cc4a0a968b4 (patch) | |
tree | 28107d07ea8259a86bd32b1e8d550daad35bfac1 /java/com/android/dialer/common | |
parent | 7e5da60e990e153c8fd5ba4e146825bb8e9a2bd4 (diff) |
Split MainActivity into two peers, old and new to keep logic isolated.
This change updates MainActivity to defer lifecycle callbacks and other
relevant methods to which ever peer is active, old or new.
The old peer implements the logic for the old fragments.
The new peer implements the logic for the new fragments.
MainActivity implements the logic that is shared or common between the two like
last tab, post call, search, dialpad, ect.
Bug: 72525324
Test: pending
PiperOrigin-RevId: 184317828
Change-Id: Ie73733f2a3837c9d63e54cf5b142984633340731
Diffstat (limited to 'java/com/android/dialer/common')
-rw-r--r-- | java/com/android/dialer/common/FragmentUtils.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/java/com/android/dialer/common/FragmentUtils.java b/java/com/android/dialer/common/FragmentUtils.java index 947a9b20a..c07d9a799 100644 --- a/java/com/android/dialer/common/FragmentUtils.java +++ b/java/com/android/dialer/common/FragmentUtils.java @@ -21,6 +21,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v4.app.Fragment; +import com.android.dialer.main.MainActivityPeer; /** Utility methods for working with Fragments */ public class FragmentUtils { @@ -89,6 +90,11 @@ public class FragmentUtils { @SuppressWarnings("unchecked") // Casts are checked using runtime methods T parent = ((FragmentUtilListener) fragment.getActivity()).getImpl(callbackInterface); return parent; + } else if (fragment.getActivity() instanceof MainActivityPeer.PeerSupplier) { + MainActivityPeer peer = ((MainActivityPeer.PeerSupplier) fragment.getActivity()).getPeer(); + if (peer instanceof FragmentUtilListener) { + return ((FragmentUtilListener) peer).getImpl(callbackInterface); + } } return null; } |