List of usage examples for android.os Bundle putSerializable
@Override public void putSerializable(@Nullable String key, @Nullable Serializable value)
From source file:com.ccs.wedate.common.eventbus.util.ErrorDialogFragmentFactory.java
/** * Prepares the fragment's arguments and creates the fragment. May be overridden to provide custom error fragments. *///w w w .j a v a2 s .c o m protected T prepareErrorFragment(ThrowableFailureEvent event, boolean finishAfterDialog, Bundle argumentsForErrorDialog) { if (event.isSuppressErrorUi()) { // Show nothing by default return null; } Bundle bundle; if (argumentsForErrorDialog != null) { bundle = (Bundle) argumentsForErrorDialog.clone(); } else { bundle = new Bundle(); } if (!bundle.containsKey(ErrorDialogManager.KEY_TITLE)) { String title = getTitleFor(event, bundle); bundle.putString(ErrorDialogManager.KEY_TITLE, title); } if (!bundle.containsKey(ErrorDialogManager.KEY_MESSAGE)) { String message = getMessageFor(event, bundle); bundle.putString(ErrorDialogManager.KEY_MESSAGE, message); } if (!bundle.containsKey(ErrorDialogManager.KEY_FINISH_AFTER_DIALOG)) { bundle.putBoolean(ErrorDialogManager.KEY_FINISH_AFTER_DIALOG, finishAfterDialog); } if (!bundle.containsKey(ErrorDialogManager.KEY_EVENT_TYPE_ON_CLOSE) && config.defaultEventTypeOnDialogClosed != null) { bundle.putSerializable(ErrorDialogManager.KEY_EVENT_TYPE_ON_CLOSE, config.defaultEventTypeOnDialogClosed); } if (!bundle.containsKey(ErrorDialogManager.KEY_ICON_ID) && config.defaultDialogIconId != 0) { bundle.putInt(ErrorDialogManager.KEY_ICON_ID, config.defaultDialogIconId); } return createErrorFragment(event, bundle); }
From source file:com.plusub.lib.service.BaseRequestService.java
/** * ??/*ww w .j a va2 s . co m*/ * <p>Title: transmitParams * <p>Description: * @param map * @return */ private Bundle transmitParams(Map map) { String keys; if (map != null && map.size() > 0) { Bundle bd = new Bundle(); for (Object key : map.keySet()) { //String if (key instanceof String) { keys = (String) key; // Object obj = map.get(key); if (obj instanceof String) { bd.putString(keys, (String) obj); } else if (obj instanceof Integer) { bd.putInt(keys, (Integer) obj); } else if (obj instanceof Boolean) { bd.putBoolean(keys, (Boolean) obj); } else if (obj instanceof Serializable) { bd.putSerializable(keys, (Serializable) obj); } else if (obj instanceof Character) { bd.putChar(keys, (Character) obj); } else if (obj instanceof Double) { bd.putDouble(keys, (Double) obj); } else if (obj instanceof Float) { bd.putFloat(keys, (Float) obj); } else { Logger.e("[MainService] : unknow map values type ! keys:" + keys); } } } return bd; } return null; }
From source file:ch.bfh.evoting.alljoyn.BusHandler.java
/** * Method processing the message received * @param messageObject object containing the message transmitted over the newtork *//*from w w w. j a va2s .c o m*/ private void processMessage(AllJoynMessage messageObject) { /* * First we check if decrypter is ready. If not, only Salt message can go further */ //if messageEncrypter isn't ready to decrypt and message is encrypted if (!messageEncrypter.isReady() && messageObject.isEncrypted()) { //requeue the message in order to process it later Message msg = this.obtainMessage(BusHandler.REPROCESS_MESSAGE); Bundle data = new Bundle(); data.putSerializable("message", messageObject); msg.setData(data); this.sendMessage(msg); Log.d(TAG, "Requeueing message received"); return; } /* * Second, we check if the message contains the salt and extract it */ //Check if the message contains the salt if (messageObject.getType().equals(Type.SALT)) { if (messageEncrypter.getSalt() == null) { this.saltReceived(messageObject); return; } } /* * Third, we check if the message contains an identity */ //Check if message contain an identity if (messageObject.getType().equals(Type.IDENTITY)) { extractIdentity(messageObject); return; } /* * Fourth, we verify the signature, if we know the sender, otherwise we set a flag */ if (identityMap.containsKey(messageObject.getSender())) { boolean result = messageObject.verifyMessage(identityMap.get(messageObject.getSender()).getPublicKey());//messageAuthenticater.verifySignature(identityMap.get(sender).getPublicKey(), Base64.decode(signature,Base64.DEFAULT), Base64.decode(message,Base64.DEFAULT)); if (!result) { //signature verification failed //ignoring message Log.e(TAG, "Wrong signature"); return; } else { Log.d(TAG, "Signature correct"); } } else { //message not containing a salt nor an identity coming from an unknown person => ignore Log.d(TAG, "Ignoring message since sender is not known"); //try to decrypt in order to detect if it could be a password error messageObject.getMessage(); return; } /* * Fifth, we decrypt the message */ String decryptedString = messageObject.getMessage(); if (decryptedString == null || decryptedString.equals("")) { //decryption failed Log.d(TAG, "Message decryption failed"); return; } /* * Sixth, we transmit message to the application */ //Send the message to the app Intent i = new Intent("messageArrived"); i.putExtra("senderId", messageObject.getSender()); i.putExtra("senderName", identityMap.get(messageObject.getSender()).getName()); i.putExtra("message", decryptedString); LocalBroadcastManager.getInstance(context).sendBroadcast(i); }
From source file:aarddict.android.ArticleViewActivity.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from ww w .ja va 2 s . c o m protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable("backItems", new LinkedList(backItems)); outState.putSerializable("scrollPositionsH", new HashMap(scrollPositionsH)); outState.putSerializable("scrollPositionsV", new HashMap(scrollPositionsV)); }
From source file:com.charabia.SmsViewActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("mode", mode); outState.putString("prefPhoneNumber", prefPhoneNumber); outState.putSerializable("keypair", keypair); outState.putByteArray("key", key); outState.putString("phoneNumber", phoneNumber); }
From source file:com.juick.android.ThreadActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { JuickAdvancedApplication.maybeEnableAcceleration(this); JuickAdvancedApplication.setupTheme(this); //requestWindowFeature(Window.FEATURE_NO_TITLE); //getSherlock().requestFeature(Window.FEATURE_NO_TITLE); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); super.onCreate(savedInstanceState); handler = new Handler(); Intent i = getIntent();//w w w. ja v a 2 s .co m mid = (MessageID) i.getSerializableExtra("mid"); if (mid == null) { finish(); } messagesSource = (MessagesSource) i.getSerializableExtra("messagesSource"); if (sp.getBoolean("fullScreenThread", false)) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } setContentView(R.layout.thread); /* findViewById(R.id.gotoMain).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(ThreadActivity.this, MainActivity.class)); } }); */ final View buttons = findViewById(R.id.buttons); bSend = (ImageButton) findViewById(R.id.buttonSend); bSend.setOnClickListener(this); bAttach = (ImageButton) findViewById(R.id.buttonAttachment); bAttach.setOnClickListener(this); etMessage = (EditText) findViewById(R.id.editMessage); if (sp.getBoolean("helvNueFonts", false)) { etMessage.setTypeface(JuickAdvancedApplication.helvNue); /* TextView oldTitle = (TextView)findViewById(R.id.old_title); oldTitle.setTypeface(JuickAdvancedApplication.helvNue); */ } Button cancel = (Button) findViewById(R.id.buttonCancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doCancel(); } }); tvReplyTo = (TextView) findViewById(R.id.textReplyTo); replyToContainer = (RelativeLayout) findViewById(R.id.replyToContainer); setHeight(replyToContainer, 0); showThread = (Button) findViewById(R.id.showThread); draftsButton = (Button) findViewById(R.id.drafts); etMessage.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { etMessage.setHint(""); setHeight(buttons, ActionBar.LayoutParams.WRAP_CONTENT); InputMethodManager inputMgr = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMgr.toggleSoftInput(0, 0); } else { etMessage.setHint(R.string.ClickToReply); setHeight(buttons, 0); } //To change body of implemented methods use File | Settings | File Templates. } }); draftsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { class Item { String label; long ts; int index; Item(String label, long ts, int index) { this.label = label; this.ts = ts; this.index = index; } } final ArrayList<Item> items = new ArrayList<Item>(); final SharedPreferences drafts = getSharedPreferences("drafts", MODE_PRIVATE); for (int q = 0; q < 1000; q++) { String msg = drafts.getString("message" + q, null); if (msg != null) { if (msg.length() > 50) msg = msg.substring(0, 50); items.add(new Item(msg, drafts.getLong("timestamp" + q, 0), q)); } } Collections.sort(items, new Comparator<Item>() { @Override public int compare(Item item, Item item2) { final long l = item2.ts - item.ts; return l == 0 ? 0 : l > 0 ? 1 : -1; } }); CharSequence[] arr = new CharSequence[items.size()]; for (int i1 = 0; i1 < items.size(); i1++) { Item item = items.get(i1); arr[i1] = item.label; } new AlertDialog.Builder(ThreadActivity.this).setItems(arr, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, final int which) { final Runnable doPull = new Runnable() { @Override public void run() { pullDraft(null, drafts, items.get(which).index); updateDraftsButton(); } }; if (pulledDraft != null && pulledDraft.trim().equals(etMessage.getText().toString().trim())) { // no need to ask, user just looks at the drafts saveDraft(pulledDraftRid, pulledDraftMid, pulledDraftTs, pulledDraft); doPull.run(); } else { if (etMessage.getText().toString().length() > 0) { new AlertDialog.Builder(ThreadActivity.this) .setTitle(getString(R.string.ReplacingText)) .setMessage(getString(R.string.YourTextWillBeReplaced)) .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { doPull.run(); } }) .setNeutralButton( getString(pulledDraft != null ? R.string.SaveChangedDraft : R.string.SaveDraft), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (pulledDraft != null) { saveDraft(pulledDraftRid, pulledDraftMid, System.currentTimeMillis(), etMessage.getText().toString()); } else { saveDraft(rid, mid.toString(), System.currentTimeMillis(), etMessage.getText().toString()); } doPull.run(); } }) .setPositiveButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .show(); } else { doPull.run(); } } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); } }); enableDrafts = (sp.getBoolean("enableDrafts", false)); if (sp.getBoolean("capitalizeReplies", false)) { etMessage.setInputType(etMessage.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES); } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); tf = new ThreadFragment(); tf.init(getLastCustomNonConfigurationInstance(), this); Bundle args = new Bundle(); args.putSerializable("mid", mid); args.putSerializable("messagesSource", messagesSource); args.putSerializable("prefetched", i.getSerializableExtra("prefetched")); args.putSerializable("originalMessage", i.getSerializableExtra("originalMessage")); args.putBoolean("scrollToBottom", i.getBooleanExtra("scrollToBottom", false)); tf.setArguments(args); ft.add(R.id.threadfragment, tf); ft.commit(); MainActivity.restyleChildrenOrWidget(getWindow().getDecorView()); detector = new GestureDetector(this, new GestureDetector.OnGestureListener() { @Override public boolean onDown(MotionEvent e) { return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (velocityX > 0 && Math.abs(velocityX) > 4 * Math.abs(velocityY) && Math.abs(velocityX) > 400) { if (etMessage.getText().toString().trim().length() == 0) { System.out.println("velocityX=" + velocityX + " velocityY" + velocityY); if (sp.getBoolean("swipeToClose", true)) { onBackPressed(); } } } return false; } }); com.actionbarsherlock.app.ActionBar actionBar = getSherlock().getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setHomeButtonEnabled(true); actionBar.setLogo(R.drawable.back_button); }
From source file:ch.bfh.evoting.alljoyn.BusHandler.java
/** * Helper method send my identity to the other peers */// w w w . j a v a 2s . c o m private void sendMyIdentity() { Log.d(TAG, "Sending my identity"); String myName = userDetails.getString("identification", ""); //save my own identity in identityMap Identity myIdentity = new Identity(myName, messageAuthenticater.getMyPublicKey()); identityMap.put(this.getIdentification(), myIdentity); byte[] publicKeyBytes = messageAuthenticater.getMyPublicKey().getEncoded(); if (publicKeyBytes == null) { Log.e(TAG, "Key encoding not supported"); } String myKey = Base64.encodeToString(publicKeyBytes, Base64.DEFAULT); String identity = myName + MESSAGE_PARTS_SEPARATOR + myKey; Log.d(TAG, "Send my identity"); //send my identity Message msg = obtainMessage(BusHandler.PING); Bundle data = new Bundle(); data.putString("groupName", lastJoinedNetwork); data.putString("pingString", identity); data.putSerializable("type", Type.IDENTITY); msg.setData(data); sendMessage(msg); }
From source file:com.mci.firstidol.activity.MainActivity.java
private void obtainBaiduPushClickEvent(String customContentString) { // TODO Auto-generated method stub long articleId = 0, articleType = 0, channelId = 0, modelType = 0; // ??mykeymyvalue? if (!TextUtils.isEmpty(customContentString)) { JSONObject customJson = null;/*from w w w . j a v a 2s . com*/ try { customJson = new JSONObject(customContentString); articleId = customJson.getLong("rel_id"); articleType = customJson.getLong("rel_type"); channelId = customJson.getLong("rel_channel"); modelType = customJson.getLong("rel_modeltype"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // // Demo??? // updateContent(context, notifyString); // // // Intent intent = new Intent(); // intent.setClass(context.getApplicationContext(), // LoginActivity.class); // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // context.getApplicationContext().startActivity(intent); // ?ChannelId ModelType???? // SquareLiveModel squareLiveModel = headers.get(position); if (channelId == 49) {// ? if (modelType == 2) {// ? Bundle bundle = new Bundle(); bundle.putBoolean("IsVideo", true); bundle.putLong(Constant.IntentKey.articleID, articleId); Utily.go2Activity(context, SquareFoundDetailActivity.class, bundle, true); } else {// ? Bundle bundle = new Bundle(); bundle.putLong(Constant.IntentKey.articleID, articleId); Utily.go2Activity(context, SquareFoundDetailActivity.class, bundle, true); } } else if (channelId == 44) {// Bundle mbuBundle = new Bundle(); mbuBundle.putBoolean(Constant.IntentKey.isSearch, true); mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId); mbuBundle.putString(Constant.IntentKey.typeCode, Constant.IntentValue.ACTIVITY_SHOPPING); Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true); } else if (channelId == 43) {// ? Bundle mbuBundle = new Bundle(); mbuBundle.putBoolean(Constant.IntentKey.isSearch, true); mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId); Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true); } else if (channelId == 47) {// Bundle mbuBundle = new Bundle(); mbuBundle.putBoolean(Constant.IntentKey.isSearch, true); mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId); Utily.go2Activity(context, SquareLiveActivity.class, mbuBundle, true); } else {// ,web Bundle mbuBundle = new Bundle(); mbuBundle.putBoolean("IsFromFound", true); mbuBundle.putBoolean(Constant.IntentKey.isSearch, true); mbuBundle.putSerializable(Constant.IntentKey.articleID, articleId); Utily.go2Activity(context, SquareWelfareDetailActivity.class, mbuBundle, true); } }
From source file:at.jclehner.rxdroid.DrugListActivity2.java
private void initDrugListPagerFragment() { mIsShowingDbErrorDialog = false;/*from w w w .ja v a 2s .c om*/ supportInvalidateOptionsMenu(); final DrugListPagerFragment f = new DrugListPagerFragment(); final Bundle args = new Bundle(); args.putSerializable(DrugListFragment.ARG_DATE, getIntent().getSerializableExtra(EXTRA_DATE)); //args.putInt(DrugListFragment.ARG_PATIENT_ID, Patient.DEFAULT_PATIENT_ID); f.setArguments(args); f.setRetainInstance(false); getSupportFragmentManager().beginTransaction().replace(android.R.id.content, f, "pager").commit(); }
From source file:com.makotojava.android.debate.PolicySpeechFragment.java
@Override public void onSaveInstanceState(Bundle outState) { Log.d(TAG, "saveInstanceState(): Saving Fragment State for Speech => " + _speech); super.onSaveInstanceState(outState); outState.putSerializable(SPEECH_TIMER, _speechTimer); outState.putSerializable(CROSSEX_TIMER, _crossexTimer); outState.putSerializable(AFFPREP_TIMER, getAffirmativePrepTimer()); outState.putSerializable(NEGPREP_TIMER, getNegativePrepTimer()); }