diff options
author | Yorke Lee <yorkelee@google.com> | 2014-06-25 12:09:11 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-06-25 12:09:11 -0700 |
commit | 208071f50f93cd4968161c3ecfbb505f71c63934 (patch) | |
tree | 0d1b3fd94b9aea5c6d9b98edc489e0f5ea6fc0fe /InCallUI/src/com/android/incallui/InCallActivity.java | |
parent | 7daf9d15a1ad2853306c0023be3d7f1f1d9212bb (diff) |
Fix NPE when referencing child fragments
Child fragments are now added to the parent fragment's
fragment manager due to a change in framework behavior (ag/489316).
As a result we now need to use the child fragment manager to obtain
references to child fragments.
Bug: 15872707
Change-Id: I351cfbee780129448c1a748716a3c4895fca67e7
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallActivity.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 8c7cc649b..4e6bc5009 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -18,6 +18,7 @@ package com.android.incallui; import android.app.Activity; import android.app.AlertDialog; +import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -54,6 +55,8 @@ public class InCallActivity extends Activity { private AnswerFragment mAnswerFragment; private DialpadFragment mDialpadFragment; private ConferenceManagerFragment mConferenceManagerFragment; + private FragmentManager mChildFragmentManager; + private boolean mIsForegroundActivity; private AlertDialog mDialog; @@ -403,26 +406,28 @@ public class InCallActivity extends Activity { } private void initializeInCall() { - if (mCallButtonFragment == null) { - mCallButtonFragment = (CallButtonFragment) getFragmentManager() - .findFragmentById(R.id.callButtonFragment); - mCallButtonFragment.getView().setVisibility(View.INVISIBLE); - } - if (mCallCardFragment == null) { mCallCardFragment = (CallCardFragment) getFragmentManager() .findFragmentById(R.id.callCardFragment); } + mChildFragmentManager = mCallCardFragment.getChildFragmentManager(); + + if (mCallButtonFragment == null) { + mCallButtonFragment = (CallButtonFragment) mChildFragmentManager + .findFragmentById(R.id.callButtonFragment); + mCallButtonFragment.getView().setVisibility(View.INVISIBLE); + } + if (mAnswerFragment == null) { - mAnswerFragment = (AnswerFragment) getFragmentManager() + mAnswerFragment = (AnswerFragment) mChildFragmentManager .findFragmentById(R.id.answerFragment); } if (mDialpadFragment == null) { - mDialpadFragment = (DialpadFragment) getFragmentManager() + mDialpadFragment = (DialpadFragment) mChildFragmentManager .findFragmentById(R.id.dialpadFragment); - getFragmentManager().beginTransaction().hide(mDialpadFragment).commit(); + mChildFragmentManager.beginTransaction().hide(mDialpadFragment).commit(); } if (mConferenceManagerFragment == null) { @@ -432,12 +437,6 @@ public class InCallActivity extends Activity { } } - private void toast(String text) { - final Toast toast = Toast.makeText(this, text, Toast.LENGTH_SHORT); - - toast.show(); - } - /** * Simulates a user click to hide the dialpad. This will update the UI to show the call card, * update the checked state of the dialpad button, and update the proximity sensor state. @@ -455,7 +454,7 @@ public class InCallActivity extends Activity { } private void showDialpad(boolean showDialpad) { - final FragmentTransaction ft = getFragmentManager().beginTransaction(); + final FragmentTransaction ft = mChildFragmentManager.beginTransaction(); if (showDialpad) { ft.show(mDialpadFragment); } else { |