private void getData() { try { noticeData = new ArrayList<>(); DatabaseHandler handler = new DatabaseHandler(MainActivity.this); Cursor noticeCursor = handler.getNotice(); noticeCursor.moveToFirst(); do { NoticeData2 nd = new NoticeData2(); nd.isNew = noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("isNew")); // nd.alertTransId = // noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("alertTransId")); nd.sender_name = noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("sender_name")); nd.sender_round_photo = noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("sender_round_photo")); nd.sender_designation = noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("sender_designation")); nd.sent_date = noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("sent_date")); // nd.alertText = noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("alertText")); nd.attachmentCount = noticeCursor.getInt(noticeCursor.getColumnIndexOrThrow("attachmentCount")); nd.attachments = noticeCursor.getString(noticeCursor.getColumnIndexOrThrow("attachments")); noticeData.add(nd); } while (noticeCursor.moveToNext()); handler.close(); } catch (Exception e) { Log.e("#Exc in getdata()", e.toString()); } }
private void setUserData() { try { DatabaseHandler handler = new DatabaseHandler(MainActivity.this); handler.openDataBase(); Cursor instituteCursor = handler.getInstituteDetails(PrefUtils.getInstituteCode(MainActivity.this)); instituteCursor.moveToFirst(); do { String schoolName = instituteCursor.getString(instituteCursor.getColumnIndexOrThrow("inst_name")); String firstname = instituteCursor.getString(instituteCursor.getColumnIndexOrThrow("firstname")); String lastname = instituteCursor.getString(instituteCursor.getColumnIndexOrThrow("lastname")); SCHOOL_NAME = schoolName; txtSchoolName.setText(SCHOOL_NAME); txtUserName.setText("Welcome " + firstname + " " + lastname + "."); // etDOB.setText(dob); // Glide.with(RegisterActivity.this).load(dob).into(imgProfile); } while (instituteCursor.moveToNext()); handler.close(); } catch (Exception e) { Log.e("### EXC", "" + e.toString()); } }
private void fetchNoticeData(String type) { try { DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this); handler.openDataBase(); // Fetching NOTICE Cursor noticeCusrosr = handler.getNoticeByType(type); noticeCusrosr.moveToFirst(); noticeData = new ArrayList<>(); if (noticeCusrosr != null) { do { NoticeData2 notice = new NoticeData2(); notice.noticeTransactId = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("noticeTransactId")); notice.noticeType = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("noticeType")); notice.sender_name = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sender_name")); notice.sender_round_photo = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sender_round_photo")); notice.sender_designation = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sender_designation")); notice.sent_date = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sent_date")); notice.subject = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("subject")); notice.description = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("description")); notice.attachmentCount = noticeCusrosr.getInt(noticeCusrosr.getColumnIndexOrThrow("attachmentCount")); notice.isNew = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("isNew")); String tempAttachment = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("attachments")); notice.staffId = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("staffID")); notice.attachments = tempAttachment; noticeData.add(notice); } while (noticeCusrosr.moveToNext()); } handler.close(); } catch (Exception e) { Log.e("%%% Exc", e.toString()); } dat = new ArrayList<>(); fragmentdat2 = new ArrayList<>(); if (noticeData == null) { try { DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this); handler.openDataBase(); // Fetching NOTICE Cursor noticeCusrosr = handler.getNotice(); noticeCusrosr.moveToFirst(); noticeData = new ArrayList<>(); if (noticeCusrosr != null) { do { NoticeData2 notice = new NoticeData2(); notice.noticeTransactId = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("noticeTransactId")); notice.noticeType = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("noticeType")); notice.sender_name = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sender_name")); notice.sender_round_photo = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sender_round_photo")); notice.sender_designation = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sender_designation")); notice.sent_date = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("sent_date")); notice.subject = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("subject")); notice.description = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("description")); notice.attachmentCount = noticeCusrosr.getInt(noticeCusrosr.getColumnIndexOrThrow("attachmentCount")); notice.isNew = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("isNew")); String tempAttachment = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("attachments")); notice.staffId = noticeCusrosr.getString(noticeCusrosr.getColumnIndexOrThrow("staffID")); notice.attachments = tempAttachment; noticeData.add(notice); } while (noticeCusrosr.moveToNext()); } handler.close(); for (int i = 0; i < noticeData.size(); i++) { InstituteData fr2 = new InstituteData(); fr2.setNotice(noticeData.get(i)); fr2.setType(1); dat.add(fr2); InstituteData2 InstituteData2 = new InstituteData2(); InstituteData2.setType(1); InstituteData2.setData( noticeData.get(i).staffId, "", "", "", noticeData.get(i).noticeTransactId, noticeData.get(i).noticeType, noticeData.get(i).sender_name, noticeData.get(i).sender_round_photo, noticeData.get(i).sender_designation, noticeData.get(i).sent_date, noticeData.get(i).subject, noticeData.get(i).description, noticeData.get(i).attachmentCount, noticeData.get(i).attachments, noticeData.get(i).isNew, "", ""); fragmentdat2.add(InstituteData2); } handler.close(); } catch (Exception e) { } } else { for (int i = 0; i < noticeData.size(); i++) { InstituteData fr2 = new InstituteData(); fr2.setNotice(noticeData.get(i)); fr2.setType(1); dat.add(fr2); InstituteData2 InstituteData2 = new InstituteData2(); InstituteData2.setType(1); InstituteData2.setData( noticeData.get(i).staffId, "", "", "", noticeData.get(i).noticeTransactId, noticeData.get(i).noticeType, noticeData.get(i).sender_name, noticeData.get(i).sender_round_photo, noticeData.get(i).sender_designation, noticeData.get(i).sent_date, noticeData.get(i).subject, noticeData.get(i).description, noticeData.get(i).attachmentCount, noticeData.get(i).attachments, noticeData.get(i).isNew, "", ""); fragmentdat2.add(InstituteData2); } } }
private void fetchHomeWorkData() { try { DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this); handler.openDataBase(); Cursor alertCusrosr = handler.getAlert(); // Fetching Homework Cursor homeworkCusrosr = handler.getHomeWork(); homeworkCusrosr.moveToFirst(); homeWorkData = new ArrayList<>(); if (homeworkCusrosr != null) { do { HomeWorkData2 home = new HomeWorkData2(); home.homeWorkTransactId = homeworkCusrosr.getString( homeworkCusrosr.getColumnIndexOrThrow("homeWorkTransactId")); home.sender_name = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sender_name")); home.sender_round_photo = homeworkCusrosr.getString( homeworkCusrosr.getColumnIndexOrThrow("sender_round_photo")); home.sender_designation = homeworkCusrosr.getString( homeworkCusrosr.getColumnIndexOrThrow("sender_designation")); home.sent_date = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sent_date")); home.homeWorkSubject = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("homeWorkSubject")); home.dueDate = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("dueDate")); home.description = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("description")); home.attachmentCount = homeworkCusrosr.getInt(homeworkCusrosr.getColumnIndexOrThrow("attachmentCount")); home.isNew = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("isNew")); home.attachments = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("attachments")); home.staffId = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("staffID")); homeWorkData.add(home); } while (homeworkCusrosr.moveToNext()); } handler.close(); } catch (Exception e) { Log.e("%%% Exc", e.toString()); } dat = new ArrayList<>(); fragmentdat2 = new ArrayList<>(); if (homeWorkData == null) { try { DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this); handler.openDataBase(); // Fetching Homework Cursor homeworkCusrosr = handler.getHomeWork(); homeworkCusrosr.moveToFirst(); homeWorkData = new ArrayList<>(); if (homeworkCusrosr != null) { do { HomeWorkData2 home = new HomeWorkData2(); home.homeWorkTransactId = homeworkCusrosr.getString( homeworkCusrosr.getColumnIndexOrThrow("homeWorkTransactId")); home.sender_name = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sender_name")); home.sender_round_photo = homeworkCusrosr.getString( homeworkCusrosr.getColumnIndexOrThrow("sender_round_photo")); home.sender_designation = homeworkCusrosr.getString( homeworkCusrosr.getColumnIndexOrThrow("sender_designation")); home.sent_date = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sent_date")); home.homeWorkSubject = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("homeWorkSubject")); home.dueDate = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("dueDate")); home.description = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("description")); home.attachmentCount = homeworkCusrosr.getInt(homeworkCusrosr.getColumnIndexOrThrow("attachmentCount")); home.isNew = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("isNew")); home.staffId = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("staffID")); home.attachments = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("attachments")); homeWorkData.add(home); } while (homeworkCusrosr.moveToNext()); } handler.close(); for (int i = 0; i < homeWorkData.size(); i++) { InstituteData fr3 = new InstituteData(); fr3.setHomeWork(homeWorkData.get(i)); fr3.setType(2); dat.add(fr3); InstituteData2 InstituteData2 = new InstituteData2(); InstituteData2.setType(2); InstituteData2.setData( homeWorkData.get(i).staffId, homeWorkData.get(i).homeWorkTransactId, homeWorkData.get(i).homeWorkSubject, homeWorkData.get(i).dueDate, "", "", homeWorkData.get(i).sender_name, homeWorkData.get(i).sender_round_photo, homeWorkData.get(i).sender_designation, homeWorkData.get(i).sent_date, "", homeWorkData.get(i).description, homeWorkData.get(i).attachmentCount, homeWorkData.get(i).attachments, homeWorkData.get(i).isNew, "", ""); fragmentdat2.add(InstituteData2); } handler.close(); } catch (Exception e) { } } else { for (int i = 0; i < homeWorkData.size(); i++) { InstituteData fr3 = new InstituteData(); fr3.setHomeWork(homeWorkData.get(i)); fr3.setType(2); dat.add(fr3); InstituteData2 InstituteData2 = new InstituteData2(); InstituteData2.setType(2); InstituteData2.setData( homeWorkData.get(i).staffId, homeWorkData.get(i).homeWorkTransactId, homeWorkData.get(i).homeWorkSubject, homeWorkData.get(i).dueDate, "", "", homeWorkData.get(i).sender_name, homeWorkData.get(i).sender_round_photo, homeWorkData.get(i).sender_designation, homeWorkData.get(i).sent_date, "", homeWorkData.get(i).description, homeWorkData.get(i).attachmentCount, homeWorkData.get(i).attachments, homeWorkData.get(i).isNew, "", ""); fragmentdat2.add(InstituteData2); } } }
private void fetchALertData() { try { DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this); handler.openDataBase(); Cursor alertCusrosr = handler.getAlert(); // Fetching ALerts alertCusrosr.moveToFirst(); alertData = new ArrayList<>(); if (alertCusrosr != null) { do { AlertData2 alert = new AlertData2(); alert.alertTransId = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertTransId")); alert.sender_name = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_name")); alert.sender_round_photo = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_round_photo")); alert.sender_designation = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_designation")); alert.sent_date = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sent_date")); alert.alertText = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertText")); alert.attachmentCount = alertCusrosr.getInt(alertCusrosr.getColumnIndexOrThrow("attachmentCount")); alert.attachments = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("attachments")); alert.isNew = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("isNew")); alert.staffId = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("staffID")); alertData.add(alert); } while (alertCusrosr.moveToNext()); } handler.close(); } catch (Exception e) { Log.e("%%% Exc", e.toString()); } dat = new ArrayList<>(); fragmentdat2 = new ArrayList<>(); if (alertData == null) { try { DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this); handler.openDataBase(); Cursor alertCusrosr = handler.getAlert(); // Fetching ALerts alertCusrosr.moveToFirst(); alertData = new ArrayList<>(); if (alertCusrosr != null) { do { AlertData2 alert = new AlertData2(); alert.alertTransId = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertTransId")); alert.sender_name = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_name")); alert.sender_round_photo = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_round_photo")); alert.isNew = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("isNew")); alert.sender_designation = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_designation")); alert.sent_date = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sent_date")); alert.alertText = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertText")); alert.attachmentCount = alertCusrosr.getInt(alertCusrosr.getColumnIndexOrThrow("attachmentCount")); alert.attachments = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("attachments")); alert.staffId = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("staffID")); alertData.add(alert); } while (alertCusrosr.moveToNext()); } handler.close(); for (int i = 0; i < alertData.size(); i++) { InstituteData fr1 = new InstituteData(); InstituteData2 InstituteData2 = new InstituteData2(); InstituteData2.setType(0); InstituteData2.setData( alertData.get(i).staffId, "", "", "", "", "", alertData.get(i).sender_name, alertData.get(i).sender_round_photo, alertData.get(i).sender_designation, alertData.get(i).sent_date, "", "", alertData.get(i).attachmentCount, alertData.get(i).attachments, alertData.get(i).isNew, alertData.get(i).alertTransId, alertData.get(i).alertText); fragmentdat2.add(InstituteData2); fr1.setAlerts(alertData.get(i)); fr1.setType(0); dat.add(fr1); handler.close(); } } catch (Exception e) { } } else { for (int i = 0; i < alertData.size(); i++) { InstituteData fr1 = new InstituteData(); fr1.setAlerts(alertData.get(i)); fr1.setType(0); dat.add(fr1); InstituteData2 InstituteData2 = new InstituteData2(); InstituteData2.setType(0); InstituteData2.setData( alertData.get(i).staffId, "", "", "", "", "", alertData.get(i).sender_name, alertData.get(i).sender_round_photo, alertData.get(i).sender_designation, alertData.get(i).sent_date, "", "", alertData.get(i).attachmentCount, alertData.get(i).attachments, alertData.get(i).isNew, alertData.get(i).alertTransId, alertData.get(i).alertText); fragmentdat2.add(InstituteData2); } } }