List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:com.eTilbudsavis.sdkdemo.Search.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search);/*from w ww . ja v a2 s . c o m*/ Eta.createInstance(Keys.API_KEY, Keys.API_SECRET, this); // Find views mQuery = (EditText) findViewById(R.id.etQuery); mListView = (ListView) findViewById(R.id.lvResult); // Check for any saved state if (savedInstanceState != null && savedInstanceState.containsKey(ARG_OFFERS) && savedInstanceState.containsKey(ARG_QUERY)) { mOffers = (List<Offer>) savedInstanceState.getSerializable(ARG_OFFERS); if (mOffers != null) { mListView.setAdapter(new SearchAdapter()); } String q = savedInstanceState.getString(ARG_QUERY); if (q != null) { mQuery.setText(q); mQuery.setSelection(q.length()); } } System.out.print("Eta null: " + Eta.getInstance().getClass().toString()); Button search = (Button) findViewById(R.id.btnPerformSearch); search.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String query = mQuery.getText().toString().trim(); if (query.length() > 0) { mPd = ProgressDialog.show(Search.this, "", "Searching...", true, true); performSearch(query); } } }); }
From source file:com.mercandalli.android.apps.files.file.cloud.FileMyCloudFragment.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (!args.containsKey(ARG_POSITION_IN_VIEW_PAGER)) { throw new IllegalStateException("Missing args. Please use newInstance()"); }//from w w w . j a va2 s . c o m mPositionInViewPager = args.getInt(ARG_POSITION_IN_VIEW_PAGER); mFileCloudFabManager = FileCloudFabManager.getInstance(); mFileCloudFabManager.addFabController(mPositionInViewPager, this); mFileManager = FileManager.getInstance(getContext()); }
From source file:com.starwood.anglerslong.LicenseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.license);/* ww w . j a v a 2s . co m*/ Bundle bundle = this.getIntent().getExtras(); getSupportActionBar().setTitle(bundle.getString("abtitle")); // getSupportActionBar().setSubtitle(bundle.getString("subtitle")); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // <- This puts the back arrow in actionbar if (bundle.containsKey("isArrayEmpty")) isArrayEmpty = bundle.getBoolean("isArrayEmpty"); populateTabs(false); // Populate the tabs within the clicked tab. }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.EditFragment.java
/** * Overriden method from Fragment. Sets the appropriate TextView and ImageView * if the user is returning from changing the location or image. If the user is * returning from changing the location, the new coordinates are placed on the * edit_location_button Button./* w w w . j a va2 s .c om*/ */ @Override public void onResume() { super.onResume(); Bundle args = getArguments(); if (EditFragment.oldText != null) { TextView oldTextView = (TextView) getActivity().findViewById(R.id.old_comment_text); oldTextView.setText(EditFragment.oldText); } if (args != null) { if (args.containsKey("LATITUDE") && args.containsKey("LONGITUDE")) { Button locButton = (Button) getActivity().findViewById(R.id.edit_location_button); if (args.getString("LocationType") == "CURRENT_LOCATION") { locButton.setText("Current Location"); } else { GeoLocation geoLocation = editComment.getLocation(); Double lat = args.getDouble("LATITUDE"); Double lon = args.getDouble("LONGITUDE"); geoLocation.setCoordinates(lat, lon); String locationDescription = args.getString("locationDescription"); geoLocation.setLocationDescription(locationDescription); DecimalFormat format = new DecimalFormat(); format.setRoundingMode(RoundingMode.HALF_EVEN); format.setMinimumFractionDigits(0); format.setMaximumFractionDigits(4); locButton.setText("Location: Set"); } } } }
From source file:com.zion.htf.ui.fragment.ArtistSoundcloudFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = this.getArguments(); try {/* w ww .ja va 2 s . co m*/ if (!args.containsKey(ArtistSoundcloudFragment.ARG_ARTIST_ID) && !args.containsKey(ArtistSoundcloudFragment.ARG_SET_ID)) throw new MissingArgumentException(String.format(Locale.ENGLISH, "Either %s or %s is required for this Activity to work properly. Please provide any of them.", ArtistDetailsFragment.ARG_SET_ID, ArtistDetailsFragment.ARG_ARTIST_ID)); if (args.containsKey(ArtistSoundcloudFragment.ARG_ARTIST_ID)) { this.artist = Artist.getById(args.getInt(ArtistSoundcloudFragment.ARG_ARTIST_ID)); } else { this.artist = Artist.getBySetId(args.getInt(ArtistSoundcloudFragment.ARG_SET_ID)); } } catch (Exception e) { //Report this through Piwik if (BuildConfig.DEBUG) e.printStackTrace(); throw new RuntimeException(e); } }
From source file:com.data.pack.Util.java
/** * Connect to an HTTP URL and return the response as a string. * //from w w w . j av a2s. c o m * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url * - the resource to open: must be a welformed URL * @param method * - the HTTP method to use ("GET", "POST", etc.) * @param params * - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String * @throws MalformedURLException * - if the URL format is invalid * @throws IOException * - if a network problem occurs */ public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Util.logd("Facebook-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }
From source file:com.aknowledge.v1.automation.RemoteActivity.java
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { // Restore the previously serialized current dropdown position. Log.d("RemoteActivity", "onRestoreInstanceState"); if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) { getActionBar().setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM)); }/*from w ww. j a va 2 s . co m*/ }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String selection = null;//from w ww.ja va 2 s . c om Select query; switch (id) { case ID_LOADER_REPORT: if (args != null && args.containsKey(KEY_BUNDLE_YEAR) && args.getString(KEY_BUNDLE_YEAR) != null) { selection = IncomeVsExpenseReportEntity.YEAR + " IN (" + args.getString(KEY_BUNDLE_YEAR) + ")"; if (!TextUtils.isEmpty(selection)) { selection = "(" + selection + ")"; } } // if don't have selection abort query if (TextUtils.isEmpty(selection)) { selection = "1=2"; } QueryReportIncomeVsExpenses report = new QueryReportIncomeVsExpenses(getActivity()); query = new Select(report.getAllColumns()).where(selection).orderBy(IncomeVsExpenseReportEntity.YEAR + " " + mSort + ", " + IncomeVsExpenseReportEntity.Month + " " + mSort); return new MmxCursorLoader(getActivity(), report.getUri(), query); case ID_LOADER_YEARS: ViewMobileData mobileData = new ViewMobileData(getContext()); selection = "SELECT DISTINCT Year FROM " + mobileData.getSource() + " ORDER BY Year DESC"; query = new Select().where(selection); return new MmxCursorLoader(getActivity(), new SQLDataSet().getUri(), query); } return null; }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/*from w ww . j a v a 2s . c o m*/ if (savedInstanceState != null && savedInstanceState.containsKey(KEY_BUNDLE_YEAR) && savedInstanceState.getIntArray(KEY_BUNDLE_YEAR) != null) { for (int year : savedInstanceState.getIntArray(KEY_BUNDLE_YEAR)) { mYearsSelected.put(year, true); } } else { mYearsSelected.put(Calendar.getInstance().get(Calendar.YEAR), true); } initializeListView(); // set home button // ActionBarActivity activity = (ActionBarActivity) getActivity(); // AppCompatActivity activity = (AppCompatActivity) getActivity(); // if (activity != null) { //activity.getSupportActionBar().setDisplayHomeAsUpEnabled(false); // } // create adapter IncomeVsExpensesAdapter adapter = new IncomeVsExpensesAdapter(getActivity(), null); setListAdapter(adapter); setListShown(false); // start loader //getLoaderManager().restartLoader(ID_LOADER_YEARS, null, this); getLoaderManager().initLoader(ID_LOADER_YEARS, null, this); }
From source file:com.beesham.popularmovies.DetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_details_view, container, false); ButterKnife.bind(this, rootView); mTrailerList = new ArrayList(); mReviewsList = new ArrayList(); mReviewAdapter = new ReviewAdapter(getActivity(), mReviewsList); reviewsListView.setAdapter(mReviewAdapter); reviewsListView.setEmptyView(emptyReviewsTextView); mTrailersAdapter = new TrailersAdapter(getActivity(), mTrailerList); trailersListView.setAdapter(mTrailersAdapter); trailersListView.setEmptyView(emptyTrailersTextView); trailersListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// w w w.ja v a2 s. c o m public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); String movieBaseYoutubeUrl = getString(R.string.movies_base_youtube_url, ((Trailer) mTrailerList.get(i)).getTrailerKey()); intent.setData(Uri.parse(movieBaseYoutubeUrl)); if (intent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(intent); } } }); favoriteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (checkForFavorite()) { removeFavorite(); favoriteButton.setText(R.string.mark_favorite); } else { insertFavoriteMovie(); favoriteButton.setText(R.string.mark_unfavorite); } } }); Bundle args = getArguments(); if (args != null) { mUri = args.getParcelable(DetailsFragment.DETAIL_URI); } if (savedInstanceState != null && args.containsKey(DetailsFragment.DETAIL_URI)) { mUri = args.getParcelable(DetailsFragment.DETAIL_URI); } return rootView; }