void SearchResultPoiView::CreateAndShowGeoNamesPoiView(const Search::SdkModel::SearchResultModel& model, bool isPinned) { const std::string viewClass = "com/eegeo/searchresultpoiview/GeoNamesSearchResultPoiView"; m_uiViewClass = CreateJavaClass(viewClass); m_uiView = CreateJavaObject(m_uiViewClass); AndroidSafeNativeThreadAttachment attached(m_nativeState); JNIEnv* env = attached.envForThread; jstring titleStr = env->NewStringUTF(model.GetTitle().c_str()); jstring addressStr = env->NewStringUTF(model.GetSubtitle().c_str()); jstring categoryStr = env->NewStringUTF(model.GetCategory().c_str()); jmethodID displayPoiInfoMethod = env->GetMethodID(m_uiViewClass, "displayPoiInfo", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V"); env->CallVoidMethod( m_uiView, displayPoiInfoMethod, titleStr, addressStr, categoryStr, isPinned ); env->DeleteLocalRef(categoryStr); env->DeleteLocalRef(addressStr); env->DeleteLocalRef(titleStr); }
void SearchResultPoiView::CreateAndShowYelpPoiView(const Search::SdkModel::SearchResultModel& model, bool isPinned) { const std::string viewClass = "com/eegeo/searchresultpoiview/YelpSearchResultPoiView"; m_uiViewClass = CreateJavaClass(viewClass); m_uiView = CreateJavaObject(m_uiViewClass); Search::Yelp::SdkModel::YelpSearchResultModel yelpModel; yelpModel = Search::Yelp::SdkModel::TransformToYelpSearchResult(model); AndroidSafeNativeThreadAttachment attached(m_nativeState); JNIEnv* env = attached.envForThread; jobjectArray humanReadableCategoriesArray = CreateJavaArray(model.GetHumanReadableCategories()); jobjectArray reviewsArray = CreateJavaArray(yelpModel.GetReviews()); jstring titleStr = env->NewStringUTF(model.GetTitle().c_str()); jstring addressStr = env->NewStringUTF(model.GetSubtitle().c_str()); jstring phoneStr = env->NewStringUTF(yelpModel.GetPhone().c_str()); jstring urlStr = env->NewStringUTF(yelpModel.GetWebUrl().c_str()); jstring categoryStr = env->NewStringUTF(model.GetCategory().c_str()); jstring imageUrlStr = env->NewStringUTF(yelpModel.GetImageUrl().c_str()); jstring ratingImageUrlStr = env->NewStringUTF(yelpModel.GetRatingImageUrl().c_str()); jstring vendorStr = env->NewStringUTF(model.GetVendor().c_str()); jmethodID displayPoiInfoMethod = env->GetMethodID(m_uiViewClass, "displayPoiInfo", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;IZ)V"); env->CallVoidMethod( m_uiView, displayPoiInfoMethod, titleStr, addressStr, phoneStr, urlStr, categoryStr, humanReadableCategoriesArray, imageUrlStr, ratingImageUrlStr, vendorStr, reviewsArray, yelpModel.GetReviewCount(), isPinned ); env->DeleteLocalRef(vendorStr); env->DeleteLocalRef(ratingImageUrlStr); env->DeleteLocalRef(imageUrlStr); env->DeleteLocalRef(categoryStr); env->DeleteLocalRef(urlStr); env->DeleteLocalRef(phoneStr); env->DeleteLocalRef(addressStr); env->DeleteLocalRef(titleStr); env->DeleteLocalRef(reviewsArray); env->DeleteLocalRef(humanReadableCategoriesArray); }