Search in sources :

Example 6 with EventDetails

use of com.manan.dev.ec2018app.Models.EventDetails 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 EventDetails

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

the class SingleEventActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_event);
    databaseController = new DatabaseController(this);
    default_image = getResources().getDrawable(R.drawable.default_image_1);
    // ATTENTION: This was auto-generated to handle app links.
    Intent appLinkIntent = getIntent();
    String appLinkAction = appLinkIntent.getAction();
    Uri appLinkData = appLinkIntent.getData();
    if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null) {
        String revStr = new StringBuilder(appLinkData.toString()).reverse().toString();
        int i;
        for (i = 0; revStr.charAt(i) != 35; i++) {
        }
        revStr = revStr.substring(0, i);
        String eventName = new StringBuilder(revStr).reverse().toString().toUpperCase();
        eventName = eventName.replace("%20", " ");
        deep = true;
        eventId = databaseController.retrieveEventIdByName(eventName);
        if (eventId.equals("wrong")) {
            NO_DEEP_LINK_FLAG = false;
            MDToast.makeText(SingleEventActivity.this, "There's no such event.", MDToast.LENGTH_SHORT, MDToast.TYPE_WARNING).show();
            finish();
            startActivity(new Intent(this, SplashScreen.class));
        }
    } else {
        eventId = getIntent().getStringExtra("eventId");
    }
    container_se_view = findViewById(R.id.contaner_se);
    getEventDetails = new DatabaseController(SingleEventActivity.this);
    eventDetails = new EventDetails();
    registerButton = (Button) findViewById(R.id.btn_register);
    // barViewTicket = (ProgressBar) findViewById(R.id.pb_view_ticket);
    // barViewTicket.setIndeterminate(false);
    // barViewTicket.setVisibility(View.GONE);
    // barViewTicket.setProgress(0);
    // pd = new ProgressDialog(SingleEventActivity.this);
    // pd.setMessage("Loading Tickets...");
    // pd.setCancelable(false);
    // pd.setCanceledOnTouchOutside(false);
    pd = new ProgressDialog(SingleEventActivity.this);
    pd.setTitle("Loading Tickets");
    final Runnable progressRunnable = new Runnable() {

        @Override
        public void run() {
            pd.cancel();
        }
    };
    fragobj = new QRCodeActivity();
    barEventImage = (ProgressBar) findViewById(R.id.pb_event_image);
    eventDateTextView = (TextView) findViewById(R.id.tv_event_date);
    eventStartTimeTextView = (TextView) findViewById(R.id.tv_event_start_time);
    locationTextView = (TextView) findViewById(R.id.tv_event_location);
    eventEndTimeTextView = (TextView) findViewById(R.id.tv_event_end_time);
    // hostClubTextView = (TextView) findViewById(R.id.tv_host);
    feesTextView = (TextView) findViewById(R.id.tv_fees);
    typeOfEventTextView = (TextView) findViewById(R.id.tv_type_of_event);
    firstPrizeTextView = (TextView) findViewById(R.id.tv_prize_first);
    secondPrizeTextView = (TextView) findViewById(R.id.tv_prize_second);
    thirdPrizeTextView = (TextView) findViewById(R.id.tv_prize_third);
    descriptionTextView = (TextView) findViewById(R.id.tv_description);
    rulesTextView = (TextView) findViewById(R.id.tv_rules);
    eventNameView = (TextView) findViewById(R.id.tv_event_name);
    prizesRelativeLayout = (RelativeLayout) findViewById(R.id.rl_prizes);
    eventCategoryTextView = findViewById(R.id.tv_cat_name);
    // goingLinearLayout = (LinearLayout) findViewById(R.id.ll_people_going);
    sharebutton = findViewById(R.id.btn_share);
    categoryEventImageView = findViewById(R.id.iv_type_of_event);
    eventImageLinearLayout = (RelativeLayout) findViewById(R.id.ll_btn_register);
    line1 = (View) findViewById(R.id.line1);
    // line2 = (View) findViewById(R.id.line4);
    line3 = (View) findViewById(R.id.line5);
    line4 = (View) findViewById(R.id.line3);
    line4.setVisibility(View.GONE);
    // goingLinearLayout.setVisibility(View.GONE);
    dateTimeRelativeLayout = (RelativeLayout) findViewById(R.id.rl_time_date);
    locationRelativeLayout = (LinearLayout) findViewById(R.id.ll_location);
    coordsLinearLayout = (LinearLayout) findViewById(R.id.ll_coordinators);
    coordsHeading = (TextView) findViewById(R.id.tv_coords_heading);
    backbutton = (ImageView) findViewById(R.id.tv_back_button);
    if (NO_DEEP_LINK_FLAG) {
        eventDetails = getEventDetails.retreiveEventsByID(eventId);
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(eventDetails.getmStartTime());
        SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd, yyyy", Locale.ENGLISH);
        formattedDate = sdf.format(cal.getTime());
        eventDateTextView.setText(formattedDate);
        SimpleDateFormat sdf1 = new SimpleDateFormat("kk:mm", Locale.US);
        Calendar endTimeMilis = Calendar.getInstance();
        endTimeMilis.setTimeInMillis(eventDetails.getmEndTime());
        startTime = sdf1.format(cal.getTime());
        endTime = sdf1.format(endTimeMilis.getTime());
        eventStartTimeTextView.setText(startTime);
        eventEndTimeTextView.setText(endTime);
        backbutton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (deep) {
                    startActivity(new Intent(SingleEventActivity.this, UserLoginActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
                    finish();
                } else {
                    onBackPressed();
                }
            }
        });
        eventNameView.setText(eventDetails.getmName());
        if (eventDetails.getmCategory().equals("solo")) {
            categoryEventImageView.setImageDrawable(getResources().getDrawable(R.drawable.vector_single));
        }
        eventCategoryTextView.setText(eventDetails.getmCategory());
        locationTextView.setText(eventDetails.getmVenue());
        // hostClubTextView.setText(eventDetails.getmClubname());
        final Long fees = eventDetails.getmFees();
        if (fees == 0) {
            feesTextView.setText("Free");
        } else {
            feesTextView.setText(String.valueOf(fees));
        }
        if (eventDetails.getmEventTeamSize().equals("NA")) {
            registerButton.setVisibility(View.GONE);
            // line1.setVisibility(View.GONE);
            typeOfEventTextView.setText("Presentation Event");
            if (eventDetails.getmName().equals("XUNBAO")) {
                registerButton.setVisibility(View.VISIBLE);
                registerButton.setText("PLAY NOW!");
            }
        } else {
            typeOfEventTextView.setText(eventDetails.getmEventTeamSize());
        }
        for (final Coordinators coord : eventDetails.getmCoordinators()) {
            if (!coord.getmCoordName().equals("")) {
                View view = View.inflate(getApplicationContext(), R.layout.single_layout_event_coords, null);
                TextView coordNameView = (TextView) view.findViewById(R.id.tv_coords_name);
                TextView coordPhoneView = (TextView) view.findViewById(R.id.tv_coords_phone_no);
                coordNameView.setText(coord.getmCoordName());
                coordPhoneView.setText(String.valueOf(coord.getmCoordPhone()));
                // coordsPhoneList.add(coord.getmCoordPhone());
                coordCount++;
                coordsLinearLayout.addView(view);
                view.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        phoneIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + coord.getmCoordPhone()));
                        if (ActivityCompat.checkSelfPermission(SingleEventActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED && !permission) {
                            final String[] PERMISSIONS_CALL = { Manifest.permission.CALL_PHONE };
                            // Asking request Permissions
                            ActivityCompat.requestPermissions(SingleEventActivity.this, PERMISSIONS_CALL, 9);
                            permission = true;
                        } else if (ActivityCompat.checkSelfPermission(SingleEventActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED && permission) {
                            MDToast.makeText(SingleEventActivity.this, "Please grant Permissions first", Toast.LENGTH_SHORT, MDToast.TYPE_ERROR).show();
                        } else {
                            permission = true;
                            startActivity(phoneIntent);
                        }
                    }
                });
            }
        }
        if (coordCount == 0) {
            coordsLinearLayout.setVisibility(View.GONE);
            coordsHeading.setVisibility(View.GONE);
        // line2.setVisibility(View.GONE);
        }
        firstPrizeTextView.setVisibility(View.GONE);
        secondPrizeTextView.setVisibility(View.GONE);
        thirdPrizeTextView.setVisibility(View.GONE);
        prizesRelativeLayout.setVisibility(View.GONE);
        line3.setVisibility(View.GONE);
        for (String prizes : eventDetails.getmPrizes()) {
            if (!prizes.equals("") && !prizes.equals("null") && prizeCount == 0) {
                line3.setVisibility(View.VISIBLE);
                firstPrizeTextView.setVisibility(View.VISIBLE);
                firstPrizeTextView.setText("First Prize: Rs " + prizes);
                prizesRelativeLayout.setVisibility(View.VISIBLE);
                prizeCount++;
            } else if (!prizes.equals("") && !prizes.equals("null") && prizeCount == 1) {
                secondPrizeTextView.setVisibility(View.VISIBLE);
                secondPrizeTextView.setText("Second Prize: Rs " + prizes);
                prizeCount++;
            } else if (!prizes.equals("") && !prizes.equals("null") && prizeCount == 2) {
                thirdPrizeTextView.setVisibility(View.VISIBLE);
                thirdPrizeTextView.setText("Third Prize: Rs " + prizes);
                prizeCount++;
            }
        }
        descriptionTextView.setText(eventDetails.getmDesc());
        rulesTextView.setText(eventDetails.getmRules());
        dateTimeRelativeLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                MDToast.makeText(SingleEventActivity.this, "Set a reminder!", MDToast.LENGTH_SHORT, MDToast.TYPE_INFO).show();
                try {
                    if (!permissionGranted(android.Manifest.permission.READ_CALENDAR, android.Manifest.permission.WRITE_CALENDAR)) {
                        askForPermission(android.Manifest.permission.READ_CALENDAR, android.Manifest.permission.WRITE_CALENDAR);
                    } else {
                        addToCalendar();
                    }
                } catch (Exception ex) {
                }
            }
        });
        locationRelativeLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                MDToast.makeText(SingleEventActivity.this, "Search on Maps!", MDToast.LENGTH_SHORT, MDToast.TYPE_INFO).show();
                Intent intentMap = new Intent(SingleEventActivity.this, MapsActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intentMap);
            }
        });
        registerButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (registerButton.getText().toString().equals("View Ticket")) {
                    // barViewTicket.setVisibility(View.VISIBLE);
                    pd.show();
                    Handler pdCanceller = new Handler();
                    pdCanceller.postDelayed(progressRunnable, 3000);
                    FragmentManager fm = getFragmentManager();
                    Bundle bundle = new Bundle();
                    bundle.putString("qrcodestring", TicketModel.getQRcode());
                    bundle.putString("eventid", eventId);
                    bundle.putInt("activity", 0);
                    bundle.putInt("paymentStatus", TicketModel.getPaymentStatus());
                    bundle.putInt("arrivalStatus", TicketModel.getArrivalStatus());
                    fragobj.setArguments(bundle);
                    if (fragobj != null) {
                        fragobj.show(fm, "hiiiii");
                        pd.dismiss();
                    } else {
                        MDToast.makeText(SingleEventActivity.this, "Unable to load ticket.", Toast.LENGTH_SHORT, MDToast.TYPE_ERROR).show();
                        pd.dismiss();
                    }
                } else if (registerButton.getText().toString().equals("PLAY NOW!")) {
                    if (eventDetails.getmName().equals("XUNBAO"))
                        startActivity(new Intent(SingleEventActivity.this, XunbaoActivity.class));
                    else if (eventDetails.getmName().equals("HACKON")) {
                        // missing 'http://' will cause crashed
                        Uri uri = Uri.parse("http://www.elementsculmyca.com/schedule");
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        startActivity(intent);
                    }
                } else {
                    startActivity(new Intent(SingleEventActivity.this, EventRegister.class).putExtra("eventName", eventDetails.getmName()).putExtra("eventId", eventDetails.getmEventId()).putExtra("eventType", eventDetails.getmEventTeamSize()));
                }
            }
        });
        sharebutton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                String baseUrl = "http://elementsculmyca.com/event/";
                String parsedUrl = baseUrl + "#" + eventDetails.getmName().toString().replaceAll(" ", "%20");
                String message = "Elements Culmyca 2018:" + eventDetails.getmName().toString() + " View the event clicking the link: " + parsedUrl;
                shareEventMessage(message);
            }
        });
        showSnack(isConnected());
    }
}
Also used : Bundle(android.os.Bundle) Calendar(java.util.Calendar) Handler(android.os.Handler) DatabaseController(com.manan.dev.ec2018app.DatabaseHandler.DatabaseController) Intent(android.content.Intent) ProgressDialog(android.app.ProgressDialog) Uri(android.net.Uri) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) EventDetails(com.manan.dev.ec2018app.Models.EventDetails) FragmentManager(android.app.FragmentManager) TextView(android.widget.TextView) Coordinators(com.manan.dev.ec2018app.Models.Coordinators) SimpleDateFormat(java.text.SimpleDateFormat) QRCodeActivity(com.manan.dev.ec2018app.Fragments.QRCodeActivity)

Aggregations

EventDetails (com.manan.dev.ec2018app.Models.EventDetails)7 DatabaseController (com.manan.dev.ec2018app.DatabaseHandler.DatabaseController)3 Coordinators (com.manan.dev.ec2018app.Models.Coordinators)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Calendar (java.util.Calendar)3 ProgressDialog (android.app.ProgressDialog)2 Intent (android.content.Intent)2 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 FragmentManager (android.app.FragmentManager)1 PendingIntent (android.app.PendingIntent)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1