Back to project page RoboBinding-gallery.
The source code is released under:
Apache License
If you think the Android project RoboBinding-gallery listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.robobinding.gallery.presentationmodel; /* www. j av a2 s. com*/ import org.robobinding.annotation.PresentationModel; import org.robobinding.gallery.model.MemoryProductStore; import org.robobinding.gallery.model.Product; import android.view.MenuItem; import android.widget.AdapterView.AdapterContextMenuInfo; /** * @author Cheng Wei * @version $Revision: 1.0 $ * @since 1.0 */ @PresentationModel public class ContextMenuPresentationModel { private MemoryProductStore productStore; private ProductOperationListener productOperationListener; public ContextMenuPresentationModel(MemoryProductStore productStore, ProductOperationListener productOperationListener) { this.productStore = productStore; this.productOperationListener = productOperationListener; } public void deleteProduct(MenuItem menuItem) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) menuItem.getMenuInfo(); Product deletedProduct = productStore.remove(menuInfo.position); productOperationListener.onProductDeleted(deletedProduct); } public interface ProductOperationListener { void onProductDeleted(Product deletedProduct); } }