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); }
bool TryParseImageDetails(const Search::SdkModel::SearchResultModel& searchResultModel, std::string& out_imageUrl) { const std::string& vendor = searchResultModel.GetVendor(); if(vendor == YelpVendorName) { return Yelp::SdkModel::TryParseImageDetails(searchResultModel, out_imageUrl); } else if(vendor == EegeoVendorName) { return EegeoPois::SdkModel::TryParseImageDetails(searchResultModel, out_imageUrl); } return false; }