[android] Support drawable in PlaceHolderView

Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
Jean-Baptiste
2025-10-26 14:29:49 +01:00
committed by x7z4w
parent d4ac51cc02
commit 2b5930dff8
14 changed files with 26 additions and 11 deletions

View File

@@ -282,11 +282,11 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
{
if (isEmptySearchResults())
{
requirePlaceholder().setContent(R.string.search_not_found, R.string.search_not_found_query);
requirePlaceholder().setContent(R.string.search_not_found, R.string.search_not_found_query, R.drawable.ic_search_fail);
}
else if (isEmpty())
{
requirePlaceholder().setContent(R.string.bookmarks_empty_list_title, R.string.bookmarks_empty_list_message);
requirePlaceholder().setContent(R.string.bookmarks_empty_list_title, R.string.bookmarks_empty_list_message, R.drawable.ic_bookmarks);
}
boolean isEmptyRecycler = isEmpty() || isEmptySearchResults();

View File

@@ -222,10 +222,10 @@ public class DownloaderFragment
return;
if (mAdapter != null && mAdapter.isSearchResultsMode())
placeholder.setContent(R.string.search_not_found, R.string.search_not_found_query);
placeholder.setContent(R.string.search_not_found, R.string.search_not_found_query, R.drawable.ic_search_fail);
else
placeholder.setContent(R.string.downloader_no_downloaded_maps_title,
R.string.downloader_no_downloaded_maps_message);
R.string.downloader_no_downloaded_maps_message, R.drawable.ic_download);
}
@Override

View File

@@ -273,7 +273,7 @@ public class SearchFragment extends BaseMwmFragment implements SearchListener, C
RecyclerView mResults = mResultsFrame.findViewById(R.id.recycler);
setRecyclerScrollListener(mResults);
mResultsPlaceholder = mResultsFrame.findViewById(R.id.placeholder);
mResultsPlaceholder.setContent(R.string.search_not_found, R.string.search_not_found_query);
mResultsPlaceholder.setContent(R.string.search_not_found, R.string.search_not_found_query, R.drawable.ic_search_fail);
mSearchAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver()
{

View File

@@ -47,7 +47,7 @@ public class SearchHistoryFragment extends BaseMwmRecyclerFragment<SearchHistory
super.onViewCreated(view, savedInstanceState);
getRecyclerView().setLayoutManager(new LinearLayoutManager(view.getContext()));
mPlaceHolder = view.findViewById(R.id.placeholder);
mPlaceHolder.setContent(R.string.search_history_title, R.string.search_history_text);
mPlaceHolder.setContent(R.string.search_history_title, R.string.search_history_text, R.drawable.ic_search_recent);
getAdapter().registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override

View File

@@ -3,6 +3,7 @@ package app.organicmaps.widget;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -11,6 +12,7 @@ import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.core.content.ContextCompat;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.android.material.textview.MaterialTextView;
@@ -176,9 +178,10 @@ public class PlaceholderView extends LinearLayout
return view.getMeasuredHeight() + params.bottomMargin + params.topMargin;
}
public void setContent(@StringRes int titleRes, @StringRes int subtitleRes)
public void setContent(@StringRes int titleRes, @StringRes int subtitleRes, @DrawableRes int iconRes)
{
mTitle.setText(titleRes);
mSubtitle.setText(subtitleRes);
mImage.setImageDrawable(ContextCompat.getDrawable(getContext(), iconRes));
}
}