List of usage examples for android.os Bundle putInt
public void putInt(@Nullable String key, int value)
From source file:fr.julienvermet.bugdroid.service.CommentIntentService.java
private void sendResult(Intent intent, int statusCode, String result) { Bundle extras = intent.getExtras();//from w w w.j a v a 2 s.c o m Messenger messenger = (Messenger) extras.get(MESSENGER); if (messenger != null) { Message msg = Message.obtain(); Bundle data = new Bundle(); data.putInt(STATUS_CODE, statusCode); data.putString(RESULT, result); msg.setData(data); try { messenger.send(msg); } catch (android.os.RemoteException e1) { Log.w(getClass().getName(), "Exception sending message", e1); } } }
From source file:cm.aptoide.ptdev.ScreenshotsViewer.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("position", currentItem); }
From source file:com.analysedesgeeks.android.PodcastActivity.java
@Override protected void onSaveInstanceState(final Bundle outState) { outState.putInt(Const.EXTRA_POSITION, position); super.onSaveInstanceState(outState); }
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
private static void putNestedJSONObject(JSONObject jsonObject, Bundle bundle) throws JSONException { JSONArray names = jsonObject.names(); for (int i = 0; i < names.length(); i++) { String name = names.getString(i); Object data = jsonObject.get(name); if (data == null) { continue; }/*from ww w .j a v a 2 s. com*/ if (data instanceof Integer) { bundle.putInt(name, ((Integer) data).intValue()); } if (data instanceof Float) { bundle.putFloat(name, ((Float) data).floatValue()); } if (data instanceof Double) { bundle.putDouble(name, ((Double) data).doubleValue()); } if (data instanceof Long) { bundle.putLong(name, ((Long) data).longValue()); } if (data instanceof String) { bundle.putString(name, (String) data); } if (data instanceof Boolean) { bundle.putBoolean(name, ((Boolean) data).booleanValue()); } // Nested JSONObject if (data instanceof JSONObject) { Bundle nestedBundle = new Bundle(); bundle.putBundle(name, nestedBundle); putNestedJSONObject((JSONObject) data, nestedBundle); } // Nested JSONArray. Doesn't support mixed types in single array if (data instanceof JSONArray) { // Empty array. No way to tell what type of data to pass on, so skipping if (((JSONArray) data).length() == 0) { Log.e("Empty array not supported in nested JSONObject, skipping"); continue; } // Integer if (((JSONArray) data).get(0) instanceof Integer) { int[] integerArrayData = new int[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { integerArrayData[j] = ((JSONArray) data).getInt(j); } bundle.putIntArray(name, integerArrayData); } // Double if (((JSONArray) data).get(0) instanceof Double) { double[] doubleArrayData = new double[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { doubleArrayData[j] = ((JSONArray) data).getDouble(j); } bundle.putDoubleArray(name, doubleArrayData); } // Long if (((JSONArray) data).get(0) instanceof Long) { long[] longArrayData = new long[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { longArrayData[j] = ((JSONArray) data).getLong(j); } bundle.putLongArray(name, longArrayData); } // String if (((JSONArray) data).get(0) instanceof String) { String[] stringArrayData = new String[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { stringArrayData[j] = ((JSONArray) data).getString(j); } bundle.putStringArray(name, stringArrayData); } // Boolean if (((JSONArray) data).get(0) instanceof Boolean) { boolean[] booleanArrayData = new boolean[((JSONArray) data).length()]; for (int j = 0; j < ((JSONArray) data).length(); ++j) { booleanArrayData[j] = ((JSONArray) data).getBoolean(j); } bundle.putBooleanArray(name, booleanArrayData); } } } }
From source file:com.ruesga.rview.fragments.EditorFragment.java
public static EditorFragment newInstance(int legacyChangeId, String changeId, String revisionId, String file, String content, boolean readOnly) { EditorFragment fragment = new EditorFragment(); Bundle arguments = new Bundle(); arguments.putInt(Constants.EXTRA_LEGACY_CHANGE_ID, legacyChangeId); arguments.putString(Constants.EXTRA_CHANGE_ID, changeId); arguments.putString(Constants.EXTRA_REVISION_ID, revisionId); if (!TextUtils.isEmpty(file)) { arguments.putString(Constants.EXTRA_FILE, file); }//from w w w . j a v a 2 s . c om if (!TextUtils.isEmpty(content)) { arguments.putString(Constants.EXTRA_CONTENT_FILE, content); } arguments.putBoolean(Constants.EXTRA_READ_ONLY, readOnly); fragment.setArguments(arguments); return fragment; }
From source file:com.jerrellmardis.amphitheatre.task.DownloadTaskHelper.java
public static void traverseSmbFiles(SmbFile root, NtlmPasswordAuthentication auth) throws SmbException, MalformedURLException { int fileCount = 0; boolean video_folder = false; final Video v = new Video(); Handler h = new Handler(Looper.getMainLooper()) { @Override/*from www.ja va 2s. co m*/ public void handleMessage(Message msg) { // super.handleMessage(msg); Video vid = (Video) msg.getData().getSerializable("VIDEO"); Log.d(TAG, "Handle " + msg.getData().getInt("WHEN") + " " + vid.getName()); updateSingleVideo(vid, null); } }; for (SmbFile f : root.listFiles()) { if (f.getParent().contains("Entertainment Media")) { // Log.d(TAG, "Discovered "+f.getPath()+" "+f.isDirectory()); } if (f.isDirectory()) { try { //TODO Port VOB folder support to USB and internal storage SmbFile[] directoryContents = f.listFiles(); // Log.d(TAG, "Going into directory "+f.getPath()); //If this works, then we can explore //Let's do some quick name checking to for time savings if (f.getName().contains("Entertainment Media")) { // Log.d(TAG, Arrays.asList(f.listFiles()).toString()); } if (!f.getName().contains("iTunes") && !f.getName().contains("Digi Pix") && !f.getName().contains("AppData") && !f.getName().startsWith(".") && !f.getName().contains("Avid") && !f.getName().contains("Spotify") && !f.getName().contains("audacity_temp") && !f.getName().contains("Media_previews") && !f.getName().contains("GFX_previews") && !f.getName().contains("Samsung Install Files") && !f.getName().contains("AE Renders") && !f.getName().contains("LocalData") && !f.getName().contains("$RECYCLE") && !f.getName().contains("Encore DVD") && !f.getName().contains("16 GB Photo card") && !f.getName().contains("Ignore") && !f.getName().contains("Documents") //TEMP && !f.getName().contains("Downloads") //TEMP && !f.getName().contains("TypeGEMs") //TEMP && !f.getName().contains("KofC7032Web") //TEMP && !f.getName().contains("hype mobile docs") //TEMP && !f.getName().contains("Thrive Music Video") //TEMP /*&& f.getPath().contains("Entertainment") //TEMP*/ && !f.getName().contains("Preview Files")) { Log.d(TAG, "Check " + f.getPath()); traverseSmbFiles(f, auth); } else { // Log.d(TAG, "Don't check " + f.getPath()); } } catch (Exception e) { //This folder isn't accessible Log.d(TAG, "Inaccessible: " + f.getName() + " " + e.getMessage()); //This will save us time in the traversal } } else/* if(f.getPath().contains("Films"))*/ { //TEMP //Is this something we want to add? // Log.d(TAG, "Non-directory "+f.getPath()); if (VideoUtils.isVideoFile(f.getPath())) { Log.d(TAG, f.getName() + " is a video"); //Perhaps. Let's do some checking. /* VOB check If the files are in a structure like: { Movie Name } -> VIDEO_TS -> VTS_nn_n.vob Then use the movie name as the source, and each vob url will be added in a comma-separated list to the video url string */ if (f.getPath().contains("VIDEO_TS")) { Log.d(TAG, "Special case for " + f.getPath()); //We have a special case! String grandparentPath = f.getPath().substring(0, f.getPath().indexOf("VIDEO_TS")); SmbFile grandparent = new SmbFile(grandparentPath, auth); //Let's delete this video and all like it from our video database //TODO Makes more sense to not delete and replace a video, just to update in place // Log.d(TAG, "Purge where video_url like "+"%" + grandparent.getPath().replace("'", "\'") + "%"); List<Video> videos = Select.from(Video.class).where(Condition.prop("video_url") .like("%" + grandparent.getPath().replace("'", "\'") + "%")).list(); // Log.d(TAG, "Purging "+videos.size()+" item(s)"); for (Video vx : videos) { // Log.d(TAG, "Deleting "+vx.getVideoUrl()); vx.delete(); } v.setName(grandparent.getName().replace("/", "").replace("_", " ") + ".avi"); //FIXME VOB currently not supported v.setSource(FileSource.SMB); v.setIsMatched(true); //Kind of a lie, but we know it's a thing! //Get all the video files ArrayList<String> urls = new ArrayList<>(); for (SmbFile f2 : grandparent.listFiles()) { for (SmbFile f3 : f2.listFiles()) { if (VideoUtils.isVideoFile(f3.getPath())) { //Presumably in order urls.add(f3.getPath()); } } } // Log.d(TAG, urls.toString()); //This works well v.setVideoUrl(urls); video_folder = true; } else { //Add the video like normal //Let's delete this video and all like it from our video database List<Video> videos = Select.from(Video.class) .where(Condition.prop("video_url").like("%" + f.getPath().replace("'", "''") + "%")) .list(); // Log.d(TAG, "Purging "+videos.size()+" item(s)"); for (Video vx : videos) { // Log.d(TAG, "Deleting "+vx.getVideoUrl()); vx.delete(); } v.setName(f.getName()); v.setSource(FileSource.SMB); v.setVideoUrl(f.getPath()); fileCount++; //Send a request to update metadata every second, to prevent as many 429 errors and memory exceptions Message m = new Message(); Bundle mBundle = new Bundle(); mBundle.putSerializable("VIDEO", v.clone()); mBundle.putInt("WHEN", (int) (1000 * fileCount + Math.round(Math.random() * 100))); m.setData(mBundle); // h.sendEmptyMessageDelayed(1000 * fileCount, 1000 * fileCount); h.sendMessageDelayed(m, 1000 * fileCount); Log.d(TAG, "Queued " + mBundle.getInt("WHEN") + " - " + v.getName()); v.save(); //Need to save here, otherwise purging won't work as expected } // Log.d(TAG, v.toString()); // return; } //Ignore otherwise } } //Let's do VOB video if (video_folder) { // Log.d(TAG, "Done rooting through "+root.getPath()); Log.d(TAG, "Created info for VOB " + v.toString()); fileCount++; //Send a request to update metadata every second, to prevent as many 429 errors and memory exceptions Message m = new Message(); Bundle mBundle = new Bundle(); mBundle.putSerializable("VIDEO", v.clone()); m.setData(mBundle); // h.sendEmptyMessageDelayed(1000 * fileCount, 1000 * fileCount); h.sendMessageDelayed(m, 1000 * fileCount); Log.d(TAG, "Queued " + 1000 * fileCount + " - " + v.getName()); v.save(); //Need to save here, otherwise purging won't work as expected } }
From source file:com.odoo.orm.ODataRow.java
public Bundle getPrimaryBundleData() { Bundle bundle = new Bundle(); bundle.putInt("id", getInt("id")); bundle.putInt(OColumn.ROW_ID, getInt(OColumn.ROW_ID)); return bundle; }
From source file:com.skywomantechnology.app.guildviewer.sync.GuildViewerSyncAdapter.java
/** * Sync the remote data immediately passing along sync data to * the routines to determine how much data to sync * * @param context Activity context/* w ww . j a v a 2s . c om*/ * @param syncAll if true process all news items within the date range, * if false process normally by checking the timestamps * @param syncMax Max number of news items to process */ public static void syncImmediately(Context context, boolean syncAll, int syncMax) { Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); bundle.putBoolean(SYNC_EXTRAS_SYNC_ALL, syncAll); bundle.putInt(SYNC_EXTRAS_SYNC_MAX, syncMax); ContentResolver.requestSync(getSyncAccount(context), context.getString(R.string.content_authority), bundle); }
From source file:com.fanfou.app.opensource.update.AppVersionInfo.java
@Override public void writeToParcel(final Parcel dest, final int flags) { final Bundle bundle = new Bundle(); bundle.putInt("versionCode", this.versionCode); bundle.putString("versionName", this.versionName); bundle.putString("releaseDate", this.releaseDate); bundle.putString("changelog", this.changelog); bundle.putString("downloadUrl", this.downloadUrl); bundle.putString("versionType", this.versionType); bundle.putString("packageName", this.packageName); bundle.putBoolean("forceUpdate", this.forceUpdate); dest.writeBundle(bundle);/*w w w . j a v a2s .c om*/ }
From source file:de.kirchnerei.bicycle.battery.BatteryDetailFragment.java
private void doEditBatteryClick() { Bundle args = new Bundle(); args.putInt(BatteryDefine.PARAM_BATTERY_ID, mId); getMiddlewareHandler().onAction(R.string.fragment_battery_edit, args); }