use of com.manan.dev.ec2018app.Models.QRTicketModel in project EC2018App by Manan-YMCA.
the class TicketLayoutAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
final QRTicketModel singleItem = itemsList.get(position);
EventDetails currEvent = new EventDetails();
DatabaseController mDatabaseController = new DatabaseController(mContext);
currEvent = mDatabaseController.retreiveEventsByID(singleItem.getEventID());
if (currEvent.getmFees() == 0) {
holder.feeStatus.setTextColor(mContext.getResources().getColor(R.color.status_free));
holder.feeStatus.setText("FREE");
} else if (singleItem.getPaymentStatus() == 0) {
holder.feeStatus.setTextColor(mContext.getResources().getColor(R.color.primaryFocused));
holder.feeStatus.setText("PENDING");
} else if (singleItem.getPaymentStatus() == 1) {
holder.feeStatus.setTextColor(mContext.getResources().getColor(R.color.status_paid));
holder.feeStatus.setText("PAID");
}
mProgress = new ProgressDialog(mContext);
mProgress.setMessage("Showing your ticket.");
mProgress.setTitle("Loading...");
mProgress.setCanceledOnTouchOutside(false);
TicketsGenerator generate = new TicketsGenerator();
Bitmap currTicket = generate.GenerateClick(singleItem.getQRcode(), mContext, (int) mContext.getResources().getDimension(R.dimen.onefifty), (int) mContext.getResources().getDimension(R.dimen.onefifty), 80, 80);
holder.itemImage.setImageBitmap(currTicket);
holder.eventName.setText(currEvent.getmName());
holder.eventFee.setText("RS " + String.valueOf(currEvent.getmFees()));
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currEvent.getmStartTime());
SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd, yyyy", Locale.ENGLISH);
String formattedDate = sdf.format(cal.getTime());
holder.eventDate.setText(formattedDate);
SimpleDateFormat sdf1 = new SimpleDateFormat("kk:mm", Locale.US);
String formattedTime = sdf1.format(cal.getTime());
holder.eventTime.setText(formattedTime);
fm = ((Activity) mContext).getFragmentManager();
// final EventDetails finalCurrEvent = currEvent;
// holder.cardView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// // mProgress.show();
//
// holder.pb.setVisibility(View.VISIBLE);
//
// MDToast.makeText(mContext, "Loading Ticket...", Toast.LENGTH_SHORT, MDToast.TYPE_INFO).show();
// Bundle bundle = new Bundle();
// bundle.putString("qrcodestring", singleItem.getQRcode());
// bundle.putString("eventid", finalCurrEvent.getmEventId());
// bundle.putInt("activity", 0);
// bundle.putInt("paymentStatus", singleItem.getPaymentStatus());
// bundle.putInt("arrivalStatus", singleItem.getArrivalStatus());
// // set Fragmentclass Arguments
//
// QRCodeActivity fragobj = new QRCodeActivity();
// fragobj.setArguments(bundle);
// fragobj.show(fm, "TAG");
// }
// });
}
use of com.manan.dev.ec2018app.Models.QRTicketModel in project EC2018App by Manan-YMCA.
the class Tickets method reload.
private void reload(final String[] phone) {
String url = getResources().getString(R.string.get_events_qr_code);
url += phone;
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
mProgress.dismiss();
try {
JSONObject obj1 = new JSONObject(response);
JSONArray ticketDetails = obj1.getJSONArray("data");
for (int i = 0; i < ticketDetails.length(); i++) {
JSONObject obj2 = ticketDetails.getJSONObject(i);
QRTicketModel TicketModel = new QRTicketModel();
TicketModel.setPaymentStatus(obj2.getInt("paymentstatus"));
TicketModel.setArrivalStatus(obj2.getInt("arrived"));
TicketModel.setQRcode(obj2.getString("qrcode"));
TicketModel.setEventID(obj2.getString("eventid"));
TicketModel.setTimeStamp(obj2.getLong("timestamp"));
userTickets.add(TicketModel);
}
mIncomingHandler.sendEmptyMessage(0);
}// Try and catch are included to handle any errors due to JSON
catch (Exception e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mProgress.dismiss();
}
});
queue.add(request);
}
Aggregations