use of com.junjunguo.pocketmaps.model.listeners.OnClickAddressListener in project PocketMaps by junjunguo.
the class MapActions method initSearchLocationHandler.
private void initSearchLocationHandler(final boolean isStartP, final boolean fromFavourite) {
int viewID = R.id.map_nav_settings_to_search;
if (isStartP) {
viewID = R.id.map_nav_settings_from_search;
}
if (fromFavourite) {
viewID = R.id.map_nav_settings_to_favorite;
if (isStartP) {
viewID = R.id.map_nav_settings_from_favorite;
}
}
final ViewGroup pointItem = (ViewGroup) activity.findViewById(viewID);
pointItem.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
setBgColor(pointItem, R.color.my_primary_light);
return true;
case MotionEvent.ACTION_UP:
setBgColor(pointItem, R.color.my_primary);
Intent intent = new Intent(activity, GeocodeActivity.class);
OnClickAddressListener callbackListener = new OnClickAddressListener() {
@Override
public void onClick(Address addr) {
GeoPoint newPos = new GeoPoint(addr.getLatitude(), addr.getLongitude());
if (isStartP) {
Destination.getDestination().setStartPoint(newPos);
fromLocalET.setText(Destination.getDestination().getStartPointToString());
addFromMarker(Destination.getDestination().getStartPoint());
navSettingsFromVP.setVisibility(View.INVISIBLE);
} else {
Destination.getDestination().setEndPoint(newPos);
toLocalET.setText(Destination.getDestination().getEndPointToString());
addToMarker(Destination.getDestination().getEndPoint());
navSettingsToVP.setVisibility(View.INVISIBLE);
}
boolean showingNavigator = activeNavigator();
if (!showingNavigator) {
navSettingsVP.setVisibility(View.VISIBLE);
}
MapHandler.getMapHandler().centerPointOnMap(newPos, 0, 0, 0);
}
};
GeoPoint[] points = null;
if (fromFavourite) {
points = new GeoPoint[3];
points[0] = Destination.getDestination().getStartPoint();
points[1] = Destination.getDestination().getEndPoint();
Location curLoc = MapActivity.getmCurrentLocation();
if (curLoc != null) {
points[2] = new GeoPoint(curLoc.getLatitude(), curLoc.getLongitude());
}
}
GeocodeActivity.setPre(callbackListener, points);
activity.startActivity(intent);
return true;
}
return false;
}
});
}
use of com.junjunguo.pocketmaps.model.listeners.OnClickAddressListener in project PocketMaps by junjunguo.
the class GeocodeActivity method showAddresses.
private RecyclerView showAddresses(List<Address> list) {
setContentView(R.layout.activity_addresses);
OnClickAddressListener l = new OnClickAddressListener() {
@Override
public void onClick(Address addr) {
log("Address selected: " + addr);
GeocodeActivity.this.finish();
if (callbackListener != null) {
callbackListener.onClick(addr);
}
}
};
MyAddressAdapter adapter = new MyAddressAdapter(list, l);
RecyclerView listView = (RecyclerView) findViewById(R.id.my_addr_recycler_view);
listView.setHasFixedSize(true);
// use a linear layout manager
LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
layoutManager.setOrientation(LinearLayout.VERTICAL);
listView.setLayoutManager(layoutManager);
listView.setItemAnimator(new DefaultItemAnimator());
listView.setAdapter(adapter);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.my_addr_add_fab);
if (locations == null) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
log("Plus selected!");
showFavAdd();
}
});
}
return listView;
}
Aggregations