use of com.giua.objects.Homework in project Giua-App by Giua-app.
the class DBController method addHomeworks.
public void addHomeworks(List<Homework> homeworks) {
SQLiteDatabase db = getWritableDatabase();
for (Homework homework : homeworks) {
addHomework(homework, db);
}
db.close();
}
use of com.giua.objects.Homework in project Giua-App by Giua-app.
the class OfflineDBController method readHomeworks.
public List<Homework> readHomeworks() {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM " + HOMEWORKS_TABLE, null);
List<Homework> homeworks = new Vector<>();
if (cursor.moveToFirst()) {
boolean exists = cursor.getInt(DBHomework.EXISTS_COL.ordinal()) != 0;
do {
homeworks.add(new Homework(cursor.getString(DBHomework.DATE_COL.ordinal()).split("-")[2], cursor.getString(DBHomework.DATE_COL.ordinal()).split("-")[1], cursor.getString(DBHomework.DATE_COL.ordinal()).split("-")[0], cursor.getString(DBHomework.DATE_COL.ordinal()), cursor.getString(DBHomework.SUBJECT_COL.ordinal()), cursor.getString(DBHomework.CREATOR_COL.ordinal()), cursor.getString(DBHomework.DETAILS_COL.ordinal()), exists));
} while (cursor.moveToNext());
// muovi il cursore nella prossima riga
}
cursor.close();
return homeworks;
}
use of com.giua.objects.Homework in project Giua-App by Giua-app.
the class AgendaView method initializeComponent.
private void initializeComponent(Context context) {
// Rappresenta il giorno del compito o della verifica
Calendar objectDay = Calendar.getInstance();
loggerManager = new LoggerManager("AgendaView", context);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.view_agenda, this);
TextView tvTime = findViewById(R.id.agenda_view_time);
TextView tvDate = findViewById(R.id.agenda_view_date);
TextView tvSubject = findViewById(R.id.agenda_view_subject);
TextView tvTeacher = findViewById(R.id.agenda_view_teacher);
TextView tvText = findViewById(R.id.agenda_view_text);
TextView tvType = findViewById(R.id.agenda_view_type);
LinearLayout layout = findViewById(R.id.agenda_view_layout);
if (getRepresentedObject() == Homework.class) {
Homework homework = (Homework) agendaObject;
objectDay.set(Integer.parseInt(homework.year), Integer.parseInt(homework.month) - 1, Integer.parseInt(homework.day), 23, 59, 59);
tvDate.setText(homework.day + "-" + homework.month + "-" + homework.year);
tvType.setText(R.string.agenda_view_type_homeworks);
tvText.setText(homework.details);
tvSubject.setText(homework.subject.split(": ")[1]);
tvTeacher.setText(homework.creator);
layout.setBackgroundTintList(ResourcesCompat.getColorStateList(getResources(), R.color.adaptive_agenda_views_cyan, context.getTheme()));
} else if (getRepresentedObject() == Test.class) {
Test test = (Test) agendaObject;
objectDay.set(Integer.parseInt(test.year), Integer.parseInt(test.month) - 1, Integer.parseInt(test.day), 23, 59, 59);
tvDate.setText(test.day + "-" + test.month + "-" + test.year);
tvType.setText(R.string.agenda_view_type_tests);
tvText.setText(test.details);
tvSubject.setText(test.subject);
tvTeacher.setText(test.creator);
layout.setBackgroundTintList(ResourcesCompat.getColorStateList(getResources(), R.color.adaptive_agenda_views_orange, context.getTheme()));
} else if (getRepresentedObject() == com.giua.objects.Activity.class) {
com.giua.objects.Activity activity = (com.giua.objects.Activity) agendaObject;
objectDay.set(Integer.parseInt(activity.year), Integer.parseInt(activity.month) - 1, Integer.parseInt(activity.day), 23, 59, 59);
tvDate.setText(activity.day + "-" + activity.month + "-" + activity.year);
tvType.setText(R.string.agenda_view_type_activities);
tvText.setText(activity.details);
tvSubject.setVisibility(GONE);
tvTeacher.setVisibility(GONE);
layout.setBackgroundTintList(ResourcesCompat.getColorStateList(getResources(), R.color.adaptive_agenda_views_green, context.getTheme()));
} else if (getRepresentedObject() == InterviewAgenda.class) {
InterviewAgenda test = (InterviewAgenda) agendaObject;
objectDay.set(Integer.parseInt(test.year), Integer.parseInt(test.month) - 1, Integer.parseInt(test.day), 23, 59, 59);
tvDate.setText(test.day + "-" + test.month + "-" + test.year);
tvType.setText(R.string.agenda_view_type_interviews);
tvText.setText(test.details);
tvSubject.setText(test.period);
tvTeacher.setText(test.creator);
layout.setBackgroundTintList(ResourcesCompat.getColorStateList(getResources(), R.color.adaptive_agenda_views_purple, context.getTheme()));
}
// Calendar fake = Calendar.getInstance();
// fake.set(Calendar.MONTH, 11);
// fake.set(Calendar.DAY_OF_MONTH, 29);
int timeDiff = calcTimeDifferenceInDay(Calendar.getInstance(), objectDay);
loggerManager.d("mancano " + timeDiff + " giorni al compito del " + objectDay.get(Calendar.DAY_OF_MONTH) + "/" + objectDay.get(Calendar.MONTH) + "/" + objectDay.get(Calendar.YEAR));
if (timeDiff < 0)
if (timeDiff == -1)
tvTime.setText("Ieri");
else
tvTime.setText(Math.abs(timeDiff) + " giorni fa");
else {
switch(timeDiff) {
case 3:
tvTime.setTextColor(getResources().getColor(R.color.middle_vote_lighter, context.getTheme()));
tvTime.setText("Tra " + timeDiff + " giorni");
break;
case 2:
tvTime.setTextColor(getResources().getColor(R.color.middle_vote_no_night, context.getTheme()));
tvTime.setText("Tra " + timeDiff + " giorni");
break;
case 1:
tvTime.setTextColor(getResources().getColor(R.color.bad_vote, context.getTheme()));
tvTime.setText("Domani");
break;
case 0:
tvTime.setTextColor(getResources().getColor(R.color.bad_vote, context.getTheme()));
tvTime.setText("Oggi");
break;
default:
tvTime.setText("Tra " + timeDiff + " giorni");
break;
}
}
}
use of com.giua.objects.Homework in project Giua-App by Giua-app.
the class OfflineDBController method addHomeworks.
public void addHomeworks(List<Homework> homeworks) {
SQLiteDatabase db = getWritableDatabase();
for (Homework homework : homeworks) {
addHomework(homework, db);
}
db.close();
}
use of com.giua.objects.Homework in project Giua-App by Giua-app.
the class DBController method readHomeworks.
public List<Homework> readHomeworks() {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM " + HOMEWORKS_TABLE, null);
List<Homework> homeworks = new Vector<>();
if (cursor.moveToFirst()) {
boolean exists = cursor.getInt(DBHomework.EXISTS_COL.ordinal()) != 0;
do {
homeworks.add(new Homework(cursor.getString(DBHomework.DATE_COL.ordinal()).split("-")[2], cursor.getString(DBHomework.DATE_COL.ordinal()).split("-")[1], cursor.getString(DBHomework.DATE_COL.ordinal()).split("-")[0], cursor.getString(DBHomework.DATE_COL.ordinal()), cursor.getString(DBHomework.SUBJECT_COL.ordinal()), cursor.getString(DBHomework.CREATOR_COL.ordinal()), cursor.getString(DBHomework.DETAILS_COL.ordinal()), exists));
} while (cursor.moveToNext());
// muovi il cursore nella prossima riga
}
cursor.close();
return homeworks;
}
Aggregations