Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/jni/com/mapswithme/maps/SponsoredHotel.cpp15
-rw-r--r--android/res/layout/item_nearby.xml62
-rw-r--r--android/res/layout/place_page_details.xml2
-rw-r--r--android/res/layout/place_page_hotel_nearby.xml32
-rw-r--r--android/res/values/dimens.xml4
-rw-r--r--android/res/values/strings.xml1
-rw-r--r--android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java113
-rw-r--r--android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java34
-rw-r--r--android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java77
9 files changed, 339 insertions, 1 deletions
diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp
index c297e13f45..ab264187c7 100644
--- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp
+++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp
@@ -15,6 +15,7 @@ jmethodID g_priceCallback;
jmethodID g_descriptionCallback;
jmethodID g_facilitiesCallback;
jmethodID g_imagesCallback;
+jmethodID g_nearbyCallback;
void PrepareClassRefs(JNIEnv * env, jclass hotelClass)
{
@@ -33,6 +34,8 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass)
g_facilitiesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onFacilitiesReceived", "(Ljava/lang/String;[I[Ljava/lang/String;)V");
// static void onImagesReceived(final String id, String[] urls)
g_imagesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onImagesReceived", "(Ljava/lang/String;[Ljava/lang/String;)V");
+ // static void onNearbyReceived(final String id)
+ g_nearbyCallback = jni::GetStaticMethodID(env, g_hotelClass, "onNearbyReceived", "(Ljava/lang/String;)V");
}
} // namespace
@@ -130,4 +133,16 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestImages(JNI
"http://www.litorehotel.com/web/en/images/placeholders/1920x1200-0.jpg"}));
}
+// static void nativeRequestNearby(String id, double lat, double lon);
+JNIEXPORT void JNICALL
+Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestNearby(JNIEnv * env, jclass clazz, jstring id, jdouble lat, jdouble lon)
+{
+ PrepareClassRefs(env, clazz);
+
+ string const hotelId = jni::ToNativeString(env, id);
+
+ //TODO make request
+ env->CallStaticVoidMethod(g_hotelClass, g_nearbyCallback, jni::ToJavaString(env, hotelId));
+}
+
} // extern "C"
diff --git a/android/res/layout/item_nearby.xml b/android/res/layout/item_nearby.xml
new file mode 100644
index 0000000000..99c55a5529
--- /dev/null
+++ b/android/res/layout/item_nearby.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:paddingTop="@dimen/margin_half_plus"
+ android:paddingBottom="@dimen/margin_half_plus"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground"
+ tools:background="#4000FFFF">
+
+ <ImageView
+ android:id="@+id/iv__icon"
+ android:layout_width="@dimen/placepage_hotel_nearby_icon_size"
+ android:layout_height="@dimen/placepage_hotel_nearby_icon_size"
+ android:layout_centerVertical="true"
+ tools:src="@color/base_green"/>
+
+ <LinearLayout
+ android:id="@+id/ll__info"
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="@dimen/margin_double"
+ android:layout_marginStart="@dimen/margin_double"
+ android:layout_centerVertical="true"
+ android:layout_toRightOf="@id/iv__icon"
+ android:layout_toEndOf="@id/iv__icon"
+ android:gravity="center_vertical">
+
+ <TextView
+ android:id="@+id/tv__title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:maxLines="1"
+ android:textAppearance="@style/MwmTextAppearance.Body1"
+ tools:text="Bowery"/>
+ <TextView
+ android:id="@+id/tv__type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/margin_quarter"
+ android:maxLines="1"
+ android:textAppearance="@style/MwmTextAppearance.Body3"
+ tools:text="Subway Station"/>
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/tv__distance"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:layout_toRightOf="@id/ll__info"
+ android:layout_toEndOf="@id/ll__info"
+ android:maxLines="1"
+ android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
+ android:gravity="end"
+ tools:text="800 ft"/>
+</RelativeLayout> \ No newline at end of file
diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml
index 155a206bc0..cff136e493 100644
--- a/android/res/layout/place_page_details.xml
+++ b/android/res/layout/place_page_details.xml
@@ -55,6 +55,8 @@
<include layout="@layout/place_page_cuisine"/>
+ <include layout="@layout/place_page_hotel_nearby"/>
+
<include layout="@layout/place_page_more"/>
<include layout="@layout/divider_horizontal"/>
diff --git a/android/res/layout/place_page_hotel_nearby.xml b/android/res/layout/place_page_hotel_nearby.xml
new file mode 100644
index 0000000000..9c27aaa5e5
--- /dev/null
+++ b/android/res/layout/place_page_hotel_nearby.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/ll__place_hotel_nearby"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:minHeight="@dimen/height_block_base"
+ android:visibility="gone"
+ tools:background="#4000FFFF"
+ tools:visibility="visible">
+
+ <include layout="@layout/divider_horizontal"/>
+
+ <TextView
+ android:layout_marginLeft="@dimen/margin_base"
+ android:layout_marginRight="@dimen/margin_base"
+ android:layout_marginTop="@dimen/margin_base"
+ style="@style/PlacePageTitleText"
+ android:text="@string/placepage_hotel_nearby"/>
+
+ <com.mapswithme.maps.widget.StaticGridView
+ android:id="@+id/gv__place_hotel_nearby"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="@dimen/margin_base"
+ android:layout_marginRight="@dimen/margin_base"
+ android:layout_marginTop="@dimen/margin_half"
+ android:layout_marginBottom="@dimen/margin_half"
+ android:numColumns="1"
+ tools:listitem="@layout/item_nearby"/>
+</LinearLayout> \ No newline at end of file
diff --git a/android/res/values/dimens.xml b/android/res/values/dimens.xml
index ae3275e251..d9fad64f46 100644
--- a/android/res/values/dimens.xml
+++ b/android/res/values/dimens.xml
@@ -149,4 +149,8 @@
<dimen name="placepage_hotel_gallery_width">150dp</dimen>
<dimen name="gallery_image_height">84dp</dimen>
+ <!-- Nearby-->
+ <dimen name="placepage_hotel_nearby_height">64dp</dimen>
+ <dimen name="placepage_hotel_nearby_icon_size">24dp</dimen>
+
</resources>
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml
index 064aa3b800..f19f55527f 100644
--- a/android/res/values/strings.xml
+++ b/android/res/values/strings.xml
@@ -972,4 +972,5 @@
<string name="whats_new_booking_improve_title">Save when booking hotels</string>
<string name="whats_new_booking_improve_message">Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels.</string>
<string name="placepage_hotel_facilities">Facilities</string>
+ <string name="placepage_hotel_nearby">Nearby</string>
</resources>
diff --git a/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java
new file mode 100644
index 0000000000..4086a2fabf
--- /dev/null
+++ b/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java
@@ -0,0 +1,113 @@
+package com.mapswithme.maps.widget.placepage;
+
+import com.mapswithme.maps.R;
+import com.mapswithme.util.ThemeUtils;
+
+import android.content.res.Resources;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class NearbyAdapter extends BaseAdapter {
+
+ public NearbyAdapter(OnItemClickListener listener) {
+ mListener = listener;
+ }
+
+ public interface OnItemClickListener {
+ void onItemClick(SponsoredHotel.NearbyObject item);
+ }
+
+ private List<SponsoredHotel.NearbyObject> items = new ArrayList<>();
+ private final OnItemClickListener mListener;
+
+ @Override
+ public int getCount() {
+ return items.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return items.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+ if (convertView == null) {
+ convertView = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.item_nearby, parent, false);
+ holder = new ViewHolder(convertView, mListener);
+ convertView.setTag(holder);
+ } else {
+ holder = (ViewHolder) convertView.getTag();
+ }
+
+ holder.bind(items.get(position));
+
+ return convertView;
+ }
+
+ public void setItems(
+ List<SponsoredHotel.NearbyObject> items) {
+ this.items = items;
+ notifyDataSetChanged();
+ }
+
+ private static class ViewHolder implements View.OnClickListener {
+ final OnItemClickListener mListener;
+ ImageView mIcon;
+ TextView mTitle;
+ TextView mType;
+ TextView mDistance;
+ SponsoredHotel.NearbyObject mItem;
+
+ public ViewHolder(View view, OnItemClickListener listener) {
+ mListener = listener;
+ mIcon = (ImageView) view.findViewById(R.id.iv__icon);
+ mTitle = (TextView) view.findViewById(R.id.tv__title);
+ mType = (TextView) view.findViewById(R.id.tv__type);
+ mDistance = (TextView) view.findViewById(R.id.tv__distance);
+ view.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (mListener != null) {
+ mListener.onItemClick(mItem);
+ }
+ }
+
+ public void bind(SponsoredHotel.NearbyObject item) {
+ mItem = item;
+ String packageName = mType.getContext().getPackageName();
+ final boolean isNightTheme = ThemeUtils.isNightTheme();
+ Resources resources = mType.getResources();
+ int categoryRes = resources.getIdentifier(item.getCategory(), "string", packageName);
+ if (categoryRes == 0)
+ throw new IllegalStateException("Can't get string resource id for category:" + item.getCategory());
+
+ String iconId = "ic_category_" + item.getCategory();
+ if (isNightTheme)
+ iconId = iconId + "_night";
+ int iconRes = resources.getIdentifier(iconId, "drawable", packageName);
+ if (iconRes == 0)
+ throw new IllegalStateException("Can't get icon resource id:" + iconId);
+ mIcon.setImageResource(iconRes);
+ mTitle.setText(item.getTitle());
+ mType.setText(categoryRes);
+ mDistance.setText(item.getDistance());
+ }
+ }
+}
diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
index 9c3ec9f0c3..8676ccf47b 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
@@ -1,5 +1,7 @@
package com.mapswithme.maps.widget.placepage;
+import com.google.android.gms.maps.model.LatLng;
+
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@@ -91,7 +93,9 @@ public class PlacePageView extends RelativeLayout
LineCountTextView.OnLineCountCalculatedListener,
SponsoredHotel.OnFacilitiesReceivedListener,
SponsoredHotel.OnImagesReceivedListener,
- RecyclerClickListener {
+ RecyclerClickListener,
+ SponsoredHotel.OnNearbyReceivedListener,
+ NearbyAdapter.OnItemClickListener {
private static final String PREF_USE_DMS = "use_dms";
private boolean mIsDocked;
@@ -147,6 +151,7 @@ public class PlacePageView extends RelativeLayout
private View mHotelMoreFacilities;
private View mHotelGallery;
private RecyclerView mRvHotelGallery;
+ private View mHotelNearby;
// Animations
private BaseShadowController mShadowController;
@@ -159,6 +164,7 @@ public class PlacePageView extends RelativeLayout
private boolean mIsLatLonDms;
private FacilitiesAdapter mFacilitiesAdapter = new FacilitiesAdapter();
private GalleryAdapter mGalleryAdapter;
+ private NearbyAdapter mNearbyAdapter = new NearbyAdapter(this);
// Downloader`s stuff
private DownloaderStatusIcon mDownloaderIcon;
@@ -317,6 +323,9 @@ public class PlacePageView extends RelativeLayout
mGalleryAdapter = new GalleryAdapter(getContext());
mGalleryAdapter.setListener(this);
mRvHotelGallery.setAdapter(mGalleryAdapter);
+ mHotelNearby = findViewById(R.id.ll__place_hotel_nearby);
+ GridView gvHotelNearby = (GridView) findViewById(R.id.gv__place_hotel_nearby);
+ gvHotelNearby.setAdapter(mNearbyAdapter);
mButtons = new PlacePageButtons(this, ppButtons, new PlacePageButtons.ItemListener()
{
@@ -449,6 +458,7 @@ public class PlacePageView extends RelativeLayout
SponsoredHotel.setDescriptionListener(this);
SponsoredHotel.setFacilitiesListener(this);
SponsoredHotel.setImagesListener(this);
+ SponsoredHotel.setNearbyListener(this);
}
@Override
@@ -514,6 +524,20 @@ public class PlacePageView extends RelativeLayout
}
@Override
+ public void onNearbyReceived(String id, ArrayList<SponsoredHotel.NearbyObject> objects) {
+ if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) {
+ return;
+ }
+
+ if (objects == null || objects.isEmpty()) {
+ UiUtils.hide(mHotelNearby);
+ return;
+ }
+ UiUtils.show(mHotelNearby);
+ mNearbyAdapter.setItems(objects);
+ }
+
+ @Override
public void onLineCountCalculated(boolean grater) {
mHotelMoreDescription.setVisibility(grater ? VISIBLE : GONE);
}
@@ -523,6 +547,11 @@ public class PlacePageView extends RelativeLayout
GalleryActivity.start(getContext(), mGalleryAdapter.getItems(), mMapObject.getTitle());
}
+ @Override
+ public void onItemClick(SponsoredHotel.NearbyObject item) {
+// TODO go to selected object on map
+ }
+
private void onBookingClick(final boolean book)
{
// TODO (trashkalmar): Set correct text
@@ -662,6 +691,8 @@ public class PlacePageView extends RelativeLayout
SponsoredHotel.requestDescription(mSponsoredHotel.getId(), locale.toString());
SponsoredHotel.requestFacilities(mSponsoredHotel.getId(), locale.toString());
SponsoredHotel.requestImages(mSponsoredHotel.getId(), locale.toString());
+ SponsoredHotel.requestNearby(mSponsoredHotel.getId(), new LatLng(mMapObject.getLat(),
+ mMapObject.getLon()));
}
String country = MapManager.nativeGetSelectedCountry();
@@ -764,6 +795,7 @@ public class PlacePageView extends RelativeLayout
UiUtils.hide(mHotelDescription);
UiUtils.hide(mHotelFacilities);
UiUtils.hide(mHotelGallery);
+ UiUtils.hide(mHotelNearby);
}
else {
UiUtils.hide(mWebsite);
diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java
index 64f7f9c936..e563d4ee18 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java
@@ -1,5 +1,7 @@
package com.mapswithme.maps.widget.placepage;
+import com.google.android.gms.maps.model.LatLng;
+
import android.support.annotation.Nullable;
import android.support.annotation.DrawableRes;
import android.support.annotation.UiThread;
@@ -51,6 +53,36 @@ public final class SponsoredHotel
}
}
+ public static class NearbyObject {
+ private final String category;
+ private final String title;
+ private final String distance;
+ private final LatLng location;
+
+ public NearbyObject(String category, String title, String distance, LatLng location) {
+ this.category = category;
+ this.title = title;
+ this.distance = distance;
+ this.location = location;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getDistance() {
+ return distance;
+ }
+
+ public LatLng getLocation() {
+ return location;
+ }
+ }
+
interface OnPriceReceivedListener
{
void onPriceReceived(String id, String price, String currency);
@@ -71,6 +103,11 @@ public final class SponsoredHotel
void onImagesReceived(String id, ArrayList<Image> images);
}
+ interface OnNearbyReceivedListener
+ {
+ void onNearbyReceived(String id, ArrayList<NearbyObject> images);
+ }
+
// Hotel ID -> Price
private static final Map<String, Price> sPriceCache = new HashMap<>();
// Hotel ID -> Description
@@ -79,10 +116,13 @@ public final class SponsoredHotel
private static final Map<String, List<FacilityType>> sFacilitiesCache = new HashMap<>();
// Hotel ID -> Images
private static final Map<String, ArrayList<Image>> sImagesCache = new HashMap<>();
+ // Hotel ID -> Nearby
+ private static final Map<String, ArrayList<NearbyObject>> sNearbyCache = new HashMap<>();
private static WeakReference<OnPriceReceivedListener> sPriceListener;
private static WeakReference<OnDescriptionReceivedListener> sDescriptionListener;
private static WeakReference<OnFacilitiesReceivedListener> sFacilityListener;
private static WeakReference<OnImagesReceivedListener> sImagesListener;
+ private static WeakReference<OnNearbyReceivedListener> sNearbyListener;
private String mId;
@@ -149,6 +189,11 @@ public final class SponsoredHotel
sImagesListener = new WeakReference<>(listener);
}
+ public static void setNearbyListener(OnNearbyReceivedListener listener)
+ {
+ sNearbyListener = new WeakReference<>(listener);
+ }
+
@DrawableRes
public static int mapFacilityId(int facilityId) {
// TODO map facility id to drawable resource
@@ -201,6 +246,20 @@ public final class SponsoredHotel
nativeRequestImages(id, locale);
}
+ static void requestNearby(String id, LatLng position)
+ {
+ ArrayList<NearbyObject> objects = sNearbyCache.get(id);
+ if (objects != null) {
+ OnNearbyReceivedListener listener = sNearbyListener.get();
+ if (listener == null)
+ sNearbyListener = null;
+ else
+ listener.onNearbyReceived(id, objects);
+ }
+
+ nativeRequestNearby(id, position.latitude, position.longitude);
+ }
+
@SuppressWarnings("unused")
private static void onPriceReceived(String id, String price, String currency)
{
@@ -277,10 +336,28 @@ public final class SponsoredHotel
listener.onImagesReceived(id, result);
}
+ @SuppressWarnings("unused")
+ private static void onNearbyReceived(String id)
+ {
+ ArrayList<NearbyObject> result = new ArrayList<>();
+ result.add(new NearbyObject("transport", "Bowery", "800 ft", new LatLng(0, 0)));
+ result.add(new NearbyObject("food", "Egg Shop", "300 ft", new LatLng(0, 0)));
+ result.add(new NearbyObject("shop", "Fay Yee Inc", "200 ft", new LatLng(0, 0)));
+
+ sNearbyCache.put(id, result);
+
+ OnNearbyReceivedListener listener = sNearbyListener.get();
+ if (listener == null)
+ sNearbyListener = null;
+ else
+ listener.onNearbyReceived(id, result);
+ }
+
@Nullable
public static native SponsoredHotel nativeGetCurrent();
private static native void nativeRequestPrice(String id, String currencyCode);
private static native void nativeRequestDescription(String id, String locale);
private static native void nativeRequestFacilities(String id, String locale);
private static native void nativeRequestImages(String id, String locale);
+ private static native void nativeRequestNearby(String id, double lat, double lon);
}