Search in sources :

Example 1 with QRTicketModel

use of com.manan.dev.ec2018app.Models.QRTicketModel in project EC2018App by Manan-YMCA.

the class ContentActivity method checkCount.

private void checkCount(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);
                }
            }// 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) GraphResponse(com.facebook.GraphResponse) 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)

Example 2 with QRTicketModel

use of com.manan.dev.ec2018app.Models.QRTicketModel in project EC2018App by Manan-YMCA.

the class DatabaseController method retrieveTicketsByID.

public QRTicketModel retrieveTicketsByID(String EventId) {
    QRTicketModel qrTicketModel = new QRTicketModel();
    if (checkIfValueExists1(EventId)) {
        SQLiteDatabase db = getReadableDatabase();
        String[] projection = { Schema.DbEntry.EVENT_ID, Schema.DbEntry.QR_CODE, Schema.DbEntry.PAYMENT_STATUS, Schema.DbEntry.ARRIVAL_STATUS };
        Cursor readCursor = db.query(Schema.DbEntry.QR_TICKET_TABLE_NAME, projection, Schema.DbEntry.EVENT_ID + " = ?", new String[] { EventId }, null, null, null);
        readCursor.moveToFirst();
        qrTicketModel = retrieveTickets(readCursor);
        readCursor.close();
        return qrTicketModel;
    }
    qrTicketModel.setEventID("null");
    return qrTicketModel;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor) QRTicketModel(com.manan.dev.ec2018app.Models.QRTicketModel)

Example 3 with QRTicketModel

use of com.manan.dev.ec2018app.Models.QRTicketModel in project EC2018App by Manan-YMCA.

the class EventRegister method addTicket.

private void addTicket(final String phoneNumber) {
    String url = getResources().getString(R.string.get_events_qr_code);
    url += phoneNumber;
    RequestQueue queue = Volley.newRequestQueue(this);
    StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            try {
                JSONObject obj1 = new JSONObject(response);
                JSONArray ticketDetails = obj1.getJSONArray("data");
                for (int i = 0; i < ticketDetails.length(); i++) {
                    JSONObject obj2 = ticketDetails.getJSONObject(i);
                    if (obj2.getString("eventid").equals(eventId)) {
                        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"));
                        databaseController.addTicketsToDb(TicketModel);
                    }
                }
            }// 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) {
        }
    });
    queue.add(request);
}
Also used : Response(com.android.volley.Response) MyNotificationResponse(com.manan.dev.ec2018app.Notifications.MyNotificationResponse) 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)

Example 4 with QRTicketModel

use of com.manan.dev.ec2018app.Models.QRTicketModel in project EC2018App by Manan-YMCA.

the class ContentActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.navbar_content);
    cotainer_root_frame = (RelativeLayout) findViewById(R.id.content_frame);
    // 
    dotsLayout = (LinearLayout) findViewById(R.id.layoutDots);
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(ContentActivity.this, drawer, null, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    mProgress = new ProgressDialog(ContentActivity.this);
    mProgress.setMessage("I am working");
    mProgress.setTitle("yes i am");
    mProgress.setCanceledOnTouchOutside(false);
    nav_view = (NavigationView) findViewById(R.id.nav_view);
    pdfTextView = (TextView) findViewById(R.id.tv_pdf);
    nav_view.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this);
    nav_view.setCheckedItem(R.id.nav_home);
    userTickets = new ArrayList<QRTicketModel>();
    databaseController = new DatabaseController(ContentActivity.this);
    mIncomingHandler = new IncomingHandler(ContentActivity.this);
    categoriesHeadingTextView = findViewById(R.id.text_viewcategories);
    viewPager = (ViewPager) findViewById(R.id.slliderview_pager);
    myViewPagerAdapter = new DashboardSlideAdapter(getSupportFragmentManager());
    viewPager.setAdapter(myViewPagerAdapter);
    viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
    ImageView img = findViewById(R.id.drawerTogglebtn);
    img.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (!drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.openDrawer(GravityCompat.START);
            }
        }
    });
    pdfTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // missing 'http://' will cause crashed
            Uri uri = Uri.parse("http://www.elementsculmyca.com/schedule");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    addBottomDots(0);
    addData();
    RecyclerView categoryRecycleview = (RecyclerView) findViewById(R.id.category_recycler_view);
    categoryRecycleview.setHasFixedSize(true);
    DashboardCategoryScrollerAdapter adapter = new DashboardCategoryScrollerAdapter(ContentActivity.this, allSampleData);
    categoryRecycleview.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
    categoryRecycleview.setAdapter(adapter);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DashboardCategoryScrollerAdapter(com.manan.dev.ec2018app.Adapters.DashboardCategoryScrollerAdapter) DatabaseController(com.manan.dev.ec2018app.DatabaseHandler.DatabaseController) Intent(android.content.Intent) ProgressDialog(android.app.ProgressDialog) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Uri(android.net.Uri) QRTicketModel(com.manan.dev.ec2018app.Models.QRTicketModel) DashboardSlideAdapter(com.manan.dev.ec2018app.Adapters.DashboardSlideAdapter) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView)

Example 5 with QRTicketModel

use of com.manan.dev.ec2018app.Models.QRTicketModel in project EC2018App by Manan-YMCA.

the class DatabaseController method retrieveAllTickets.

public ArrayList<QRTicketModel> retrieveAllTickets() {
    SQLiteDatabase db = getReadableDatabase();
    ArrayList<QRTicketModel> qrTickets = new ArrayList<>();
    String[] projection = { Schema.DbEntry.EVENT_ID, Schema.DbEntry.QR_CODE, Schema.DbEntry.PAYMENT_STATUS, Schema.DbEntry.ARRIVAL_STATUS };
    Cursor readCursor = db.query(Schema.DbEntry.QR_TICKET_TABLE_NAME, projection, null, null, null, null, null);
    readCursor.moveToFirst();
    int totalTickets = readCursor.getCount();
    while (totalTickets > 0) {
        totalTickets--;
        QRTicketModel tickets = new QRTicketModel();
        tickets = retrieveTickets(readCursor);
        qrTickets.add(tickets);
        readCursor.moveToNext();
    }
    readCursor.close();
    db.close();
    return qrTickets;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) 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