Search in sources :

Example 6 with QRTicketModel

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");
// }
// });
}
Also used : Bitmap(android.graphics.Bitmap) Calendar(java.util.Calendar) TicketsGenerator(com.manan.dev.ec2018app.Utilities.TicketsGenerator) DatabaseController(com.manan.dev.ec2018app.DatabaseHandler.DatabaseController) ProgressDialog(android.app.ProgressDialog) SimpleDateFormat(java.text.SimpleDateFormat) QRTicketModel(com.manan.dev.ec2018app.Models.QRTicketModel) EventDetails(com.manan.dev.ec2018app.Models.EventDetails)

Example 7 with QRTicketModel

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);
}
Also used : Response(com.android.volley.Response) VolleyError(com.android.volley.VolleyError) JSONObject(org.json.JSONObject) RequestQueue(com.android.volley.RequestQueue) StringRequest(com.android.volley.toolbox.StringRequest) JSONArray(org.json.JSONArray) QRTicketModel(com.manan.dev.ec2018app.Models.QRTicketModel)

Aggregations

QRTicketModel (com.manan.dev.ec2018app.Models.QRTicketModel)7 RequestQueue (com.android.volley.RequestQueue)3 Response (com.android.volley.Response)3 VolleyError (com.android.volley.VolleyError)3 StringRequest (com.android.volley.toolbox.StringRequest)3 JSONArray (org.json.JSONArray)3 JSONObject (org.json.JSONObject)3 ProgressDialog (android.app.ProgressDialog)2 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 DatabaseController (com.manan.dev.ec2018app.DatabaseHandler.DatabaseController)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 NavigationView (android.support.design.widget.NavigationView)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1