order history screen
This commit is contained in:
@@ -87,12 +87,17 @@ public class LoginActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void login(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<LoginCustomerResponseModel> call = ApiService.apiInterface.login(
|
||||
emailPizzalinkEditText.getText(), passwordPizzalinkEditText.getText());
|
||||
call.enqueue(new Callback<LoginCustomerResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(Call<LoginCustomerResponseModel> call, Response<LoginCustomerResponseModel> response) {
|
||||
if(response.isSuccessful()){
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body() != null &&
|
||||
response.body().isSuccess()){
|
||||
response.body().getData().checkNull();
|
||||
SharedPrefsHelper.saveUser(response.body().getData());
|
||||
SharedPrefsHelper.saveCustomerToken(response.body().getData().getToken());
|
||||
SharedPrefsHelper.setCustomerLoggedIn(true);
|
||||
@@ -104,6 +109,7 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<LoginCustomerResponseModel> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzalink.android.model.UserModel;
|
||||
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
|
||||
import ch.pizzalink.android.view.PizzalinkButton;
|
||||
import ch.pizzalink.android.view.PizzalinkEditText;
|
||||
@@ -95,6 +96,7 @@ public class RegisterActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void registerUser(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<LoginCustomerResponseModel> call = ApiService.apiInterface.register(
|
||||
pizzalinkEditTextList.get(0).getText(), pizzalinkEditTextList.get(1).getText(),pizzalinkEditTextList.get(2).getText(),
|
||||
pizzalinkEditTextList.get(3).getText(),pizzalinkEditTextList.get(4).getText(),pizzalinkEditTextList.get(5).getText(),
|
||||
@@ -103,7 +105,11 @@ public class RegisterActivity extends BaseActivity {
|
||||
call.enqueue(new Callback<LoginCustomerResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(Call<LoginCustomerResponseModel> call, Response<LoginCustomerResponseModel> response) {
|
||||
if(response.isSuccessful()){
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body() != null &&
|
||||
response.body().isSuccess()){
|
||||
response.body().getData().checkNull();
|
||||
SharedPrefsHelper.saveUser(response.body().getData());
|
||||
SharedPrefsHelper.saveCustomerToken(response.body().getData().getToken());
|
||||
SharedPrefsHelper.setCustomerLoggedIn(true);
|
||||
@@ -115,6 +121,7 @@ public class RegisterActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<LoginCustomerResponseModel> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -47,7 +47,9 @@ public class SplashActivity extends BaseActivity {
|
||||
call.enqueue(new Callback<CategoryResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(Call<CategoryResponseModel> call, Response<CategoryResponseModel> response) {
|
||||
if(response.isSuccessful()){
|
||||
if(response.isSuccessful() &&
|
||||
response.body() != null &&
|
||||
response.body().isSuccess()){
|
||||
CategoryModel.checkNull(response.body().getData());
|
||||
SharedPrefsHelper.saveCategoryList(response.body().getData());
|
||||
checkCustomerToken();
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package ch.pizzalink.android.adapter.recycler;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.helper.ImageLoadHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.OrderModel;
|
||||
import ch.pizzalink.android.model.PizzaModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 04/10/2017.
|
||||
*/
|
||||
|
||||
public class OrderHistoryRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
|
||||
private final int HOLDER_ORDER = 0;
|
||||
private final int HOLDER_SPACE = 1;
|
||||
|
||||
private ArrayList<OrderModel> orderHistoryList = new ArrayList<>();
|
||||
private RecyclerItemClickListener recyclerItemClickListener;
|
||||
|
||||
public static class OrderViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.orderTotalTextView) TextView orderTotalTextView;
|
||||
@BindView(R.id.orderDateTextView) TextView orderDateTextView;
|
||||
@BindView(R.id.orderStatusTextView) TextView orderStatusTextView;
|
||||
@BindView(R.id.cancelOrderImageView) ImageView cancelOrderImageView;
|
||||
|
||||
public OrderViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
cancelOrderImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(cancelOrderImageView, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class SpaceViewHolder extends RecyclerView.ViewHolder{
|
||||
public SpaceViewHolder(final View view) {
|
||||
super(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
|
||||
if(position == orderHistoryList.size())
|
||||
return HOLDER_SPACE;
|
||||
|
||||
return HOLDER_ORDER;
|
||||
}
|
||||
|
||||
public OrderHistoryRecyclerAdapter(ArrayList<OrderModel> orderHistoryList,
|
||||
RecyclerItemClickListener recyclerItemClickListener){
|
||||
this.orderHistoryList = orderHistoryList;
|
||||
this.recyclerItemClickListener = recyclerItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
|
||||
RecyclerView.ViewHolder viewHolder;
|
||||
View view;
|
||||
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
|
||||
|
||||
switch (viewType){
|
||||
|
||||
case HOLDER_ORDER:
|
||||
view = inflater.inflate(R.layout.row_order_history, viewGroup, false);
|
||||
viewHolder = new OrderViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE:
|
||||
view = inflater.inflate(R.layout.row_space, viewGroup, false);
|
||||
viewHolder = new SpaceViewHolder(view);
|
||||
break;
|
||||
|
||||
default:
|
||||
view = inflater.inflate(R.layout.row_order_history, viewGroup, false);
|
||||
viewHolder = new OrderViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
}
|
||||
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
|
||||
switch (holder.getItemViewType()){
|
||||
case HOLDER_ORDER :
|
||||
OrderViewHolder orderViewHolder = (OrderViewHolder) holder;
|
||||
orderViewHolder.orderTotalTextView.setText(orderHistoryList.get(position).getTotalString());
|
||||
orderViewHolder.orderDateTextView.setText(orderHistoryList.get(position).getFormattedCreateDate());
|
||||
orderViewHolder.orderStatusTextView.setText(orderHistoryList.get(position).getStatus());
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE :
|
||||
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return orderHistoryList.size() + 1 ;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,5 +8,7 @@ public class ApiEndPoints {
|
||||
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories" + SUFFIX;
|
||||
public static final String API_REGISTER = PREFIX + "signUp" + SUFFIX;
|
||||
public static final String API_LOGIN = PREFIX + "login" + SUFFIX;
|
||||
public static final String API_LOGOUT = PREFIX + "logout" + SUFFIX;
|
||||
public static final String API_GET_ORDER_HISTORY = PREFIX + "getOrders" + SUFFIX;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
package ch.pizzalink.android.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import ch.pizzalink.android.model.OrderModel;
|
||||
import ch.pizzalink.android.model.responseModel.BaseResponseModel;
|
||||
import ch.pizzalink.android.model.responseModel.CategoryResponseModel;
|
||||
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
|
||||
import ch.pizzalink.android.model.responseModel.OrderHistoryResponseModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
@@ -37,6 +44,13 @@ public interface ApiInterface {
|
||||
@POST(ApiEndPoints.API_LOGIN)
|
||||
Call<LoginCustomerResponseModel> login(@Field("email") String email, @Field("password") String password);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_LOGOUT)
|
||||
Call<BaseResponseModel> logout(@Field("token") String customerToken);
|
||||
|
||||
@POST(ApiEndPoints.API_GET_ORDER_HISTORY)
|
||||
Call<OrderHistoryResponseModel> getOrderHistory(@Body HashMap<String, Object> body);
|
||||
|
||||
|
||||
/*
|
||||
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||||
|
||||
@@ -1,13 +1,33 @@
|
||||
package ch.pizzalink.android.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.adapter.recycler.OrderHistoryRecyclerAdapter;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.SessionHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.OrderModel;
|
||||
import ch.pizzalink.android.model.responseModel.OrderHistoryResponseModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 20/09/2017.
|
||||
@@ -15,10 +35,15 @@ import ch.pizzalink.android.R;
|
||||
|
||||
public class HistoryFragment extends BaseFragment {
|
||||
|
||||
@BindView(R.id.orderHistoryRecyclerView) RecyclerView orderHistoryRecyclerView;
|
||||
|
||||
@BindString(R.string.bottom_nav_menu_item_history) String fragmentTitle;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "historyFragment";
|
||||
|
||||
private ArrayList<OrderModel> orderHistoryList = new ArrayList<>();
|
||||
private OrderHistoryRecyclerAdapter orderHistoryRecyclerAdapter;
|
||||
|
||||
public HistoryFragment() {}
|
||||
|
||||
public static HistoryFragment newInstance() {
|
||||
@@ -35,10 +60,59 @@ public class HistoryFragment extends BaseFragment {
|
||||
View view = inflater.inflate(R.layout.fragment_history, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
initViews();
|
||||
getOrderHistory();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
setPizzalinkToolbarFields(false, fragmentTitle);
|
||||
initRecyclerView();
|
||||
}
|
||||
|
||||
private void initRecyclerView(){
|
||||
orderHistoryRecyclerAdapter = new OrderHistoryRecyclerAdapter(orderHistoryList, new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
|
||||
}
|
||||
});
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
|
||||
orderHistoryRecyclerView.setLayoutManager(layoutManager);
|
||||
orderHistoryRecyclerView.setAdapter(orderHistoryRecyclerAdapter);
|
||||
}
|
||||
|
||||
private void getOrderHistory(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("token", SessionHelper.getCustomerToken().getToken());
|
||||
Call<OrderHistoryResponseModel> call = ApiService.apiInterface.getOrderHistory(params);
|
||||
call.enqueue(new Callback<OrderHistoryResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(Call<OrderHistoryResponseModel> call, Response<OrderHistoryResponseModel> response) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body() != null &&
|
||||
response.body().isSuccess()){
|
||||
fillAndNotifyOrderHistoryList(response.body().getData());
|
||||
}
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<OrderHistoryResponseModel> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void fillAndNotifyOrderHistoryList(ArrayList<OrderModel> orderList){
|
||||
if(orderList == null)
|
||||
return;
|
||||
OrderModel.checkNull(orderList);
|
||||
orderHistoryList.clear();
|
||||
orderHistoryList.addAll(orderList);
|
||||
orderHistoryRecyclerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
package ch.pizzalink.android.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.activity.LoginActivity;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.SessionHelper;
|
||||
import ch.pizzalink.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzalink.android.model.responseModel.BaseResponseModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 18/09/2017.
|
||||
@@ -15,6 +30,8 @@ import ch.pizzalink.android.R;
|
||||
|
||||
public class ProfileFragment extends BaseFragment {
|
||||
|
||||
@BindView(R.id.logoutButton) Button logoutButton;
|
||||
|
||||
@BindString(R.string.bottom_nav_menu_item_profile) String fragmentTitle;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "profileFragment";
|
||||
@@ -38,7 +55,44 @@ public class ProfileFragment extends BaseFragment {
|
||||
return view;
|
||||
}
|
||||
|
||||
@OnClick(R.id.logoutButton)
|
||||
public void onClick(View view){
|
||||
logOutOnWeb();
|
||||
}
|
||||
|
||||
|
||||
private void initViews(){
|
||||
setPizzalinkToolbarFields(false, fragmentTitle);
|
||||
}
|
||||
|
||||
private void logOutOnWeb(){
|
||||
DialogHelper.showLoadingDialog();
|
||||
Call<BaseResponseModel> call = ApiService.apiInterface.logout(SessionHelper.getCustomerToken().getToken());
|
||||
call.enqueue(new Callback<BaseResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(Call<BaseResponseModel> call, Response<BaseResponseModel> response) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
if(response.isSuccessful() &&
|
||||
response.body() != null &&
|
||||
response.body().isSuccess())
|
||||
logoutLocally();
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<BaseResponseModel> call, Throwable t) {
|
||||
DialogHelper.hideLoadingDialog();
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void logoutLocally(){
|
||||
SharedPrefsHelper.clearCustomerInfo();
|
||||
SharedPrefsHelper.clearCustomerToken();
|
||||
SharedPrefsHelper.setCustomerLoggedIn(false);
|
||||
BaseActivity.currentActivity.startActivity(new Intent(BaseActivity.currentActivity, LoginActivity.class));
|
||||
BaseActivity.currentActivity.finishAffinity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package ch.pizzalink.android.helper;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 04/10/2017.
|
||||
*/
|
||||
|
||||
public class DateTimeHelper {
|
||||
|
||||
public static long getMillisFromDateString(String dateString){
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = null;
|
||||
try {
|
||||
Date date = formatter.parse(dateString);
|
||||
calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
return calendar.getTimeInMillis();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFormattedDateFromDateString(String dateString){
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = null;
|
||||
try {
|
||||
Date date = formatter.parse(dateString);
|
||||
calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
return calendar.get(Calendar.DAY_OF_MONTH) + " " +
|
||||
getMonthName(calendar.get(Calendar.MONTH)) + " " +
|
||||
calendar.get(Calendar.YEAR);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static String getMonthName(int monthIndex){
|
||||
switch (monthIndex){
|
||||
case 0:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_january);
|
||||
case 1:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_february);
|
||||
case 2:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_march);
|
||||
case 3:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_april);
|
||||
case 4:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_may);
|
||||
case 5:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_jun);
|
||||
case 6:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_july);
|
||||
case 7:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_august);
|
||||
case 8:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_september);
|
||||
case 9:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_october);
|
||||
case 10:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_november);
|
||||
case 11:
|
||||
return BaseActivity.currentActivity.getString(R.string.month_name_december);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import ch.pizzalink.android.activity.BaseActivity;
|
||||
|
||||
public class DialogHelper {
|
||||
|
||||
private static MaterialDialog loadingDialog;
|
||||
|
||||
public static void showDialogWithPositiveButton(Context context, String content) {
|
||||
|
||||
new MaterialDialog.Builder(context)
|
||||
@@ -63,6 +65,24 @@ public class DialogHelper {
|
||||
.show();
|
||||
}
|
||||
|
||||
public static void showLoadingDialog(){
|
||||
if(loadingDialog != null && loadingDialog.isShowing())
|
||||
return;
|
||||
loadingDialog = new MaterialDialog.Builder(BaseActivity.currentActivity)
|
||||
.content("Content")
|
||||
.cancelable(false)
|
||||
.progress(true, 0)
|
||||
.progressIndeterminateStyle(true)
|
||||
.show();
|
||||
}
|
||||
|
||||
public static void hideLoadingDialog(){
|
||||
if(loadingDialog != null && loadingDialog.isShowing()){
|
||||
loadingDialog.dismiss();
|
||||
loadingDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
public static void showDialogWithPositiveButtonCallback(Context context, String content,
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import ch.pizzalink.android.helper.DateTimeHelper;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 26/09/2017.
|
||||
*/
|
||||
@@ -28,22 +30,19 @@ public class CustomerTokenModel {
|
||||
|
||||
public boolean isCustomerTokenAlive(){
|
||||
long millis7days = 86400000 * 7;
|
||||
return (getTokenDeathDate(expiresIn).getTimeInMillis() - System.currentTimeMillis() >= millis7days);
|
||||
return DateTimeHelper.getMillisFromDateString(expiresIn) - System.currentTimeMillis() >= millis7days;
|
||||
}
|
||||
|
||||
private Calendar getTokenDeathDate(String tokenDeathTime){
|
||||
public void checkNull(){
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = null;
|
||||
try {
|
||||
Date date = formatter.parse(tokenDeathTime);
|
||||
calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
return calendar;
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return calendar;
|
||||
}
|
||||
if(token == null)
|
||||
token = "";
|
||||
|
||||
if(expiresIn == null)
|
||||
expiresIn = "";
|
||||
|
||||
if(refreshToken == null)
|
||||
refreshToken = "";
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
|
||||
133
app/src/main/java/ch/pizzalink/android/model/OrderModel.java
Normal file
133
app/src/main/java/ch/pizzalink/android/model/OrderModel.java
Normal file
@@ -0,0 +1,133 @@
|
||||
package ch.pizzalink.android.model;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ch.pizzalink.android.helper.DateTimeHelper;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 04/10/2017.
|
||||
*/
|
||||
|
||||
public class OrderModel {
|
||||
|
||||
@Expose
|
||||
@SerializedName("order_id")
|
||||
private String id;
|
||||
|
||||
@Expose
|
||||
@SerializedName("date_added")
|
||||
private String createDate;
|
||||
|
||||
@Expose
|
||||
@SerializedName("currency_code")
|
||||
private String currencyCode;
|
||||
|
||||
@Expose
|
||||
@SerializedName("currency_value")
|
||||
private String currencyValue;
|
||||
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String status;
|
||||
private String total;
|
||||
|
||||
public int getTotalInt(){
|
||||
try {
|
||||
return Integer.valueOf(total);
|
||||
}catch (Exception e){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public String getTotalString(){
|
||||
return currencyCode + " " + total;
|
||||
}
|
||||
|
||||
public String getFormattedCreateDate(){
|
||||
return DateTimeHelper.getFormattedDateFromDateString(createDate);
|
||||
}
|
||||
|
||||
private void checkNull(){
|
||||
|
||||
if(id == null)
|
||||
id = "";
|
||||
|
||||
if(createDate == null)
|
||||
createDate = "";
|
||||
|
||||
if(currencyCode == null)
|
||||
currencyCode = "";
|
||||
|
||||
if(currencyValue == null)
|
||||
currencyValue = "";
|
||||
|
||||
if(firstname == null)
|
||||
firstname = "";
|
||||
|
||||
if(lastname == null)
|
||||
lastname = "";
|
||||
|
||||
if(status == null)
|
||||
status = "";
|
||||
|
||||
if(total == null)
|
||||
total = "";
|
||||
}
|
||||
|
||||
public static void checkNull(ArrayList<OrderModel> orderHistoryList){
|
||||
for(OrderModel orderModel : orderHistoryList){
|
||||
orderModel.checkNull();
|
||||
}
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrency_code(String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
public String getCurrencyValue() {
|
||||
return currencyValue;
|
||||
}
|
||||
|
||||
public void setCurrencyValue(String currencyValue) {
|
||||
this.currencyValue = currencyValue;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,27 @@ public class UserModel {
|
||||
private String telephone;
|
||||
private CustomerTokenModel token;
|
||||
|
||||
public void checkNull(){
|
||||
|
||||
if(id == null)
|
||||
id = "";
|
||||
|
||||
if(firstname == null)
|
||||
firstname = "";
|
||||
|
||||
if(lastname == null)
|
||||
lastname = "";
|
||||
|
||||
if(email == null)
|
||||
email = "";
|
||||
|
||||
if(telephone == null)
|
||||
telephone = "";
|
||||
|
||||
if(token != null)
|
||||
token.checkNull();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package ch.pizzalink.android.model.responseModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ch.pizzalink.android.model.OrderModel;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 04/10/2017.
|
||||
*/
|
||||
|
||||
public class OrderHistoryResponseModel extends BaseResponseModel{
|
||||
|
||||
private ArrayList<OrderModel> data;
|
||||
|
||||
public ArrayList<OrderModel> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(ArrayList<OrderModel> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
<android.support.v7.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/orderHistoryRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Orders Fragment"
|
||||
android:layout_centerInParent="true"
|
||||
android:textColor="@color/black"/>
|
||||
|
||||
</RelativeLayout>
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
@@ -12,4 +12,14 @@
|
||||
android:layout_centerInParent="true"
|
||||
android:textColor="@color/black"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/logoutButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/button_logout"
|
||||
style="@style/PizzalinkButton"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
113
app/src/main/res/layout/row_order_history.xml
Normal file
113
app/src/main/res/layout/row_order_history.xml
Normal file
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
app:cardCornerRadius="4dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_marginEnd="12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/order_history_total"
|
||||
android:textColor="@color/black"
|
||||
android:padding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/orderTotalTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="25 CHF"
|
||||
android:textColor="@color/black"
|
||||
android:padding="12dp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cancelOrderImageView"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_cancel"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/order_history_date"
|
||||
android:textColor="@color/black"
|
||||
android:padding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/orderDateTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="5 Oct. 2017"
|
||||
android:textColor="@color/black"
|
||||
android:padding="12dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/order_history_status"
|
||||
android:textColor="@color/black"
|
||||
android:padding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/orderStatusTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Pending"
|
||||
android:textColor="@color/black"
|
||||
android:padding="12dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
@@ -71,11 +71,36 @@
|
||||
<string name="register_text">KAYIT OL</string>
|
||||
<!-- LoginActivity-->
|
||||
|
||||
<!-- ProfileFragment-->
|
||||
<string name="button_logout">ÇIKIŞ YAP</string>
|
||||
<!-- ProfileFragment-->
|
||||
|
||||
<!-- OrderHistoryFragment-->
|
||||
<string name="order_history_total">Total :</string>
|
||||
<string name="order_history_date">Date</string>
|
||||
<string name="order_history_status">Status</string>
|
||||
<!-- OrderHistoryFragment-->
|
||||
|
||||
<string name="alert">Uyarı</string>
|
||||
<string name="error_message">Bir hata oluştu.</string>
|
||||
<string name="no_network_message">İnternet bağlanıtısı yok. Lütfen daha sonra tekrar deneyiniz.</string>
|
||||
<string name="bad_request">Bad Request</string>
|
||||
<string name="failed">Connection failed</string>
|
||||
<string name="ok">Tamam</string>
|
||||
<string name="loading">Lütfen bekleyiniz...</string>
|
||||
|
||||
<string name="month_name_january">Jan.</string>
|
||||
<string name="month_name_february">Feb.</string>
|
||||
<string name="month_name_march">Mar.</string>
|
||||
<string name="month_name_april">Apr.</string>
|
||||
<string name="month_name_may">May</string>
|
||||
<string name="month_name_jun">June</string>
|
||||
<string name="month_name_july">July</string>
|
||||
<string name="month_name_august">Aug.</string>
|
||||
<string name="month_name_september">Sept</string>
|
||||
<string name="month_name_october">Oct.</string>
|
||||
<string name="month_name_november">Nov.</string>
|
||||
<string name="month_name_december">Dec.</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user