Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'android/3rd_party/HoloEverywhere/library/src/android/support/v4/app/_HoloFragmentInflater.java')
-rw-r--r--android/3rd_party/HoloEverywhere/library/src/android/support/v4/app/_HoloFragmentInflater.java119
1 files changed, 119 insertions, 0 deletions
diff --git a/android/3rd_party/HoloEverywhere/library/src/android/support/v4/app/_HoloFragmentInflater.java b/android/3rd_party/HoloEverywhere/library/src/android/support/v4/app/_HoloFragmentInflater.java
new file mode 100644
index 0000000000..2b9dbe84bd
--- /dev/null
+++ b/android/3rd_party/HoloEverywhere/library/src/android/support/v4/app/_HoloFragmentInflater.java
@@ -0,0 +1,119 @@
+
+package android.support.v4.app;
+
+import org.holoeverywhere.LayoutInflater;
+
+import android.content.Context;
+import android.content.ContextWrapper;
+import android.content.res.TypedArray;
+import android.support.v4.app.FragmentActivity.FragmentTag;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class _HoloFragmentInflater {
+ private static View inflate(AttributeSet attrs, View parent, FragmentActivity activity,
+ Fragment parentFragment) {
+ String fname = attrs.getAttributeValue(null, "class");
+ TypedArray a = activity.obtainStyledAttributes(attrs, FragmentTag.Fragment);
+ if (fname == null) {
+ fname = a.getString(FragmentTag.Fragment_name);
+ }
+ if (fname.startsWith(".")) {
+ fname = activity.getPackageName() + fname;
+ }
+ int id = a.getResourceId(FragmentTag.Fragment_id, View.NO_ID);
+ String tag = a.getString(FragmentTag.Fragment_tag);
+ a.recycle();
+ int containerId = parent != null ? parent.getId() : 0;
+ if (containerId == View.NO_ID && id == View.NO_ID && tag == null) {
+ throw new IllegalArgumentException(
+ attrs.getPositionDescription()
+ + ": Must specify unique android:id, android:tag, or have a parent with an id for "
+ + fname);
+ }
+ final FragmentManagerImpl fm = obtainFragmentManager(activity, parentFragment);
+ Fragment fragment = id != View.NO_ID ? fm.findFragmentById(id) : null;
+ if (fragment == null && tag != null) {
+ fragment = fm.findFragmentByTag(tag);
+ }
+ if (fragment == null && containerId != View.NO_ID) {
+ fragment = fm.findFragmentById(containerId);
+ }
+ if (fragment == null) {
+ fragment = Fragment.instantiate(activity, fname);
+ fragment.mParentFragment = parentFragment;
+ fragment.mFromLayout = true;
+ fragment.mFragmentId = id != 0 ? id : containerId;
+ fragment.mContainer = (ViewGroup) parent;
+ fragment.mContainerId = containerId;
+ fragment.mTag = tag;
+ fragment.mInLayout = true;
+ fragment.mFragmentManager = fm;
+ fragment.onInflate(activity, attrs, fragment.mSavedFragmentState);
+ fm.addFragment(fragment, false);
+ fm.moveToState(fragment, Fragment.CREATED, 0, 0, false);
+ } else if (fragment.mInLayout) {
+ throw new IllegalArgumentException(attrs.getPositionDescription()
+ + ": Duplicate id 0x" + Integer.toHexString(id)
+ + ", tag " + tag + ", or parent id 0x" + Integer.toHexString(containerId)
+ + " with another fragment for " + fname);
+ } else {
+ fragment.mInLayout = true;
+ if (!fragment.mRetaining) {
+ fragment.onInflate(activity, attrs, fragment.mSavedFragmentState);
+ }
+ fm.moveToState(fragment, Fragment.CREATED, 0, 0, false);
+ }
+ if (fragment.mView == null) {
+ throw new IllegalStateException("Fragment " + fname
+ + " did not create a view.");
+ }
+ if (id != 0) {
+ fragment.mView.setId(id);
+ }
+ if (fragment.mView.getTag() == null) {
+ fragment.mView.setTag(tag);
+ }
+ return fragment.mView;
+ }
+
+ public static View inflate(LayoutInflater layoutInflater, AttributeSet attrs, View parent,
+ Fragment fragment) {
+ FragmentActivity activity = layoutInflater.getFragmentActivity();
+ if (activity != null) {
+ return inflate(attrs, parent, activity, fragment);
+ }
+ Context context = layoutInflater.getContext();
+ while (context instanceof ContextWrapper) {
+ if (context instanceof FragmentActivity) {
+ activity = (FragmentActivity) context;
+ break;
+ }
+ context = ((ContextWrapper) context).getBaseContext();
+ }
+ if (activity == null) {
+ throw new IllegalStateException("Cannot find any reference to FragmentActivity");
+ }
+ return inflate(attrs, parent, activity, fragment);
+ }
+
+ private static FragmentManagerImpl obtainFragmentManager(FragmentActivity activity,
+ Fragment fragment) {
+ FragmentManagerImpl fm = null;
+ if (fragment != null) {
+ fm = fragment.mChildFragmentManager;
+ if (fm == null) {
+ try {
+ fm = (FragmentManagerImpl) fragment.getChildFragmentManager();
+ } catch (ClassCastException e) {
+ fm = fragment.mChildFragmentManager;
+ }
+ }
+ }
+ if (fm == null && activity != null) {
+ fm = activity.mFragments;
+ }
+ return fm;
+ }
+}