Add "Online Search" button to empty state
This commit is contained in:
parent
30fc1c69cb
commit
f13c0145c5
5 changed files with 90 additions and 22 deletions
|
@ -10,9 +10,8 @@
|
|||
android:id="@+id/empty_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingBottom="24dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="24dp"
|
||||
android:visibility="visible">
|
||||
|
||||
<View
|
||||
|
@ -23,8 +22,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
android:layout_weight="1">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -37,23 +35,24 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/nothing_found"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:text="@string/nothing_found"/>
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/nothing_found_descr"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:text="@string/nothing_found_descr"/>
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -74,10 +73,11 @@
|
|||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/increase_radius_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="48dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
|
@ -96,4 +96,44 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/online_search_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="48dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/online_search_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:src="@drawable/ic_world_globe_dark"
|
||||
android:tint="?attr/color_dialog_buttons"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_online_address"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -77,6 +77,7 @@ import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
|||
import net.osmand.plus.search.listitems.QuickSearchHeaderListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem.SearchMoreItemOnClickListener;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||
import net.osmand.search.SearchUICore;
|
||||
|
@ -1709,15 +1710,23 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
private void addMoreButton() {
|
||||
if (!paused && !cancelPrev && mainSearchFragment != null) {
|
||||
QuickSearchMoreListItem moreListItem =
|
||||
new QuickSearchMoreListItem(app, null, new OnClickListener() {
|
||||
new QuickSearchMoreListItem(app, null, new SearchMoreItemOnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
public void increaseRadiusOnClick() {
|
||||
if (!interruptedSearch) {
|
||||
SearchSettings settings = searchUICore.getSearchSettings();
|
||||
searchUICore.updateSettings(settings.setRadiusLevel(settings.getRadiusLevel() + 1));
|
||||
}
|
||||
runCoreSearch(searchQuery, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onlineSearchOnClick() {
|
||||
startOnlinePoiSearch();
|
||||
mainSearchFragment.getAdapter().clear();
|
||||
updateTabbarVisibility(false);
|
||||
runCoreSearch(searchQuery, false, true);
|
||||
}
|
||||
});
|
||||
moreListItem.setInterruptedSearch(interruptedSearch);
|
||||
moreListItem.setEmptySearch(isResultEmpty());
|
||||
|
|
|
@ -190,7 +190,8 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
QuickSearchListItemType type = getItem(position).getType();
|
||||
return type != QuickSearchListItemType.HEADER
|
||||
&& type != QuickSearchListItemType.TOP_SHADOW
|
||||
&& type != QuickSearchListItemType.BOTTOM_SHADOW;
|
||||
&& type != QuickSearchListItemType.BOTTOM_SHADOW
|
||||
&& type != QuickSearchListItemType.SEARCH_MORE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -232,6 +233,18 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
view.findViewById(R.id.empty_search).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.more_divider).setVisibility(View.GONE);
|
||||
}
|
||||
view.findViewById(R.id.increase_radius_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
((QuickSearchMoreListItem) listItem).increaseRadiusOnClick();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.online_search_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
((QuickSearchMoreListItem) listItem).onlineSearchOnClick();
|
||||
}
|
||||
});
|
||||
} else if (type == QuickSearchListItemType.BUTTON) {
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) app
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.osmand.plus.search.listitems.QuickSearchBottomShadowListItem;
|
|||
import net.osmand.plus.search.listitems.QuickSearchButtonListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItemType;
|
||||
import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
|
||||
import net.osmand.plus.search.listitems.QuickSearchTopShadowListItem;
|
||||
import net.osmand.search.core.ObjectType;
|
||||
import net.osmand.search.core.SearchResult;
|
||||
|
@ -83,9 +82,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
if (index < listAdapter.getCount()) {
|
||||
QuickSearchListItem item = listAdapter.getItem(index);
|
||||
if (item != null) {
|
||||
if (item.getType() == QuickSearchListItemType.SEARCH_MORE) {
|
||||
((QuickSearchMoreListItem) item).getOnClickListener().onClick(view);
|
||||
} else if (item.getType() == QuickSearchListItemType.BUTTON) {
|
||||
if (item.getType() == QuickSearchListItemType.BUTTON) {
|
||||
((QuickSearchButtonListItem) item).getOnClickListener().onClick(view);
|
||||
} else if (item.getType() == QuickSearchListItemType.SEARCH_RESULT) {
|
||||
SearchResult sr = item.getSearchResult();
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
package net.osmand.plus.search.listitems;
|
||||
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class QuickSearchMoreListItem extends QuickSearchListItem {
|
||||
|
||||
private String name;
|
||||
private OnClickListener onClickListener;
|
||||
private SearchMoreItemOnClickListener onClickListener;
|
||||
private boolean emptySearch;
|
||||
private boolean interruptedSearch;
|
||||
private String findMore;
|
||||
private String restartSearch;
|
||||
private String increaseRadius;
|
||||
|
||||
public QuickSearchMoreListItem(OsmandApplication app, String name, OnClickListener onClickListener) {
|
||||
public QuickSearchMoreListItem(OsmandApplication app, String name, SearchMoreItemOnClickListener onClickListener) {
|
||||
super(app, null);
|
||||
this.name = name;
|
||||
this.onClickListener = onClickListener;
|
||||
|
@ -59,7 +57,18 @@ public class QuickSearchMoreListItem extends QuickSearchListItem {
|
|||
this.emptySearch = emptySearch;
|
||||
}
|
||||
|
||||
public OnClickListener getOnClickListener() {
|
||||
return onClickListener;
|
||||
public void increaseRadiusOnClick() {
|
||||
onClickListener.increaseRadiusOnClick();
|
||||
}
|
||||
|
||||
public void onlineSearchOnClick() {
|
||||
onClickListener.onlineSearchOnClick();
|
||||
}
|
||||
|
||||
public interface SearchMoreItemOnClickListener {
|
||||
|
||||
void increaseRadiusOnClick();
|
||||
|
||||
void onlineSearchOnClick();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue