use of net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording in project Osmand by osmandapp.
the class NotesAdapter method getView.
@NonNull
@Override
public View getView(final int position, View row, @NonNull ViewGroup parent) {
boolean nightMode = !app.getSettings().isLightContent();
Context themedCtx = UiUtilities.getThemedContext(getContext(), nightMode);
if (portrait) {
final int type = getItemViewType(position);
boolean header = type == TYPE_DATE_HEADER || type == TYPE_AUDIO_HEADER || type == TYPE_PHOTO_HEADER || type == TYPE_VIDEO_HEADER;
if (row == null) {
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
if (header) {
row = inflater.inflate(R.layout.list_item_header, parent, false);
HeaderViewHolder hHolder = new HeaderViewHolder(row);
row.setTag(hHolder);
} else {
row = inflater.inflate(R.layout.note_list_item, parent, false);
ItemViewHolder iHolder = new ItemViewHolder(row);
row.setTag(iHolder);
}
}
if (header) {
setupHeader(type, (HeaderViewHolder) row.getTag());
} else {
final Object item = getItem(position);
if (item instanceof Recording) {
setupItem(position, (Recording) item, (ItemViewHolder) row.getTag());
}
}
return row;
} else {
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
boolean lastCard = getCardsCount() == position + 1;
int margin = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
int sideMargin = app.getResources().getDisplayMetrics().widthPixels / 10;
FrameLayout fl = new FrameLayout(themedCtx);
LinearLayout ll = new LinearLayout(themedCtx);
fl.addView(ll);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setBackgroundResource(nightMode ? R.drawable.bg_card_dark : R.drawable.bg_card_light);
((FrameLayout.LayoutParams) ll.getLayoutParams()).setMargins(sideMargin, margin, sideMargin, lastCard ? margin : 0);
if (position == 0 && hasShareLocationItem()) {
createItem(parent, inflater, ll, 0, NotesFragment.SHARE_LOCATION_FILE);
return fl;
}
int headerInd = getHeaderIndex(hasShareLocationItem() ? position - 1 : position);
HeaderViewHolder headerVH = new HeaderViewHolder(inflater.inflate(R.layout.list_item_header, parent, false));
setupHeader((int) items.get(headerInd), headerVH);
ll.addView(headerVH.view);
for (int i = headerInd + 1; i < items.size(); i++) {
Object item = items.get(i);
if (item instanceof Recording) {
createItem(parent, inflater, ll, i, (Recording) item);
} else {
break;
}
}
return fl;
}
}
Aggregations