Xamarin Mobile Application Development for Android Second Edition by 2015
Author:2015
Language: eng
Format: epub
Publisher: Packt Publishing
Creating DeletePOI()
Like SavePOI(), the DeletePOI() method was created to simplify the logic in OnOptionsItemSelected(). Before deleting the POI, we must ask the user to reconfirm by showing a dialog. Later in this chapter, we will show you how to display a confirmation prompt before initiating the deleted request.
We created the CreateOrUpdatePOIAsync() method in POIDetailActivity, let's now add another new method named DeletePOIAsync(). This method performs pretty much the same task as the CreateOrUpdatePOIAsync() method does in POIDetailActivity. It checks for the Internet connection availability, initiates the delete operation asynchronously, and finally, notifies the user with a toast message.
Add the following DeletePOIAsync method to your POIDetailActivity class:
public async void DeletePOIAsync(){ POIService service = new POIService (); if (!service.isConnected(this)) { Toast toast = Toast.MakeText (this, "Not conntected to internet. Please check your device network settings.", ToastLength.Short); toast.Show (); return; } string response = await service.DeletePOIAsync (_poi.id); if (!string.IsNullOrEmpty (response)) { Toast toast = Toast.MakeText (this, String.Format ("{0} deleted.", _poi.Name), ToastLength.Short); toast.Show(); Finish (); } else { Toast toast = Toast.MakeText (this, "Something went Wrong!", ToastLength.Short); toast.Show(); } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6532)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Kotlin in Action by Dmitry Jemerov(5062)
Odoo 15 Development Essentials - Fifth Edition by Daniel Reis & Greg Mader(3343)
Odoo 15 Development Essentials by Daniel Reis(2814)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2529)
Learning Angular - Second Edition by Christoffer Noring(2358)
Pride and Prejudice by Jane Austen(2350)
Mobile Forensics Cookbook by Igor Mikhaylov(2017)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Bulletproof Android: Practical Advice for Building Secure Apps (Developer's Library) by Godfrey Nolan(1872)
Android Development with Kotlin by Marcin Moskala & Igor Wojda(1797)
Building Android UIs with Custom Views by Raimon Ràfols Montané(1789)
1936941139 (N) by Bob Rosenthal(1731)
Building Progressive Web Apps: Bringing the Power of Native to the Browser by Ater Tal(1725)
Hands-On Internet of Things with MQTT by Tim Pulver(1706)
Android App Development by Franceschi Hervé J.;(1702)
Ember.js in Action by Joachim Haagen Skeie(1689)
Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz(1656)
