use of com.manan.dev.ec2018app.DatabaseHandler.DatabaseController in project EC2018App by Manan-YMCA.
the class QRCodeActivity method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.qrcode_dialog_box, container, false);
if (mContext == null) {
mContext = getActivity();
}
String qrcodestring = getArguments().getString("qrcodestring");
eventId = getArguments().getString("eventid");
activity = getArguments().getInt("activity");
paymentStatus = getArguments().getInt("paymentStatus");
arrivalStatus = getArguments().getInt("arrivalStatus");
qrTicketImage = (ImageView) rootView.findViewById(R.id.qr_ticket);
eventName = (TextView) rootView.findViewById(R.id.tv_event_name);
eventDate = (TextView) rootView.findViewById(R.id.tv_event_date);
eventTime = (TextView) rootView.findViewById(R.id.tv_event_time);
fees = (TextView) rootView.findViewById(R.id.eventfees);
status = (TextView) rootView.findViewById(R.id.iv_event_fees_status);
back = (ImageView) rootView.findViewById(R.id.iv_cross);
getEventDetails = new DatabaseController(getActivity());
eventDetails = getEventDetails.retreiveEventsByID(eventId);
eventName.setText(eventDetails.getmName());
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getDialog().dismiss();
}
});
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(eventDetails.getmStartTime());
SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd, yyyy", Locale.ENGLISH);
String formattedDate = sdf.format(cal.getTime());
SimpleDateFormat sdf1 = new SimpleDateFormat("kk:mm", Locale.US);
String formattedTime = sdf1.format(cal.getTime());
eventDate.setText(formattedDate);
eventTime.setText(formattedTime);
fees.setText(String.valueOf("RS " + eventDetails.getmFees()));
TicketsGenerator ticketsGenerator = new TicketsGenerator();
Bitmap qrTicket = ticketsGenerator.GenerateClick(qrcodestring, mContext, (int) getResources().getDimension(R.dimen.threefifty), (int) getResources().getDimension(R.dimen.twoforty), 120, 120);
qrTicketImage.setImageBitmap(qrTicket);
if (String.valueOf(eventDetails.getmFees()).equals("0")) {
status.setTextColor(mContext.getResources().getColor(R.color.status_free));
status.setText("FREE");
} else if (String.valueOf(paymentStatus).equals("0")) {
status.setTextColor(mContext.getResources().getColor(R.color.primaryFocused));
status.setText("PENDING");
} else {
status.setTextColor(mContext.getResources().getColor(R.color.status_paid));
status.setText("PAID");
}
if (arrivalStatus == 1) {
qrTicketImage.setImageResource(R.drawable.arrived_qr);
}
return rootView;
}
use of com.manan.dev.ec2018app.DatabaseHandler.DatabaseController in project EC2018App by Manan-YMCA.
the class EventRegister method sendNotification.
public void sendNotification() {
Intent my_intent = new Intent(EventRegister.this, MyNotificationResponse.class);
my_intent.putExtra("eventId", eventId);
my_intent.putExtra("eventName", eventName);
Calendar calendar = Calendar.getInstance();
// calendar.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
// calendar.add(Calendar.SECOND, 10);
DatabaseController db = new DatabaseController(getApplicationContext());
EventDetails currEvent = new EventDetails();
currEvent = db.retreiveEventsByID(eventId);
Long eventStartTime = currEvent.getmStartTime();
calendar.setTimeInMillis(eventStartTime);
calendar.add(Calendar.HOUR, -1);
SimpleDateFormat sdf1 = new SimpleDateFormat("kk:mm", Locale.US);
SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd, yyyy", Locale.ENGLISH);
my_intent.putExtra("uniqueId", currEvent.getmUniqueKey());
pending_intent = PendingIntent.getBroadcast(EventRegister.this, currEvent.getmUniqueKey(), my_intent, PendingIntent.FLAG_ONE_SHOT);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pending_intent);
}
use of com.manan.dev.ec2018app.DatabaseHandler.DatabaseController 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.DatabaseHandler.DatabaseController 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());
}
}
Aggregations