Android Open Source - openpizza-android Send Order From Project Back to project page openpizza-android .
License The source code is released under:
MIT License
If you think the Android project openpizza-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package de.openpizza.android.ordermodul;
/ * f r o m w w w . j a v a 2 s . c o m * /
import java.util.List;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import android.app.Activity;
import android.content.Context;
import de.openpizza.android.service.OrderContentService;
import de.openpizza.android.service.data.OrderContentRequest;
import de.openpizza.android.service.data.OrderContentResponse;
import de.openpizza.android.service.restapi.RESTServiceHandler;
public class SendOrder implements
RESTServiceHandler<List<OrderContentResponse>> {
private Context context;
private OrderBean orderBean;
public SendOrder(OrderBean bean, Context context, Activity activity) {
this.orderBean = bean;
this.context = context;
}
public void sendProductList() {
OrderContentService contentService = new OrderContentService(
(Activity) context);
contentService.setNickname(orderBean.getNickname());
contentService.setId(orderBean.getId());
if (!orderBean.productListIsEmpty()) {
OrderContentRequest orderContentRequest = new OrderContentRequest();
orderContentRequest.setProducts(orderBean.getProductList());
contentService.httpPost(orderContentRequest, this );
}
}
public void startPulling(Activity activity) {
ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
final OrderContentService service = new OrderContentService(activity);
service.setId(orderBean.getId());
final SendOrder sendOrder = this ;
exec.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
service.httpGet("orders/" + orderBean.getId()
+ "/items" , "" , sendOrder);
}
});
}
}, 0, 5, TimeUnit.SECONDS); // execute every 60 seconds
}
@Override
public void handleGetResponse(List<OrderContentResponse> response) {
orderBean.setProductFormOthers(response);
}
@Override
public void handlePostResponse(List<OrderContentResponse> response) {
// TODO: Ist im service aus kommentiert
// orderBean.setProductFormOthers(response);
}
@Override
public void handlePutResponse(List<OrderContentResponse> Response) {
// TODO Auto-generated method stub
}
}
Java Source Code List de.openpizza.android.Category.java de.openpizza.android.activitys.shopOverview.ShopOverviewActivity.java de.openpizza.android.activitys.shopOverview.ShopOverviewCoordinator.java de.openpizza.android.activitys.shopOverview.ShopOverviewFragment.java de.openpizza.android.activitys.shopOverview.shopList.ShopListArrayAdapter.java de.openpizza.android.activitys.shopOverview.shopList.ShopListItem.java de.openpizza.android.activitys.shopOverview.shopList.ShopListView.java de.openpizza.android.activitys.shopOverview.shopList.ShopList.java de.openpizza.android.activitys.shop.ShopView.java de.openpizza.android.ordermodul.CreateOrder.java de.openpizza.android.ordermodul.DummyProvider.java de.openpizza.android.ordermodul.ModelChangedListener.java de.openpizza.android.ordermodul.NicknameHandler.java de.openpizza.android.ordermodul.OrderBean.java de.openpizza.android.ordermodul.OrderFacade.java de.openpizza.android.ordermodul.OrderSyncAdapter.java de.openpizza.android.ordermodul.Order.java de.openpizza.android.ordermodul.SendOrder.java de.openpizza.android.service.OrderContentService.java de.openpizza.android.service.OrderService.java de.openpizza.android.service.ShopIdService.java de.openpizza.android.service.ShopsService.java de.openpizza.android.service.data.DeliveryAddress.java de.openpizza.android.service.data.OrderContentRequest.java de.openpizza.android.service.data.OrderContentResponse.java de.openpizza.android.service.data.OrderRequest.java de.openpizza.android.service.data.OrderResponse.java de.openpizza.android.service.data.Product.java de.openpizza.android.service.data.Shop.java de.openpizza.android.service.restapi.RESTServiceCall.java de.openpizza.android.service.restapi.RESTServiceHandler.java de.openpizza.android.service.restapi.RESTService.java de.openpizza.android.views.LoginActivity.java de.openpizza.android.views.OrderActivity.java de.openpizza.android.views.ProductView.java de.openpizza.android.views.SendOrderActivity.java de.openpizza.android.views.ShopView.java de.openpizza.android.views.antihost.LinkActivity.java de.openpizza.android.views.antihost.OrderActivityAntihost.java de.openpizza.android.views.antihost.ShopViewAntihost.java de.openpizza.android.views.host.OrderActivityHost.java de.openpizza.android.views.host.ShopViewHostEdit.java de.openpizza.android.views.host.ShopViewHost.java de.openpizza.android.views.shopview.CategoryFragment.java de.openpizza.android.views.shopview.ShopViewTabsPagerAdapter.java de.openpizza.android.views.shopview.ShowViewFragment.java