List of usage examples for android.os Bundle putInt
public void putInt(@Nullable String key, int value)
From source file:com.openerp.addons.messages.Message.java
public void setupListView(List<OEListViewRows> message_list) { // Destroying pre-loaded instance and going to create new one lstview = null;// w w w.j a v a2 s . c o m // Fetching required messages for listview by filtering of requrement if (list != null && list.size() <= 0) { list = message_list;// getMessages(message_list); } else { rootView.findViewById(R.id.messageSyncWaiter).setVisibility(View.GONE); rootView.findViewById(R.id.txvMessageAllReadMessage).setVisibility(View.GONE); } // Handling List View controls and keys String[] from = new String[] { "subject|type", "body", "starred", "author_id|email_from", "date", "model|type" }; int[] to = new int[] { R.id.txvMessageSubject, R.id.txvMessageBody, R.id.imgMessageStarred, R.id.txvMessageFrom, R.id.txvMessageDate, R.id.txvMessageTag }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_listview_items, list, from, to, db, true, new int[] { R.drawable.message_listview_bg_toread_selector, R.drawable.message_listview_bg_tonotread_selector }, "to_read"); // Telling adapter to clean HTML text for key value listAdapter.cleanHtmlToTextOn("body"); listAdapter.cleanDate("date", scope.User().getTimezone()); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(int position, View row_view, OEListViewRows row_data) { String model_name = row_data.getRow_data().get("model").toString(); String model = model_name; String res_id = row_data.getRow_data().get("res_id").toString(); if (model_name.equals("false")) { model_name = capitalizeString(row_data.getRow_data().get("type").toString()); } else { String[] model_parts = TextUtils.split(model_name, "\\."); HashSet unique_parts = new HashSet(Arrays.asList(model_parts)); model_name = capitalizeString(TextUtils.join(" ", unique_parts.toArray())); } TextView msgTag = (TextView) row_view.findViewById(R.id.txvMessageTag); int tag_color = 0; if (message_model_colors.containsKey(model_name)) { tag_color = message_model_colors.get(model_name); } else { tag_color = Color.parseColor(tag_colors[tag_color_count]); message_model_colors.put(model_name, tag_color); tag_color_count++; if (tag_color_count > tag_colors.length) { tag_color_count = 0; } } if (model.equals("mail.group")) { if (UserGroups.group_names.containsKey("group_" + res_id)) { model_name = UserGroups.group_names.get("group_" + res_id); tag_color = UserGroups.menu_color.get("group_" + res_id); } } msgTag.setBackgroundColor(tag_color); msgTag.setText(model_name); TextView txvSubject = (TextView) row_view.findViewById(R.id.txvMessageSubject); TextView txvAuthor = (TextView) row_view.findViewById(R.id.txvMessageFrom); if (row_data.getRow_data().get("to_read").toString().equals("false")) { txvSubject.setTypeface(null, Typeface.NORMAL); txvSubject.setTextColor(Color.BLACK); txvAuthor.setTypeface(null, Typeface.NORMAL); txvAuthor.setTextColor(Color.BLACK); } else { txvSubject.setTypeface(null, Typeface.BOLD); txvSubject.setTextColor(Color.parseColor("#414141")); txvAuthor.setTypeface(null, Typeface.BOLD); txvAuthor.setTextColor(Color.parseColor("#414141")); } return row_view; } }); // Creating instance for listview control lstview = (ListView) rootView.findViewById(R.id.lstMessages); // Providing adapter to listview scope.context().runOnUiThread(new Runnable() { @Override public void run() { lstview.setAdapter(listAdapter); } }); // Setting listview choice mode to multiple model lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); // Seeting item long click listern to activate action mode. lstview.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int index, long arg3) { // TODO Auto-generated method stub OEListViewRows data = (OEListViewRows) lstview.getAdapter().getItem(index); Toast.makeText(scope.context(), data.getRow_id() + " id clicked", Toast.LENGTH_LONG).show(); view.setSelected(true); if (mActionMode != null) { return false; } // Start the CAB using the ActionMode.Callback defined above mActionMode = scope.context().startActionMode(mActionModeCallback); selectedCounter++; view.setBackgroundResource(R.drawable.listitem_pressed); // lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); return true; } }); // Setting multi choice selection listener lstview.setMultiChoiceModeListener(new MultiChoiceModeListener() { HashMap<Integer, Boolean> selectedList = new HashMap<Integer, Boolean>(); @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are // selected/de-selected, // such as update the title in the CAB selectedList.put(position, checked); if (checked) { selectedCounter++; } else { selectedCounter--; } if (selectedCounter != 0) { mode.setTitle(selectedCounter + ""); } } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB HashMap<Integer, Integer> msg_pos = new HashMap<Integer, Integer>(); OEDialog dialog = null; switch (item.getItemId()) { case R.id.menu_message_mark_unread_selected: Log.e("menu_message_context", "Mark as Unread"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_mark_read_selected: Log.e("menu_message_context", "Mark as Read"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, true); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_move_to_archive_selected: Log.e("menu_message_context", "Archive"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_add_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, true); markasTodoTask.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_remove_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, false); markasTodoTask.execute((Void) null); mode.finish(); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.menu_fragment_message_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // Here you can make any necessary updates to the activity when // the CAB is removed. By default, selected items are // deselected/unchecked. /* * Perform Operation on Selected Ids. * * row_ids are list of selected message Ids. */ selectedList.clear(); selectedCounter = 0; lstview.clearChoices(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // Here you can perform updates to the CAB due to // an invalidate() request return false; } }); lstview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int index, long id) { // TODO Auto-generated method stub MessageDetail messageDetail = new MessageDetail(); Bundle bundle = new Bundle(); bundle.putInt("message_id", list.get(index).getRow_id()); bundle.putInt("position", index); messageDetail.setArguments(bundle); scope.context().fragmentHandler.setBackStack(true, null); scope.context().fragmentHandler.replaceFragmnet(messageDetail); if (!type.equals("archive")) { list.remove(index); } listAdapter.refresh(list); } }); // Getting Pull To Refresh Attacher from Main Activity mPullToRefreshAttacher = scope.context().getPullToRefreshAttacher(); // Set the Refreshable View to be the ListView and the refresh listener // to be this. if (mPullToRefreshAttacher != null & lstview != null) { mPullToRefreshAttacher.setRefreshableView(lstview, this); } }
From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatchFileFragment.java
/** * {@inheritDoc}//from w ww .ja v a 2 s. c om */ @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(EXTRA_SELECTED_PATCHER_ID, mSelectedPatcherId); outState.putParcelable(EXTRA_SELECTED_INPUT_URI, mSelectedInputUri); outState.putParcelable(EXTRA_SELECTED_OUTPUT_URI, mSelectedOutputUri); outState.putString(EXTRA_SELECTED_INPUT_FILE_NAME, mSelectedInputFileName); outState.putLong(EXTRA_SELECTED_INPUT_FILE_SIZE, mSelectedInputFileSize); outState.putInt(EXTRA_SELECTED_TASK_ID, mSelectedTaskId); outState.putParcelable(EXTRA_SELECTED_DEVICE, mSelectedDevice); outState.putString(EXTRA_SELECTED_ROM_ID, mSelectedRomId); outState.putBoolean(EXTRA_QUERYING_METADATA, mQueryingMetadata); }
From source file:com.lewa.crazychapter11.MainActivity.java
private void cal() { Message msg = new Message(); msg.what = 0x1234;//from w w w . j a va 2 s. c om Bundle bundle = new Bundle(); bundle.putInt(UPPER_NUM, Integer.parseInt(etNum.getText().toString())); msg.setData(bundle); calThread.mHandler.sendMessage(msg); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.InAppFlashingFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelableArrayList(EXTRA_PENDING_ACTIONS, mPendingActions); outState.putParcelable(EXTRA_SELECTED_URI, mSelectedUri); outState.putString(EXTRA_SELECTED_URI_FILE_NAME, mSelectedUriFileName); outState.putParcelable(EXTRA_SELECTED_BACKUP_DIR_URI, mSelectedBackupDirUri); outState.putString(EXTRA_SELECTED_BACKUP_NAME, mSelectedBackupName); outState.putStringArray(EXTRA_SELECTED_BACKUP_TARGETS, mSelectedBackupTargets); outState.putString(EXTRA_SELECTED_ROM_ID, mSelectedRomId); outState.putString(EXTRA_ZIP_ROM_ID, mZipRomId); outState.putSerializable(EXTRA_ADD_TYPE, mAddType); outState.putInt(EXTRA_TASK_ID_VERIFY_ZIP, mTaskIdVerifyZip); outState.putBoolean(EXTRA_QUERYING_METADATA, mQueryingMetadata); }
From source file:com.facebook.Request.java
/** * Creates a new Request that is configured to perform a search for places near a specified location via the Graph * API. At least one of location or searchText must be specified. * * @param session/*from ww w.j a va2 s . co m*/ * the Session to use, or null; if non-null, the session must be in an opened state * @param location * the location around which to search; only the latitude and longitude components of the location are * meaningful * @param radiusInMeters * the radius around the location to search, specified in meters; this is ignored if * no location is specified * @param resultsLimit * the maximum number of results to return * @param searchText * optional text to search for as part of the name or type of an object * @param callback * a callback that will be called when the request is completed to handle success or error conditions * @return a Request that is ready to execute * * @throws FacebookException If neither location nor searchText is specified */ public static Request newPlacesSearchRequest(Session session, Location location, int radiusInMeters, int resultsLimit, String searchText, final GraphPlaceListCallback callback) { if (location == null && Utility.isNullOrEmpty(searchText)) { throw new FacebookException("Either location or searchText must be specified."); } Bundle parameters = new Bundle(5); parameters.putString("type", "place"); parameters.putInt("limit", resultsLimit); if (location != null) { parameters.putString("center", String.format(Locale.US, "%f,%f", location.getLatitude(), location.getLongitude())); parameters.putInt("distance", radiusInMeters); } if (!Utility.isNullOrEmpty(searchText)) { parameters.putString("q", searchText); } Callback wrapper = new Callback() { @Override public void onCompleted(Response response) { if (callback != null) { callback.onCompleted(typedListFromResponse(response, GraphPlace.class), response); } } }; return new Request(session, SEARCH, parameters, HttpMethod.GET, wrapper); }
From source file:app.sunstreak.yourpisd.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);//w ww .ja va2 s .c om } // Find the screen height/width DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); SCREEN_HEIGHT = displaymetrics.heightPixels; SCREEN_WIDTH = displaymetrics.widthPixels; session = ((YPApplication) getApplication()).session; // Create the adapter that will return a fragment for each of the three // primary sections of the app. FragmentManager fm = getSupportFragmentManager(); mSectionsPagerAdapter = new SectionsPagerAdapter(fm); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); /* Deprecated as of 1/13/2015. @Han Li */ // setUpTabs(); setUpNavigationDrawer(); AppRater.app_launched(this); mFragments = new YPMainFragment[NUM_FRAGMENTS]; // Opens Spring semester summary by default. currentSummaryFragment = 1; for (int position = 0; position < NUM_FRAGMENTS; position++) { if (position == SUMMARY_FRAGMENT_POSITION) { mFragments[position] = new PlaceholderFragment(); } // else if (position == ATTENDANCE_FRAGMENT_POSITION) { // mFragments[position] = new AttendanceFragment(); // } else { mFragments[position] = new MainActivityFragment(); Bundle args = new Bundle(); args.putInt(MainActivityFragment.ARG_OBJECT, position); mFragments[position].setArguments(args); } } mViewPager.setAdapter(mSectionsPagerAdapter); // setUpMaterialTabs(); // For parents with multiple students, show the profile cards first. // If we are coming back from ClassSwipeActivity, go to requested // section (should be section #1). if (session.MULTIPLE_STUDENTS) { if (getIntent().hasExtra("mainActivitySection")) mViewPager.setCurrentItem(getIntent().getExtras().getInt("mainActivitySection")); else mViewPager.setCurrentItem(0); } // Otherwise, show the current six weeks grades list. else mViewPager.setCurrentItem(1); isAttendanceLoaded = false; MyTextView.typeface = Typeface.createFromAsset(getAssets(), "Roboto-Light.ttf"); if (DateHelper.isAprilFools()) { setUpTroll(); } }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
private void retrieveLocation() { // Build HTTP request StringBuilder builder = new StringBuilder(); HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet( "http://maps.google." + "com/maps/api/geocode/json?address=" + addressURL + "&sensor=false"); // Send HTTP request try {/*from w w w. jav a2s . c o m*/ HttpResponse response = client.execute(httpGet); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); if (statusCode == 200) { // Read the returned content into a string HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { builder.append(line); } } else { // Something is wrong, inform user of the error Log.e(TAG, "Failed to download file"); Toast.makeText(getApplicationContext(), "Location retrieval failed. Please try again", Toast.LENGTH_LONG).show(); Message msg = new Message(); msg.obj = "SHOW ADDRESS ENTER DIALOG"; handler.sendMessage(msg); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Create the JSONObject for parsing the string returned JSONObject jsonObject = new JSONObject(); try { jsonObject = new JSONObject(builder.toString()); } catch (JSONException e) { e.printStackTrace(); } // Parse the string returned into JSONObject try { addressArray = (JSONArray) jsonObject.get("results"); } catch (JSONException e) { e.printStackTrace(); } if (addressArray == null) { // Nothing returned, inform the user of the error Message msg = new Message(); msg.obj = "SHOW ADDRESS ENTER DIALOG - FAILED"; handler.sendMessage(msg); } else if (addressArray.length() == 0) { // No match found, inform the user of the error Message msg = new Message(); msg.obj = "SHOW ADDRESS ENTER DIALOG - NO RESULTS"; handler.sendMessage(msg); } else if (addressArray.length() == 1) { // Exact one result returned // Set the intent back to FindActivity Bundle bundle = new Bundle(); Intent newIntent = new Intent(); bundle.putString(Find.TIME, date); Double lng = new Double(0); Double lat = new Double(0); // Parse the JSONObject to get the longitude and latitude try { lng = addressArray.getJSONObject(0).getJSONObject("geometry").getJSONObject("location") .getDouble("lng"); lat = addressArray.getJSONObject(0).getJSONObject("geometry").getJSONObject("location") .getDouble("lat"); } catch (JSONException e) { e.printStackTrace(); } bundle.putDouble(Find.LONGITUDE, lng); bundle.putDouble(Find.LATITUDE, lat); bundle.putInt(Find.IS_ADHOC, REMINDER_SET); newIntent.putExtras(bundle); setResult(RESULT_OK, newIntent); finish(); } else { // More than one results returned // Show Address Confirm Dialog for user confirmation Message msg = new Message(); msg.obj = "SHOW ADDRESS CONFIRM DIALOG"; handler.sendMessage(msg); } }
From source file:com.ichi2.anki.NoteEditor.java
@Override protected void onSaveInstanceState(Bundle savedInstanceState) { Timber.i("Saving instance"); savedInstanceState.putInt("caller", mCaller); savedInstanceState.putBoolean("addFact", mAddNote); savedInstanceState.putLong("did", mCurrentDid); savedInstanceState.putStringArray("tags", mSelectedTags.toArray(new String[mSelectedTags.size()])); Bundle fields = new Bundle(); // Save the content of all the note fields. We use the field's ord as the key to // easily map the fields correctly later. for (FieldEditText e : mEditFields) { fields.putString(Integer.toString(e.getOrd()), e.getText().toString()); }//from w w w . j a v a2 s .c o m savedInstanceState.putBundle("editFields", fields); super.onSaveInstanceState(savedInstanceState); }
From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java
@Override protected void onSaveInstanceState(Bundle state) { super.onSaveInstanceState(state); state.putString(Constants.USERNAME_KEY, mUsername); state.putString(Constants.CommentsSort.SORT_BY_KEY, mSortByUrl); state.putString(Constants.JUMP_TO_THREAD_ID_KEY, mJumpToThreadId); state.putString(Constants.AFTER_KEY, mAfter); state.putString(Constants.BEFORE_KEY, mBefore); state.putInt(Constants.THREAD_COUNT_KEY, mCount); state.putString(Constants.LAST_AFTER_KEY, mLastAfter); state.putString(Constants.LAST_BEFORE_KEY, mLastBefore); state.putInt(Constants.THREAD_LAST_COUNT_KEY, mLastCount); state.putStringArray(Constants.KARMA_KEY, mKarma); state.putParcelable(Constants.VOTE_TARGET_THING_INFO_KEY, mVoteTargetThingInfo); }