Add on click listeners
This commit is contained in:
parent
9b7664448e
commit
ae01e250a9
3 changed files with 35 additions and 7 deletions
|
@ -69,8 +69,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginLeft="56dp"
|
android:layout_marginLeft="44dp"
|
||||||
android:layout_marginStart="56dp">
|
android:layout_marginStart="44dp">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/use_location_button"
|
android:id="@+id/use_location_button"
|
||||||
|
@ -80,8 +80,8 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingLeft="12dp"
|
||||||
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingRight="12dp"
|
||||||
android:text="@string/use_location"
|
android:text="@string/use_location"
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
android:textColor="?attr/color_dialog_buttons"
|
||||||
osmand:textAllCapsCompat="true"
|
osmand:textAllCapsCompat="true"
|
||||||
|
@ -95,8 +95,8 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingLeft="12dp"
|
||||||
android:paddingStart="@dimen/measurement_tool_text_button_padding_small"
|
android:paddingRight="12dp"
|
||||||
android:text="@string/shared_string_do_not_use"
|
android:text="@string/shared_string_do_not_use"
|
||||||
android:textColor="?attr/color_dialog_buttons"
|
android:textColor="?attr/color_dialog_buttons"
|
||||||
osmand:textAllCapsCompat="true"
|
osmand:textAllCapsCompat="true"
|
||||||
|
|
|
@ -216,6 +216,16 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUseLocationClick() {
|
||||||
|
Toast.makeText(mapActivity, "use location", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDoNotUseLocationClick() {
|
||||||
|
Toast.makeText(mapActivity, "do not use location", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600;
|
boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600;
|
||||||
markersRv.setPadding(0, 0, 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 72 : 108));
|
markersRv.setPadding(0, 0, 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 72 : 108));
|
||||||
|
|
|
@ -87,6 +87,20 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
||||||
|
|
||||||
if (holder instanceof UseLocationCardViewHolder) {
|
if (holder instanceof UseLocationCardViewHolder) {
|
||||||
final UseLocationCardViewHolder locationCardHolder = (UseLocationCardViewHolder) holder;
|
final UseLocationCardViewHolder locationCardHolder = (UseLocationCardViewHolder) holder;
|
||||||
|
|
||||||
|
locationCardHolder.useLocationBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
listener.onUseLocationClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
locationCardHolder.doNotUseLocationBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
listener.onDoNotUseLocationClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (holder instanceof MapMarkerItemViewHolder) {
|
} else if (holder instanceof MapMarkerItemViewHolder) {
|
||||||
MapMarker marker = getItem(pos);
|
MapMarker marker = getItem(pos);
|
||||||
final MapMarkerItemViewHolder itemHolder = (MapMarkerItemViewHolder) holder;
|
final MapMarkerItemViewHolder itemHolder = (MapMarkerItemViewHolder) holder;
|
||||||
|
@ -115,7 +129,7 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
||||||
itemHolder.firstDescription.setVisibility((pos == firstMarkerPos || pos == lastMarkerPos) ? View.VISIBLE : View.GONE);
|
itemHolder.firstDescription.setVisibility((pos == firstMarkerPos || pos == lastMarkerPos) ? View.VISIBLE : View.GONE);
|
||||||
itemHolder.bottomShadow.setVisibility(pos == lastMarkerPos ? View.VISIBLE : View.GONE);
|
itemHolder.bottomShadow.setVisibility(pos == lastMarkerPos ? View.VISIBLE : View.GONE);
|
||||||
itemHolder.divider.setVisibility(pos == lastMarkerPos ? View.GONE : View.VISIBLE);
|
itemHolder.divider.setVisibility(pos == lastMarkerPos ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
if (pos == firstMarkerPos) {
|
if (pos == firstMarkerPos) {
|
||||||
itemHolder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + " • ");
|
itemHolder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + " • ");
|
||||||
} else if (pos == lastMarkerPos) {
|
} else if (pos == lastMarkerPos) {
|
||||||
|
@ -203,6 +217,10 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
||||||
void onDragStarted(RecyclerView.ViewHolder holder);
|
void onDragStarted(RecyclerView.ViewHolder holder);
|
||||||
|
|
||||||
void onDragEnded(RecyclerView.ViewHolder holder);
|
void onDragEnded(RecyclerView.ViewHolder holder);
|
||||||
|
|
||||||
|
void onUseLocationClick();
|
||||||
|
|
||||||
|
void onDoNotUseLocationClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UseLocationCardViewHolder extends RecyclerView.ViewHolder {
|
private class UseLocationCardViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
Loading…
Reference in a new issue