List of usage examples for android.widget Toast show
public void show()
From source file:carsharing.starter.automotive.iot.ibm.com.mobilestarterapp.AnalyzeMyDriving.java
public void completeReservation(final String resId, final boolean alreadyTaken) { final String url = API.reservation + "/" + resId; try {/*from w ww . j a va 2 s . c o m*/ final API.doRequest task = new API.doRequest(new API.doRequest.TaskListener() { @Override public void postExecute(JSONArray result) throws JSONException { final JSONObject serverResponse = result.getJSONObject(result.length() - 1); final int statusCode = serverResponse.getInt("statusCode"); result.remove(result.length() - 1); String title = ""; String message = ""; switch (statusCode) { case 200: title = "Trip completed."; message = "Please allow at least 30 minutes for the driver behavior data to be analyzed"; reservationId[0] = null; break; default: title = "Something went wrong."; } final AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.getSupportActionBar().setTitle(title); if (!alreadyTaken) { Toast toast = Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_SHORT); toast.show(); } Log.i("Complete Reservation", result.toString()); } }); final String trip_id = getTripId(deviceID); final JSONObject bodyObject = new JSONObject(); bodyObject.put("status", "close"); if (trip_id != null) { // bind this trip to this reservation bodyObject.put("trip_id", trip_id); } completeDrive(deviceID); task.execute(url, "PUT", null, bodyObject.toString()).get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:net.homelinux.penecoptero.android.citybikes.donation.app.MainActivity.java
private void fillData(boolean all) { if (mNDBAdapter != null && mNDBAdapter.isConfigured()) { Bundle data = new Bundle(); if (!all) { GeoPoint center = locator.getCurrentGeoPoint(); if (center == null) { //Do something.. int nid = settings.getInt("network_id", -1); //Log.i("CityBikes","Current network is id: "+Integer.toString(nid)); if (nid != -1) { try { mNDBAdapter.load(); JSONObject network = mNDBAdapter.getNetworks(nid); //Log.i("CityBikes",network.toString()); double lat = Integer.parseInt(network.getString("lat")) / 1E6; double lng = Integer.parseInt(network.getString("lng")) / 1E6; Location fallback = new Location("fallback"); fallback.setLatitude(lat); fallback.setLongitude(lng); locator.setFallbackLocation(fallback); locator.unlockCenter(); center = locator.getCurrentGeoPoint(); } catch (Exception e) { //Log.i("CityBikes","We re fucked, that network aint existin"); e.printStackTrace(); }//from w ww. j a va 2 s .c om } else { //Log.i("CityBikes","We re fucked, why re we here?"); } } data.putInt(StationsDBAdapter.CENTER_LAT_KEY, center.getLatitudeE6()); data.putInt(StationsDBAdapter.CENTER_LNG_KEY, center.getLongitudeE6()); data.putInt(StationsDBAdapter.RADIUS_KEY, hOverlay.getRadius()); } progressDialog = new ProgressDialog(this); progressDialog.setTitle(""); progressDialog.setMessage(getString(R.string.loading)); progressDialog.show(); try { mDbHelper.sync(all, data); } catch (Exception e) { ////Log.i("openBicing", "Error Updating?"); e.printStackTrace(); progressDialog.dismiss(); } ; } else { //Log.i("CityBikes","First time!!! :D"); try { mNDBAdapter.update(); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_map); alertDialog.setTitle(R.string.bike_network_alert_title); alertDialog.setMessage(getString(R.string.bike_network_alert_text)); alertDialog.setButton(getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); alertDialog.show(); } catch (Exception e) { e.printStackTrace(); Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error), Toast.LENGTH_LONG); toast.show(); } } }
From source file:net.homelinux.penecoptero.android.citybikes.app.MainActivity.java
private void fillData(boolean all) { if (mNDBAdapter != null && mNDBAdapter.isConfigured()) { Bundle data = new Bundle(); if (!all) { GeoPoint center = locator.getCurrentGeoPoint(); if (center == null) { //Do something.. int nid = settings.getInt("network_id", -1); //Log.i("CityBikes","Current network is id: "+Integer.toString(nid)); if (nid != -1) { try { mNDBAdapter.load(); JSONObject network = mNDBAdapter.getNetworks(nid); //Log.i("CityBikes",network.toString()); double lat = Integer.parseInt(network.getString("lat")) / 1E6; double lng = Integer.parseInt(network.getString("lng")) / 1E6; Location fallback = new Location("fallback"); fallback.setLatitude(lat); fallback.setLongitude(lng); locator.setFallbackLocation(fallback); locator.unlockCenter(); center = locator.getCurrentGeoPoint(); } catch (Exception e) { //Log.i("CityBikes","We re fucked, that network aint existin"); e.printStackTrace(); }//from w w w .ja v a 2s . co m } else { //Log.i("CityBikes","We re fucked, why re we here?"); } } data.putInt(StationsDBAdapter.CENTER_LAT_KEY, center.getLatitudeE6()); data.putInt(StationsDBAdapter.CENTER_LNG_KEY, center.getLongitudeE6()); data.putInt(StationsDBAdapter.RADIUS_KEY, hOverlay.getRadius()); } progressDialog = new ProgressDialog(this); progressDialog.setTitle(""); progressDialog.setMessage(getString(R.string.loading)); progressDialog.show(); try { mDbHelper.sync(all, data); } catch (Exception e) { ////Log.i("openBicing", "Error Updating?"); e.printStackTrace(); progressDialog.dismiss(); } ; } else { //Log.i("CityBikes","First time!!! :D"); try { mNDBAdapter.update(); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_map); alertDialog.setTitle(R.string.bike_network_alert_title); alertDialog.setMessage(getString(R.string.bike_network_alert_text)); alertDialog.setButton(getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); alertDialog.show(); } catch (Exception e) { e.printStackTrace(); Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error), Toast.LENGTH_LONG); toast.show(); } } infoLayer.update(); }
From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String data = prefs.getString("AFilmModel", null); Gson gson = new Gson(); AFilmModel aFilm = gson.fromJson(data, AFilmModel.class); String link = "http://nhatphim.com/index/api-detail?id=" + aFilm.getId(); getListVideo(link);//from w ww . ja v a 2s. c o m // contentUri = Uri.parse("http://www.phim3s.net/phim-bo/thien-kim-tro-ve_8328/xem-phim/221808/video.mp4"); /* contentUri = Uri.parse("http://www.phim3s.net/phim-bo/thien-kim-tro-ve_8328/xem-phim/221808/video.mp4");*/ contentType = 2; contentId = "dizzy"; setContentView(R.layout.player_activity); root = findViewById(R.id.root); root.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { toggleControlsVisibility(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { view.performClick(); } return true; } }); shutterView = findViewById(R.id.shutter); debugRootView = findViewById(R.id.controls_root); surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view); surfaceView.getHolder().addCallback(this); debugTextView = (TextView) findViewById(R.id.debug_text_view); playerStateTextView = (TextView) findViewById(R.id.player_state_view); subtitleView = (SubtitleView) findViewById(R.id.subtitles); mediaController = new VideoControllerView(this); mediaController.setAnchorView((FrameLayout) root); mediaController.setPrevNextListeners(new OnClickListener() { @Override public void onClick(View v) { //next button clicked Toast t = Toast.makeText(PlayerActivity.this, "click", Toast.LENGTH_SHORT); t.show(); } }, new OnClickListener() { @Override public void onClick(View v) { Toast t = Toast.makeText(PlayerActivity.this, "pt bt", Toast.LENGTH_SHORT); t.show(); } }); retryButton = (Button) findViewById(R.id.retry_button); retryButton.setOnClickListener(this); videoButton = (Button) findViewById(R.id.video_controls); audioButton = (Button) findViewById(R.id.audio_controls); textButton = (Button) findViewById(R.id.text_controls); DemoUtil.setDefaultCookieManager(); configureSubtitleView(); delegate = new Listener() { @Override public void GetFinish() { // adapter = new NavDrawerListAdapter(PlayerActivity.this,Film.getServer()); // lv.setAdapter(adapter); contentUri = Uri.parse(Film.getServer().get(0).getLink()); if (player == null && contentUri != null) { preparePlayer(); ProgressBar progressBar = (ProgressBar) root.findViewById(R.id.progressBar); progressBar.setVisibility(View.GONE); ///////////////////////////////////////////// FragmentManager fragmentManager; FragmentTransaction fragmentTransaction; fragmentManager = getSupportFragmentManager(); fragmentTransaction = fragmentManager.beginTransaction(); VerticalGridFragment verticalFragment = new VerticalGridFragment(PlayerActivity.this, Film.getServer()); fragmentTransaction.replace(R.id.view_fm, verticalFragment); fragmentTransaction.commit(); } } }; recyclerViewDesign(); }
From source file:ch.uzh.supersede.feedbacklibrary.FeedbackActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Resources res = getResources(); if (userScreenshotChosenTask .equals(res.getString(R.string.supersede_feedbacklibrary_photo_capture_text))) { } else if (userScreenshotChosenTask .equals(res.getString(R.string.supersede_feedbacklibrary_library_chooser_text))) { galleryIntent();//from w w w . java 2 s . co m } } else { // The user denied the permission onRequestPermissionsResultDenied(requestCode, permissions, grantResults, Manifest.permission.READ_EXTERNAL_STORAGE, R.string.supersede_feedbacklibrary_external_storage_permission_text, getResources().getString( R.string.supersede_feedbacklibrary_external_storage_permission_text_instructions)); } break; case PERMISSIONS_REQUEST_RECORD_AUDIO: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Toast toast = Toast.makeText(getApplicationContext(), R.string.supersede_feedbacklibrary_record_audio_permission_granted_text, Toast.LENGTH_SHORT); toast.show(); } else { // The user denied the permission onRequestPermissionsResultDenied(requestCode, permissions, grantResults, Manifest.permission.RECORD_AUDIO, R.string.supersede_feedbacklibrary_record_audio_permission_text, getResources().getString( R.string.supersede_feedbacklibrary_record_audio_permission_text_instructions)); } break; } }
From source file:com.music.mybarr.activities.ExampleActivity.java
/** * Get the current user, and load their collection to start playback with. * Requires authorization and the Rdio app to be installed. */// ww w. j a v a2 s .co m private void getUserData() { if (!amIThere()) { Toast toast = Toast.makeText(getApplicationContext(), "You are not in the bar, you definetly should be!", Toast.LENGTH_LONG); toast.show(); return; } if (accessToken == null || accessTokenSecret == null) { doSomethingWithoutApp(); return; } Log.i(TAG, "Getting current user"); showGetUserDialog(); // Get the current user so we can find out their user ID and get their collection key List<NameValuePair> args = new LinkedList<NameValuePair>(); args.add(new BasicNameValuePair("extras", "username,displayName,lastSongPlayed")); rdio.apiCall("currentUser", args, new RdioApiCallback() { @Override public void onApiSuccess(JSONObject result) { dismissGetUserDialog(); try { result = result.getJSONObject("result"); username = result.getString("username"); lastSong = result.getJSONObject("lastSongPlayed").getString("artistKey"); //send data to server to check my music sendMyData(); } catch (Exception e) { Log.e(TAG, "Failed to handle JSONObject: ", e); } } @Override public void onApiFailure(String methodName, Exception e) { dismissGetUserDialog(); Log.e(TAG, "getCurrentUser failed. ", e); if (e instanceof RdioAuthorisationException) { doSomethingWithoutApp(); } } }); }
From source file:com.RSMSA.policeApp.Fragments.PaymentVerifierFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { contentView = (RelativeLayout) inflater.inflate(R.layout.fragment_payment_verifier, container, false); /**/* www . ja va 2 s . co m*/ * get the instances of the buttons at our view */ progressBar = (ProgressBar) contentView.findViewById(R.id.pbar_main); inputnformation = (RelativeLayout) contentView.findViewById(R.id.input_information); verificationResults = (ScrollView) contentView.findViewById(R.id.verification_results); driversOffenceList = (LinearLayout) contentView.findViewById(R.id.history_list_driver); vehiclesOffenceList = (LinearLayout) contentView.findViewById(R.id.history_list_car); vehiclesDetails = (LinearLayout) contentView.findViewById(R.id.vehicles_details); driversDetails = (LinearLayout) contentView.findViewById(R.id.drivers_details); nameTextView = (TextView) contentView.findViewById(R.id.name); licenseNumberTextView = (TextView) contentView.findViewById(R.id.license_number); addressTextView = (TextView) contentView.findViewById(R.id.address); genderTextView = (TextView) contentView.findViewById(R.id.gender); dateOfBirthTextView = (TextView) contentView.findViewById(R.id.date_of_birth); phoneNumberTextView = (TextView) contentView.findViewById(R.id.phone_number); makeTextView = (TextView) contentView.findViewById(R.id.make); plateNumberTextView = (TextView) contentView.findViewById(R.id.plate_number); typeTextView = (TextView) contentView.findViewById(R.id.type); colorTextView = (TextView) contentView.findViewById(R.id.color); scanBtn = (ImageView) contentView.findViewById(R.id.scan_button); verifyBtn = (Button) contentView.findViewById(R.id.verify); verifyBtn.setTypeface(MainOffence.Rosario_Bold); licenseEdittext = (EditText) contentView.findViewById(R.id.license_); verifyBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d("MainOffense", "verify button clicked"); licenceNumber = licenseEdittext.getText().toString(); if (licenceNumber.equals("")) { Toast toast = Toast.makeText(getActivity(), " Field Empty!", Toast.LENGTH_SHORT); toast.show(); } else { verifyBtn.setVisibility(View.INVISIBLE); progressBar.setVisibility(View.VISIBLE); progressBar.bringToFront(); NetAsync(view); } } }); final RadioButton licence = (RadioButton) contentView.findViewById(R.id.licence); licence.setTypeface(MainOffence.Roboto_Regular); final RadioButton plate = (RadioButton) contentView.findViewById(R.id.plate); plate.setTypeface(MainOffence.Roboto_Regular); licence.setChecked(true); licence.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { driversPaymentVerification = true; licenseEdittext.setHint("Enter Licence No"); } } }); plate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { driversPaymentVerification = false; licenseEdittext.setHint("Enter Plate No"); } } }); try { receivedNumber = getArguments().getString("licenceNumber"); } catch (Exception e) { } if (receivedNumber != null) { verifyLicenceNumber(receivedNumber); } else { try { receivedNumber = getArguments().getString("plateNumber"); } catch (Exception e) { } if (!receivedNumber.equals("") || receivedNumber != null) { driversPaymentVerification = false; plate.setChecked(true); licence.setChecked(false); verifyLicenceNumber(receivedNumber); } } return contentView; }
From source file:com.netcompss.ffmpeg4android_client.BaseVideo.java
public void toastsettext(String string1) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_activity, (ViewGroup) ((Activity) context).findViewById(R.id.toast_rl)); TextView txt = (TextView) layout.findViewById(R.id.toast_txt); txt.setText(string1);/*from ww w . j a v a 2s . co m*/ Toast tst = new Toast(context); tst.setGravity(Gravity.CENTER_VERTICAL, 0, 0); tst.setDuration(Toast.LENGTH_SHORT); tst.setView(layout); tst.show(); }
From source file:fm.smart.r1.activity.ItemActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); // could check here to see if this was suspended for login and go // straight to add_item ... setContentView(R.layout.item);/*w ww .j a v a 2 s .c o m*/ /* * ImageView author_icon = (ImageView) * findViewById(R.id.item_author_icon); if (item.author_image != null){ * author_icon.setImageBitmap(item.author_image); } */ TextView cue_and_pronunciation = (TextView) findViewById(R.id.cue_and_pronunciation); cue_and_pronunciation.setText(item.cue_text); // TODO handle case where item is null? TextView cue_part_of_speech = (TextView) findViewById(R.id.cue_part_of_speech); if (!TextUtils.equals(item.part_of_speech, "None")) { cue_part_of_speech.setText(item.part_of_speech); } else { cue_part_of_speech.setVisibility(View.INVISIBLE); } /* * TextView author = (TextView) findViewById(R.id.item_author); * author.setText(item.author_name); */ TextView response_and_pronunciation = (TextView) findViewById(R.id.response_and_pronunciation); response_and_pronunciation.setText(item.children[0][0]); TextView response_part_of_speech = (TextView) findViewById(R.id.response_part_of_speech); if (item.type != null && item.type.equals("meaning")) { item.type = "Translation"; } response_part_of_speech.setText(item.type); response_part_of_speech.setVisibility(View.INVISIBLE); ImageView cue_sound = (ImageView) findViewById(R.id.cue_sound); setSound(cue_sound, item.cue_sound_url, this, R.id.cue_sound, (String) item.item_node.atts.get("id"), item.cue_text); ImageView response_sound = (ImageView) findViewById(R.id.response_sound); setSound(response_sound, item.response_sound_url, this, R.id.response_sound, (String) item.item_node.atts.get("id"), item.response_node.getFirstContents("text")); EfficientAdapter adapter = new EfficientAdapter(ItemActivity.this, item.sentence_vector); setListAdapter(adapter); if (adapter.getCount() == 0 && !ItemActivity.shown_toast) { Toast t = Toast.makeText(this, "Know a good example? Click the menu button to add one", 250); t.setGravity(Gravity.CENTER, 0, 0); t.show(); ItemActivity.shown_toast = true; } // notify(); }
From source file:com.grass.caishi.cc.activity.SettingUserActivity.java
/** * ?uri??// w w w . j a va2s . c om * * @param selectedImage */ private File Uritofile(Uri selectedImage) { File file = null; Cursor cursor = this.getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } file = new File(picturePath); // sendPicture(picturePath); } else { file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return null; } } return file; }