use of com.manan.dev.ec2018app.Models.EventDetails in project EC2018App by Manan-YMCA.
the class DatabaseController method retreiveEventsByID.
public EventDetails retreiveEventsByID(String EventId) {
SQLiteDatabase db = getReadableDatabase();
EventDetails ev = new EventDetails();
String[] projection = { Schema.DbEntry.EVENT_ID_COLUMN_NAME, Schema.DbEntry.EVENT_NAME_COLUMN_NAME, Schema.DbEntry.EVENT_CLUB_COLUMN_NAME, Schema.DbEntry.EVENT_CATEGORY_COLUMN_NAME, Schema.DbEntry.EVENT_DESCRIPTION_COLUMN_NAME, Schema.DbEntry.EVENT_RULES_COLUMN_NAME, Schema.DbEntry.EVENT_VENUE_COLUMN_NAME, Schema.DbEntry.EVENT_FEE_COLUMN_NAME, Schema.DbEntry.EVENT_PHOTO, Schema.DbEntry.EVENT_COORDINATOR_NAME_1, Schema.DbEntry.EVENT_COORDINATOR_PHONE_1, Schema.DbEntry.EVENT_COORDINATOR_ID_1, Schema.DbEntry.EVENT_COORDINATOR_NAME_2, Schema.DbEntry.EVENT_COORDINATOR_PHONE_2, Schema.DbEntry.EVENT_COORDINATOR_ID_2, Schema.DbEntry.EVENT_START_TIME_COLUMN_NAME, Schema.DbEntry.EVENT_END_TIME_COLUMN_NAME, Schema.DbEntry.EVENT_PRIZES_1, Schema.DbEntry.EVENT_PRIZES_2, Schema.DbEntry.EVENT_PRIZES_3, Schema.DbEntry.EVENT_TEAM_SIZE, Schema.DbEntry.EVENT_UNIQUE_ID };
Cursor readCursor = db.query(Schema.DbEntry.EVENT_LIST_TABLE_NAME, projection, Schema.DbEntry.EVENT_ID_COLUMN_NAME + " = ?", new String[] { EventId }, null, null, null);
readCursor.moveToFirst();
ev = retrieveEvents(readCursor);
readCursor.close();
db.close();
return ev;
}
use of com.manan.dev.ec2018app.Models.EventDetails 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.EventDetails 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.EventDetails in project EC2018App by Manan-YMCA.
the class DatabaseController method retreiveCategory.
public ArrayList<EventDetails> retreiveCategory(String clubName) {
SQLiteDatabase db = getReadableDatabase();
ArrayList<EventDetails> eventList = new ArrayList<>();
String[] projection = { Schema.DbEntry.EVENT_ID_COLUMN_NAME, Schema.DbEntry.EVENT_NAME_COLUMN_NAME, Schema.DbEntry.EVENT_CLUB_COLUMN_NAME, Schema.DbEntry.EVENT_CATEGORY_COLUMN_NAME, Schema.DbEntry.EVENT_DESCRIPTION_COLUMN_NAME, Schema.DbEntry.EVENT_RULES_COLUMN_NAME, Schema.DbEntry.EVENT_VENUE_COLUMN_NAME, Schema.DbEntry.EVENT_FEE_COLUMN_NAME, Schema.DbEntry.EVENT_PHOTO, Schema.DbEntry.EVENT_COORDINATOR_NAME_1, Schema.DbEntry.EVENT_COORDINATOR_PHONE_1, Schema.DbEntry.EVENT_COORDINATOR_ID_1, Schema.DbEntry.EVENT_COORDINATOR_NAME_2, Schema.DbEntry.EVENT_COORDINATOR_PHONE_2, Schema.DbEntry.EVENT_COORDINATOR_ID_2, Schema.DbEntry.EVENT_START_TIME_COLUMN_NAME, Schema.DbEntry.EVENT_END_TIME_COLUMN_NAME, Schema.DbEntry.EVENT_PRIZES_1, Schema.DbEntry.EVENT_PRIZES_2, Schema.DbEntry.EVENT_PRIZES_3, Schema.DbEntry.EVENT_TEAM_SIZE, Schema.DbEntry.EVENT_UNIQUE_ID };
Cursor readCursor = db.query(Schema.DbEntry.EVENT_LIST_TABLE_NAME, projection, Schema.DbEntry.EVENT_CLUB_COLUMN_NAME + " = ?", new String[] { clubName }, null, null, null);
readCursor.moveToFirst();
int totalEvents = readCursor.getCount();
while (totalEvents > 0) {
totalEvents--;
EventDetails event = new EventDetails();
event = retrieveEvents(readCursor);
eventList.add(event);
readCursor.moveToNext();
}
readCursor.close();
db.close();
return eventList;
}
use of com.manan.dev.ec2018app.Models.EventDetails 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);
}
Aggregations