use of com.manan.dev.ec2018app.Models.Coordinators in project EC2018App by Manan-YMCA.
the class SplashScreen method JsonParse.
void JsonParse(String response) {
try {
JSONObject object = new JSONObject(response);
JSONArray eventArray = object.getJSONArray("data");
for (int i = 0; i < eventArray.length(); i++) {
EventDetails event = new EventDetails();
JSONObject currEvent = eventArray.getJSONObject(i);
event.setmUniqueKey(i);
if (currEvent.has("timing"))
event.setmName(currEvent.getString("title"));
if (currEvent.has("fee"))
event.setmFees(currEvent.getLong("fee"));
if (currEvent.has("timing")) {
JSONObject timing = currEvent.getJSONObject("timing");
if (timing.has("from"))
event.setmStartTime(timing.getLong("from"));
if (timing.has("to"))
event.setmEndTime(timing.getLong("to"));
}
if (currEvent.has("clubname"))
event.setmClubname(currEvent.getString("clubname"));
if (currEvent.has("category"))
event.setmCategory(currEvent.getString("category"));
if (currEvent.has("desc"))
event.setmDesc(currEvent.getString("desc"));
if (currEvent.has("venue"))
event.setmVenue(currEvent.getString("venue"));
if (currEvent.has("rules"))
event.setmRules(currEvent.getString("rules"));
if (currEvent.has("photolink")) {
event.setmPhotoUrl(currEvent.getString("photolink"));
} else {
event.setmPhotoUrl(null);
}
event.setmCoordinators(new ArrayList<Coordinators>());
if (currEvent.has("coordinators")) {
JSONArray coordinators = currEvent.getJSONArray("coordinators");
for (int j = 0; j < coordinators.length(); j++) {
JSONObject coordinatorsDetail = coordinators.getJSONObject(j);
Coordinators coord = new Coordinators();
if (coordinatorsDetail.has("_id"))
coord.setmCoordId(coordinatorsDetail.getString("_id"));
if (coordinatorsDetail.has("phone"))
coord.setmCoordPhone(coordinatorsDetail.getLong("phone"));
if (coordinatorsDetail.has("name"))
coord.setmCoordName(coordinatorsDetail.getString("name"));
event.getmCoordinators().add(coord);
}
}
event.setmPrizes(new ArrayList<String>());
if (currEvent.has("prizes")) {
JSONObject prize = currEvent.getJSONObject("prizes");
if (prize.has("prize1"))
event.getmPrizes().add(prize.getString("prize1"));
if (prize.has("prize2"))
event.getmPrizes().add(prize.getString("prize2"));
if (prize.has("prize3"))
event.getmPrizes().add(prize.getString("prize3"));
} else {
event.getmPrizes().add(null);
event.getmPrizes().add(null);
event.getmPrizes().add(null);
}
if (currEvent.has("_id"))
event.setmEventId(currEvent.getString("_id"));
if (currEvent.has("eventtype")) {
event.setmEventTeamSize(currEvent.getString("eventtype"));
}
allEvents.add(event);
}
incomingHandler.sendEmptyMessage(0);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.manan.dev.ec2018app.Models.Coordinators in project EC2018App by Manan-YMCA.
the class DatabaseController method retrieveEvents.
public EventDetails retrieveEvents(Cursor readCursor) {
String eventId = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_ID_COLUMN_NAME));
String eventName = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_NAME_COLUMN_NAME));
String category = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_CATEGORY_COLUMN_NAME));
String description = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_DESCRIPTION_COLUMN_NAME));
String rules = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_RULES_COLUMN_NAME));
String venue = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_VENUE_COLUMN_NAME));
Long fee = readCursor.getLong(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_FEE_COLUMN_NAME));
Integer uniqueKey = readCursor.getInt(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_UNIQUE_ID));
String prize1 = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_PRIZES_1));
String prize2 = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_PRIZES_2));
String prize3 = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_PRIZES_3));
ArrayList<String> prizes = new ArrayList<>();
prizes.add(prize1);
prizes.add(prize2);
prizes.add(prize3);
String eventTeamSize = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_TEAM_SIZE));
String clubName = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_CLUB_COLUMN_NAME));
String photourl = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_PHOTO));
Long startTime = readCursor.getLong(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_START_TIME_COLUMN_NAME));
Long endTime = readCursor.getLong(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_END_TIME_COLUMN_NAME));
ArrayList<Coordinators> coords = new ArrayList<>();
String coordName1 = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_COORDINATOR_NAME_1));
String coordId1 = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_COORDINATOR_ID_1));
Long coordPhone1 = readCursor.getLong(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_COORDINATOR_PHONE_1));
String coordName2 = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_COORDINATOR_NAME_2));
String coordId2 = readCursor.getString(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_COORDINATOR_ID_2));
Long coordPhone2 = readCursor.getLong(readCursor.getColumnIndexOrThrow(Schema.DbEntry.EVENT_COORDINATOR_PHONE_2));
coords.add(new Coordinators(coordName1, coordId1, coordPhone1));
coords.add(new Coordinators(coordName2, coordId2, coordPhone2));
return new EventDetails(eventName, clubName, category, description, rules, venue, photourl, eventId, eventTeamSize, startTime, endTime, fee, coords, prizes, uniqueKey);
}
use of com.manan.dev.ec2018app.Models.Coordinators 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