Merge "Remove dependencies on Activity from common Fragment superclasses" into nyc-dev
am: d2285b1
* commit 'd2285b1f40a714a49602dab5645c194af0eac880':
Remove dependencies on Activity from common Fragment superclasses
Change-Id: Ic0da5094cae15e03f139eae6ed2760a6cd126e0c
This commit is contained in:
@@ -361,8 +361,8 @@ public class DialogFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(activity);
|
super.onAttach(context);
|
||||||
if (!mShownByMe) {
|
if (!mShownByMe) {
|
||||||
// If not explicitly shown through our API, take this as an
|
// If not explicitly shown through our API, take this as an
|
||||||
// indication that the dialog is no longer dismissed.
|
// indication that the dialog is no longer dismissed.
|
||||||
@@ -394,7 +394,6 @@ public class DialogFragment extends Fragment
|
|||||||
mShowsDialog = savedInstanceState.getBoolean(SAVED_SHOWS_DIALOG, mShowsDialog);
|
mShowsDialog = savedInstanceState.getBoolean(SAVED_SHOWS_DIALOG, mShowsDialog);
|
||||||
mBackStackId = savedInstanceState.getInt(SAVED_BACK_STACK_ID, -1);
|
mBackStackId = savedInstanceState.getInt(SAVED_BACK_STACK_ID, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -473,11 +472,15 @@ public class DialogFragment extends Fragment
|
|||||||
View view = getView();
|
View view = getView();
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
if (view.getParent() != null) {
|
if (view.getParent() != null) {
|
||||||
throw new IllegalStateException("DialogFragment can not be attached to a container view");
|
throw new IllegalStateException(
|
||||||
|
"DialogFragment can not be attached to a container view");
|
||||||
}
|
}
|
||||||
mDialog.setContentView(view);
|
mDialog.setContentView(view);
|
||||||
}
|
}
|
||||||
mDialog.setOwnerActivity(getActivity());
|
final Activity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
mDialog.setOwnerActivity(activity);
|
||||||
|
}
|
||||||
mDialog.setCancelable(mCancelable);
|
mDialog.setCancelable(mCancelable);
|
||||||
if (!mDialog.takeCancelAndDismissListeners("DialogFragment", this, this)) {
|
if (!mDialog.takeCancelAndDismissListeners("DialogFragment", this, this)) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ public class ListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the activity's list view widget.
|
* Get the fragment's list view widget.
|
||||||
*/
|
*/
|
||||||
public ListView getListView() {
|
public ListView getListView() {
|
||||||
ensureList();
|
ensureList();
|
||||||
@@ -346,9 +346,9 @@ public class ListFragment extends Fragment {
|
|||||||
if (shown) {
|
if (shown) {
|
||||||
if (animate) {
|
if (animate) {
|
||||||
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
getActivity(), android.R.anim.fade_out));
|
getContext(), android.R.anim.fade_out));
|
||||||
mListContainer.startAnimation(AnimationUtils.loadAnimation(
|
mListContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
getActivity(), android.R.anim.fade_in));
|
getContext(), android.R.anim.fade_in));
|
||||||
} else {
|
} else {
|
||||||
mProgressContainer.clearAnimation();
|
mProgressContainer.clearAnimation();
|
||||||
mListContainer.clearAnimation();
|
mListContainer.clearAnimation();
|
||||||
@@ -358,9 +358,9 @@ public class ListFragment extends Fragment {
|
|||||||
} else {
|
} else {
|
||||||
if (animate) {
|
if (animate) {
|
||||||
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
getActivity(), android.R.anim.fade_in));
|
getContext(), android.R.anim.fade_in));
|
||||||
mListContainer.startAnimation(AnimationUtils.loadAnimation(
|
mListContainer.startAnimation(AnimationUtils.loadAnimation(
|
||||||
getActivity(), android.R.anim.fade_out));
|
getContext(), android.R.anim.fade_out));
|
||||||
} else {
|
} else {
|
||||||
mProgressContainer.clearAnimation();
|
mProgressContainer.clearAnimation();
|
||||||
mListContainer.clearAnimation();
|
mListContainer.clearAnimation();
|
||||||
@@ -371,7 +371,7 @@ public class ListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ListAdapter associated with this activity's ListView.
|
* Get the ListAdapter associated with this fragment's ListView.
|
||||||
*/
|
*/
|
||||||
public ListAdapter getListAdapter() {
|
public ListAdapter getListAdapter() {
|
||||||
return mAdapter;
|
return mAdapter;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class WebViewFragment extends Fragment {
|
|||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
mWebView.destroy();
|
mWebView.destroy();
|
||||||
}
|
}
|
||||||
mWebView = new WebView(getActivity());
|
mWebView = new WebView(getContext());
|
||||||
mIsWebViewAvailable = true;
|
mIsWebViewAvailable = true;
|
||||||
return mWebView;
|
return mWebView;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,6 @@ public class MediaRouteControllerDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
return onCreateControllerDialog(getActivity(), savedInstanceState);
|
return onCreateControllerDialog(getContext(), savedInstanceState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user