当前位置: 首页>>代码示例>>Java>>正文


Java View.restoreHierarchyState方法代码示例

本文整理汇总了Java中android.view.View.restoreHierarchyState方法的典型用法代码示例。如果您正苦于以下问题:Java View.restoreHierarchyState方法的具体用法?Java View.restoreHierarchyState怎么用?Java View.restoreHierarchyState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.restoreHierarchyState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: restoreActionViewStates

import android.view.View; //导入方法依赖的package包/类
public void restoreActionViewStates(Bundle states) {
    if (states != null) {
        SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
        int itemCount = size();
        for (int i = 0; i < itemCount; i++) {
            MenuItem item = getItem(i);
            View v = MenuItemCompat.getActionView(item);
            if (!(v == null || v.getId() == -1)) {
                v.restoreHierarchyState(viewStates);
            }
            if (item.hasSubMenu()) {
                ((SubMenuBuilder) item.getSubMenu()).restoreActionViewStates(states);
            }
        }
        int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
        if (expandedId > 0) {
            MenuItem itemToExpand = findItem(expandedId);
            if (itemToExpand != null) {
                MenuItemCompat.expandActionView(itemToExpand);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:MenuBuilder.java

示例2: restoreActionViewStates

import android.view.View; //导入方法依赖的package包/类
public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
            getActionViewStatesKey());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) {
        //Fixes Issue #652 with sdk <= 2.3.6
        return;
    }

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:35,代码来源:MenuBuilder.java

示例3: restoreViewState

import android.view.View; //导入方法依赖的package包/类
private void restoreViewState(@NonNull View view) {
  if (viewState != null) {
    view.restoreHierarchyState(viewState.getSparseParcelableArray(KEY_VIEW_STATE_HIERARCHY));

    Bundle savedViewState = viewState.getBundle(KEY_VIEW_STATE_BUNDLE);
    if (savedViewState != null) {
      savedViewState.setClassLoader(getClass().getClassLoader());
      onRestoreViewState(view, savedViewState);
    }

    if (!lifecycleListeners.isEmpty()) {
      for (LifecycleListener listener : new ArrayList<>(lifecycleListeners)) {
        listener.onRestoreViewState(this, viewState);
      }
    }
  }
}
 
开发者ID:seven332,项目名称:Stage,代码行数:18,代码来源:Scene.java

示例4: restoreInstanceState

import android.view.View; //导入方法依赖的package包/类
public void restoreInstanceState(Bundle state) {
    Iterator i$;
    int checkedItem = state.getInt(STATE_CHECKED_ITEM, 0);
    if (checkedItem != 0) {
        this.mUpdateSuspended = true;
        i$ = this.mItems.iterator();
        while (i$.hasNext()) {
            NavigationMenuItem item = (NavigationMenuItem) i$.next();
            if (item instanceof NavigationMenuTextItem) {
                MenuItemImpl menuItem = ((NavigationMenuTextItem) item).getMenuItem();
                if (menuItem != null && menuItem.getItemId() == checkedItem) {
                    setCheckedItem(menuItem);
                    break;
                }
            }
        }
        this.mUpdateSuspended = false;
        prepareMenuItems();
    }
    SparseArray<ParcelableSparseArray> actionViewStates = state.getSparseParcelableArray(STATE_ACTION_VIEWS);
    i$ = this.mItems.iterator();
    while (i$.hasNext()) {
        NavigationMenuItem navigationMenuItem = (NavigationMenuItem) i$.next();
        if (navigationMenuItem instanceof NavigationMenuTextItem) {
            MenuItemImpl item2 = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
            View actionView = item2 != null ? item2.getActionView() : null;
            if (actionView != null) {
                actionView.restoreHierarchyState((SparseArray) actionViewStates.get(item2.getItemId()));
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:NavigationMenuPresenter.java

示例5: applyDecorator

import android.view.View; //导入方法依赖的package包/类
/**
 * The method, which is invoked by a {@link TabSwitcher} to apply the decorator. It initializes
 * the view holder pattern, which is provided by the decorator and then delegates the method
 * call to the decorator's custom implementation of the method <code>onShowTab(...):void</code>.
 *
 * @param context
 *         The context, the tab switcher belongs to, as an instance of the class {@link
 *         Context}. The context may not be null
 * @param tabSwitcher
 *         The tab switcher, whose tabs are visualized by the decorator, as an instance of the
 *         class {@link TabSwitcher}. The tab switcher may not be null
 * @param view
 *         The view, which is used to visualize the tab, as an instance of the class {@link
 *         View}. The view may not be null
 * @param tab
 *         The tab, which should be visualized, as an instance of the class {@link Tab}. The tab
 *         may not be null
 * @param index
 *         The index of the tab, which should be visualized, as an {@link Integer} value
 * @param savedInstanceState
 *         The bundle, which has previously been used to save the state of the view as an
 *         instance of the class {@link Bundle} or null, if no saved state is available
 */
public final void applyDecorator(@NonNull final Context context,
                                 @NonNull final TabSwitcher tabSwitcher,
                                 @NonNull final View view, @NonNull final Tab tab,
                                 final int index, @Nullable final Bundle savedInstanceState) {
    setCurrentParentView(view);
    int viewType = getViewType(tab, index);

    if (savedInstanceState != null) {
        SparseArray<Parcelable> viewStates =
                savedInstanceState.getSparseParcelableArray(VIEW_HIERARCHY_STATE_EXTRA);

        if (viewStates != null) {
            view.restoreHierarchyState(viewStates);
        }
    }

    onShowTab(context, tabSwitcher, view, tab, index, viewType, savedInstanceState);
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:42,代码来源:TabSwitcherDecorator.java

示例6: restoreViewFromState

import android.view.View; //导入方法依赖的package包/类
/**
 * Restores the state of the view based on the currently stored {@link SavedState}, according to the view's key.
 *
 * @param view the view that belongs to a certain key
 */
public void restoreViewFromState(@NonNull View view) {
    if(view == null) {
        throw new IllegalArgumentException("You cannot restore state into null view!");
    }
    Object newKey = KeyContextWrapper.getKey(view.getContext());
    SavedState savedState = getSavedState(newKey);
    view.restoreHierarchyState(savedState.getViewHierarchyState());
    if(view instanceof Bundleable) {
        ((Bundleable) view).fromBundle(savedState.getBundle());
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:17,代码来源:BackstackManager.java


注:本文中的android.view.View.restoreHierarchyState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。