Add on click listeners

This commit is contained in:
Alexander Sytnyk 2017-09-27 18:07:03 +03:00
parent 9b7664448e
commit ae01e250a9
3 changed files with 35 additions and 7 deletions

View file

@ -69,8 +69,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="56dp"
android:layout_marginStart="56dp">
android:layout_marginLeft="44dp"
android:layout_marginStart="44dp">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/use_location_button"
@ -80,8 +80,8 @@
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:text="@string/use_location"
android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true"
@ -95,8 +95,8 @@
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/measurement_tool_text_button_padding_small"
android:paddingStart="@dimen/measurement_tool_text_button_padding_small"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:text="@string/shared_string_do_not_use"
android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true"

View file

@ -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;
markersRv.setPadding(0, 0, 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 72 : 108));

View file

@ -87,6 +87,20 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<RecyclerView.Vie
if (holder instanceof UseLocationCardViewHolder) {
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) {
MapMarker marker = getItem(pos);
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.bottomShadow.setVisibility(pos == lastMarkerPos ? View.VISIBLE : View.GONE);
itemHolder.divider.setVisibility(pos == lastMarkerPos ? View.GONE : View.VISIBLE);
if (pos == firstMarkerPos) {
itemHolder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + "");
} else if (pos == lastMarkerPos) {
@ -203,6 +217,10 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<RecyclerView.Vie
void onDragStarted(RecyclerView.ViewHolder holder);
void onDragEnded(RecyclerView.ViewHolder holder);
void onUseLocationClick();
void onDoNotUseLocationClick();
}
private class UseLocationCardViewHolder extends RecyclerView.ViewHolder {