本文整理汇总了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);
}
}
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
}
示例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();
}
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
}
}
}
示例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();
}
示例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);
}
}
}
}
}
示例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;
}
示例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);
}
示例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();
}
}