Search in sources :

Example 11 with Recording

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;
    }
}
Also used : Context(android.content.Context) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) LinearLayout(android.widget.LinearLayout) NonNull(androidx.annotation.NonNull)

Aggregations

Recording (net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording)11 File (java.io.File)4 ArrayList (java.util.ArrayList)3 MapMarker (net.osmand.plus.mapmarkers.MapMarker)3 GPXFile (net.osmand.GPXUtilities.GPXFile)2 WptPt (net.osmand.GPXUtilities.WptPt)2 LatLon (net.osmand.data.LatLon)2 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)2 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)2 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)2 FileSubtype (net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype)2 Context (android.content.Context)1 Intent (android.content.Intent)1 PointF (android.graphics.PointF)1 Uri (android.net.Uri)1 Pair (android.util.Pair)1 LayoutInflater (android.view.LayoutInflater)1 FrameLayout (android.widget.FrameLayout)1 LinearLayout (android.widget.LinearLayout)1 NonNull (androidx.annotation.NonNull)1