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


Java Bundle.setClassLoader方法代码示例

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


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

示例1: restoreState

import android.os.Bundle; //导入方法依赖的package包/类
@Override
    public void restoreState(Parcelable state, ClassLoader loader) {
        if (state != null) {
            Bundle bundle = (Bundle) state;
            bundle.setClassLoader(loader);
            mSavedState.clear();
            mFragments.clear();
            if (bundle.containsKey("states")) {
                mSavedState = bundle.getSparseParcelableArray("states");
            }
            Iterable<String> keys = bundle.keySet();
            for (String key : keys) {
                if (key.startsWith("f")) {
                    int index = Integer.parseInt(key.substring(1));
                    Fragment f = mFragmentManager.getFragment(bundle, key);
                    if (f != null) {
                        f.setMenuVisibility(false);
                        mFragments.put(index, f);
                    } else {
//						Log.w(TAG, "Bad fragment at key " + key);
                    }
                }
            }
        }
    }
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:26,代码来源:FragmentListPageAdapter.java

示例2: setIntentClassLoader

import android.os.Bundle; //导入方法依赖的package包/类
private void setIntentClassLoader(Intent intent, ClassLoader classLoader) {
    try {
        Bundle mExtras = (Bundle) FieldUtils.readField(intent, "mExtras");
        if (mExtras != null) {
            mExtras.setClassLoader(classLoader);
        } else {
            Bundle value = new Bundle();
            value.setClassLoader(classLoader);
            FieldUtils.writeField(intent, "mExtras", value);
        }
    } catch (Exception e) {
    } finally {
        intent.setExtrasClassLoader(classLoader);
    }
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:16,代码来源:PluginCallback.java

示例3: restoreState

import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        SparseArray<Parcelable> ss = bundle.containsKey(STATE) ? bundle.getSparseParcelableArray(STATE) : null;
        mSavedStates = ss != null ? ss : new SparseArray<Parcelable>();
    }
    super.restoreState(state, loader);
}
 
开发者ID:achenglike,项目名称:imageviewer,代码行数:11,代码来源:RecyclingPagerAdapter.java

示例4: restoreViewState

import android.os.Bundle; //导入方法依赖的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

示例5: send

import android.os.Bundle; //导入方法依赖的package包/类
public Bundle send(Bundle bundle) {
	
	Parcel data = Parcel.obtain();
	data.writeBundle(bundle);
	
	Parcel reply = Parcel.obtain();
	
	try {
		mService.transact(ServiceContext.TRANSACT_BUNDLE_SENDER, data, reply, 0);
		
		Bundle result = reply.readBundle();
		result.setClassLoader(getClass().getClassLoader());
		return result;
		
	} catch (RemoteException e) {
		e.printStackTrace();
		return null;
	} finally {
		data.recycle();
		reply.recycle();
	}
	
}
 
开发者ID:devyok,项目名称:DroidIPC,代码行数:24,代码来源:BundleSender.java

示例6: invokeSync

import android.os.Bundle; //导入方法依赖的package包/类
@Override
public Bundle invokeSync(Bundle data, String clazz) throws RemoteException {
    if (clazz == null || clazz.length() == 0) {
        Log.e(TAG, "invokeAsync failed, class is null or nil.");
        return null;
    }
    IPCSyncInvokeTask task = ObjectStore.get(clazz, IPCSyncInvokeTask.class);
    if (task == null) {
        Log.e(TAG, "invokeSync failed, can not newInstance by class %s.", clazz);
        return null;
    }
    if (data != null) {
        data.setClassLoader(BaseIPCService.class.getClassLoader());
    }
    return task.invoke(data);
}
 
开发者ID:AlbieLiang,项目名称:IPCInvoker,代码行数:17,代码来源:BaseIPCService.java

示例7: handleMessage

import android.os.Bundle; //导入方法依赖的package包/类
public void handleMessage(Message msg) {
    if (this.mCallbacksMessengerRef != null) {
        Bundle data = msg.getData();
        data.setClassLoader(MediaSessionCompat.class.getClassLoader());
        switch (msg.what) {
            case 1:
                this.mCallbackImpl.onServiceConnected((Messenger) this.mCallbacksMessengerRef.get(), data.getString(MediaBrowserProtocol.DATA_MEDIA_ITEM_ID), (Token) data.getParcelable(MediaBrowserProtocol.DATA_MEDIA_SESSION_TOKEN), data.getBundle(MediaBrowserProtocol.DATA_ROOT_HINTS));
                return;
            case 2:
                this.mCallbackImpl.onConnectionFailed((Messenger) this.mCallbacksMessengerRef.get());
                return;
            case 3:
                this.mCallbackImpl.onLoadChildren((Messenger) this.mCallbacksMessengerRef.get(), data.getString(MediaBrowserProtocol.DATA_MEDIA_ITEM_ID), data.getParcelableArrayList(MediaBrowserProtocol.DATA_MEDIA_ITEM_LIST), data.getBundle(MediaBrowserProtocol.DATA_OPTIONS));
                return;
            default:
                Log.w(MediaBrowserCompat.TAG, "Unhandled message: " + msg + "\n  Client version: " + 1 + "\n  Service version: " + msg.arg1);
                return;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:MediaBrowserCompat.java

示例8: handleMessage

import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case MSG_ONDOWNLOADPROGRESS:                        
            Bundle bun = msg.getData();
            if ( null != mContext ) {
                bun.setClassLoader(mContext.getClassLoader());
                DownloadProgressInfo dpi = (DownloadProgressInfo) msg.getData()
                        .getParcelable(PARAM_PROGRESS);
                mItf.onDownloadProgress(dpi);
            }
            break;
        case MSG_ONDOWNLOADSTATE_CHANGED:
            mItf.onDownloadStateChanged(msg.getData().getInt(PARAM_NEW_STATE));
            break;
        case MSG_ONSERVICECONNECTED:
            mItf.onServiceConnected(
                    (Messenger) msg.getData().getParcelable(PARAM_MESSENGER));
            break;
    }
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:22,代码来源:DownloaderClientMarshaller.java

示例9: readFromParcel

import android.os.Bundle; //导入方法依赖的package包/类
public static Parcelable readFromParcel(Parcel parcel, Class<?> parcelableType, String key) {
    parcel.setDataPosition(0);

    Bundle bundle = parcel.readBundle();
    bundle.setClassLoader(parcelableType.getClassLoader());
    
    Parcelable unparceledInstance = bundle.getParcelable(key);
    return unparceledInstance;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ParcelUtils.java

示例10: restoreState

import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:32,代码来源:CustomFragmentStatePagerAdapter.java

示例11: onCreate

import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    wxapi = WXAPIFactory.createWXAPI(this, AllShare.getWxId(), true);
    boolean registered = wxapi.registerApp(AllShare.getWxId());
    // 若是接收结果,处理完直接finish
    if (wxapi.handleIntent(intent, this)) {
        finish();
        return;
    }

    Bundle bundle;
    boolean paramError = false;
    if (!registered) {
        LogUtils.e("%s: api is null, finish.", TAG);
        paramError = true;
    } else if (null == intent || null == (bundle = intent.getExtras())) {
        LogUtils.e("%s: params is null, finish.", TAG);
        paramError = true;
    } else {
        bundle.setClassLoader(WXContent.class.getClassLoader());
        if (null == (shareContent = bundle.getParcelable(KEY_SHARE_CONTENT))) {
            LogUtils.e("%s: share content is null, finish.", TAG);
            paramError = true;
        } else if (null == (listener = bundle.getParcelable(KEY_SHARE_LISTENER))) {
            LogUtils.e("%s: result receiver is null.", TAG);
        }
    }
    if (paramError) {
        Toast.makeText(this, R.string.share_failed, Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    share();
}
 
开发者ID:szitguy,项目名称:Allshare,代码行数:38,代码来源:WXEntryActivity.java

示例12: restoreState

import android.os.Bundle; //导入方法依赖的package包/类
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        this.mSavedState.clear();
        this.mFragments.clear();
        if (fss != null) {
            for (Parcelable parcelable : fss) {
                this.mSavedState.add((SavedState) parcelable);
            }
        }
        for (String key : bundle.keySet()) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = this.mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (this.mFragments.size() <= index) {
                        this.mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    this.mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:30,代码来源:FragmentStatePagerAdapter.java

示例13: toMap

import android.os.Bundle; //导入方法依赖的package包/类
private HashMap<String, EpisodeTags> toMap(Bundle b) {
    int size = (b!=null) ? b.size() : 0;
    HashMap<String, EpisodeTags> result = new HashMap<String, EpisodeTags>(size);
    if (b != null) {
        b.setClassLoader(BaseTags.class.getClassLoader());
        for (String key : b.keySet()) {
            result.put(key, b.<EpisodeTags>getParcelable(key));
        }
    }
    return result;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:12,代码来源:ManualShowScrappingSearchFragment.java

示例14: onReceiveResult

import android.os.Bundle; //导入方法依赖的package包/类
protected void onReceiveResult(int resultCode, Bundle resultData) {
    resultData.setClassLoader(MediaBrowserCompat.class.getClassLoader());
    if (resultCode == 0 && resultData != null && resultData.containsKey(MediaBrowserServiceCompat.KEY_MEDIA_ITEM)) {
        Parcelable item = resultData.getParcelable(MediaBrowserServiceCompat.KEY_MEDIA_ITEM);
        if (item instanceof MediaItem) {
            this.mCallback.onItemLoaded((MediaItem) item);
            return;
        } else {
            this.mCallback.onError(this.mMediaId);
            return;
        }
    }
    this.mCallback.onError(this.mMediaId);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:15,代码来源:MediaBrowserCompat.java

示例15: restoreState

import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle b = (Bundle) state;

        b.setClassLoader(getClass().getClassLoader());

        entries = ((Bundle) state).getParcelableArrayList(KEY_DESCRIPTORS);
        notifyDataSetChanged();
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:12,代码来源:ArrayPagerAdapter.java


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