當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。