use of it.niedermann.owncloud.notes.model.Item in project nextcloud-notes by stefan-niedermann.
the class SelectSingleNoteActivity method onNoteClick.
@Override
public void onNoteClick(int position, View v) {
ItemAdapter adapter = getItemAdapter();
Item item = adapter.getItem(position);
DBNote note = (DBNote) item;
long noteID = note.getId();
Intent intent = getIntent();
Bundle extras = intent.getExtras();
int mAppWidgetId = -1;
if (extras != null) {
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(this).edit();
sp.putLong(SingleNoteWidget.WIDGET_KEY + mAppWidgetId, noteID);
sp.apply();
Intent retIntent = new Intent(this, SingleNoteWidget.class);
retIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
retIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
sendBroadcast(retIntent);
setResult(RESULT_OK, retIntent);
finish();
}
use of it.niedermann.owncloud.notes.model.Item in project nextcloud-notes by stefan-niedermann.
the class LoadNotesListTask method fillListByTime.
@NonNull
@WorkerThread
private List<Item> fillListByTime(@NonNull List<DBNote> noteList) {
List<Item> itemList = new ArrayList<>();
// #12 Create Sections depending on Time
boolean todaySet, yesterdaySet, weekSet, monthSet, earlierSet;
todaySet = yesterdaySet = weekSet = monthSet = earlierSet = false;
Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
Calendar yesterday = Calendar.getInstance();
yesterday.set(Calendar.DAY_OF_YEAR, yesterday.get(Calendar.DAY_OF_YEAR) - 1);
yesterday.set(Calendar.HOUR_OF_DAY, 0);
yesterday.set(Calendar.MINUTE, 0);
yesterday.set(Calendar.SECOND, 0);
yesterday.set(Calendar.MILLISECOND, 0);
Calendar week = Calendar.getInstance();
week.set(Calendar.DAY_OF_WEEK, week.getFirstDayOfWeek());
week.set(Calendar.HOUR_OF_DAY, 0);
week.set(Calendar.MINUTE, 0);
week.set(Calendar.SECOND, 0);
week.set(Calendar.MILLISECOND, 0);
Calendar month = Calendar.getInstance();
month.set(Calendar.DAY_OF_MONTH, 0);
month.set(Calendar.HOUR_OF_DAY, 0);
month.set(Calendar.MINUTE, 0);
month.set(Calendar.SECOND, 0);
month.set(Calendar.MILLISECOND, 0);
for (int i = 0; i < noteList.size(); i++) {
DBNote currentNote = noteList.get(i);
if (currentNote.isFavorite()) {
// don't show as new section
} else if (!todaySet && currentNote.getModified().getTimeInMillis() >= today.getTimeInMillis()) {
// after 00:00 today
if (i > 0) {
itemList.add(new SectionItem(context.getResources().getString(R.string.listview_updated_today)));
}
todaySet = true;
} else if (!yesterdaySet && currentNote.getModified().getTimeInMillis() < today.getTimeInMillis() && currentNote.getModified().getTimeInMillis() >= yesterday.getTimeInMillis()) {
// between today 00:00 and yesterday 00:00
if (i > 0) {
itemList.add(new SectionItem(context.getResources().getString(R.string.listview_updated_yesterday)));
}
yesterdaySet = true;
} else if (!weekSet && currentNote.getModified().getTimeInMillis() < yesterday.getTimeInMillis() && currentNote.getModified().getTimeInMillis() >= week.getTimeInMillis()) {
// between yesterday 00:00 and start of the week 00:00
if (i > 0) {
itemList.add(new SectionItem(context.getResources().getString(R.string.listview_updated_this_week)));
}
weekSet = true;
} else if (!monthSet && currentNote.getModified().getTimeInMillis() < week.getTimeInMillis() && currentNote.getModified().getTimeInMillis() >= month.getTimeInMillis()) {
// between start of the week 00:00 and start of the month 00:00
if (i > 0) {
itemList.add(new SectionItem(context.getResources().getString(R.string.listview_updated_this_month)));
}
monthSet = true;
} else if (!earlierSet && currentNote.getModified().getTimeInMillis() < month.getTimeInMillis()) {
// before start of the month 00:00
if (i > 0) {
itemList.add(new SectionItem(context.getResources().getString(R.string.listview_updated_earlier)));
}
earlierSet = true;
}
itemList.add(currentNote);
}
return itemList;
}
use of it.niedermann.owncloud.notes.model.Item in project nextcloud-notes by stefan-niedermann.
the class LoadNotesListTask method fillListByCategory.
@NonNull
@WorkerThread
private List<Item> fillListByCategory(@NonNull List<DBNote> noteList) {
List<Item> itemList = new ArrayList<>();
String currentCategory = category.category;
for (DBNote note : noteList) {
if (currentCategory != null && !currentCategory.equals(note.getCategory())) {
itemList.add(new SectionItem(NoteUtil.extendCategory(note.getCategory())));
}
itemList.add(note);
currentCategory = note.getCategory();
}
return itemList;
}
Aggregations