[and] Changed title on browsing.
This commit is contained in:
parent
1adcd85366
commit
3505a50180
5 changed files with 40 additions and 12 deletions
|
@ -67,6 +67,11 @@ public:
|
|||
return m_storage.FormatParentName(info);
|
||||
}
|
||||
|
||||
string GetTitleByUrl(string const & url)
|
||||
{
|
||||
return m_storage.GetTitleFromUrl(url)->GetTitle();
|
||||
}
|
||||
|
||||
private:
|
||||
Storage m_storage;
|
||||
};
|
||||
|
@ -86,7 +91,7 @@ extern "C"
|
|||
* Method: query
|
||||
* Signature: (Ljava/lang/String;DD)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_example_travelguide_cpp_Storage_query(JNIEnv * env, jobject thiz, jstring query,
|
||||
JNIEXPORT void JNICALL Java_com_example_travelguide_cpp_Storage_query(JNIEnv * env, jclass clazz, jstring query,
|
||||
jboolean useLocation, jdouble lat, jdouble lon)
|
||||
{
|
||||
STORAGE.Query(JString2StdString(env, query), useLocation, lat, lon);
|
||||
|
@ -98,7 +103,7 @@ JNIEXPORT void JNICALL Java_com_example_travelguide_cpp_Storage_query(JNIEnv * e
|
|||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_com_example_travelguide_cpp_Storage_getResultSize
|
||||
(JNIEnv * env, jobject thiz)
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
return STORAGE.GetResultSize();
|
||||
}
|
||||
|
@ -109,7 +114,7 @@ JNIEXPORT jint JNICALL Java_com_example_travelguide_cpp_Storage_getResultSize
|
|||
* Signature: (I)Lcom/example/travelguide/article/ArticleInfo;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_example_travelguide_cpp_Storage_getArticleInfoByIndex
|
||||
(JNIEnv * env, jobject thiz, jint index)
|
||||
(JNIEnv * env, jclass clazz, jint index)
|
||||
{
|
||||
ArticleInfo const & info = STORAGE.GetArticleInfoByIndex(index);
|
||||
jclass ArtInfoClass = env->FindClass("com/example/travelguide/article/ArticleInfo");
|
||||
|
@ -130,6 +135,12 @@ JNIEXPORT void JNICALL Java_com_example_travelguide_cpp_Storage_nativeInitIndex
|
|||
STORAGE.Init(env, assetManager);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_example_travelguide_cpp_Storage_getTitleByUrl
|
||||
(JNIEnv * env, jclass clazz, jstring url)
|
||||
{
|
||||
return StdString2JString(env, STORAGE.GetTitleByUrl(JString2StdString(env, url)));
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -7,13 +7,21 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: com_example_travelguide_cpp_Storage
|
||||
* Method: getTitleByUrl
|
||||
* Signature: (Ljava/lang/String;)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_example_travelguide_cpp_Storage_getTitleByUrl
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: com_example_travelguide_cpp_Storage
|
||||
* Method: query
|
||||
* Signature: (Ljava/lang/String;ZDD)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_example_travelguide_cpp_Storage_query
|
||||
(JNIEnv *, jobject, jstring, jboolean, jdouble, jdouble);
|
||||
(JNIEnv *, jclass, jstring, jboolean, jdouble, jdouble);
|
||||
|
||||
/*
|
||||
* Class: com_example_travelguide_cpp_Storage
|
||||
|
@ -21,7 +29,7 @@ JNIEXPORT void JNICALL Java_com_example_travelguide_cpp_Storage_query
|
|||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_com_example_travelguide_cpp_Storage_getResultSize
|
||||
(JNIEnv *, jobject);
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: com_example_travelguide_cpp_Storage
|
||||
|
@ -29,7 +37,7 @@ JNIEXPORT jint JNICALL Java_com_example_travelguide_cpp_Storage_getResultSize
|
|||
* Signature: (I)Lcom/example/travelguide/article/ArticleInfo;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_example_travelguide_cpp_Storage_getArticleInfoByIndex
|
||||
(JNIEnv *, jobject, jint);
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
/*
|
||||
* Class: com_example_travelguide_cpp_Storage
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.example.travelguide.ArticleInfoListFragment.OnListIconClickedListener
|
|||
import com.example.travelguide.article.ArticleInfo;
|
||||
import com.example.travelguide.article.ArticlePathFinder;
|
||||
import com.example.travelguide.article.ObbPathFinder;
|
||||
import com.example.travelguide.cpp.Storage;
|
||||
import com.example.travelguide.util.Utils;
|
||||
|
||||
/**
|
||||
|
@ -114,6 +115,13 @@ public class ArticleInfoDetailFragment extends Fragment implements OnClickListen
|
|||
super.onPageStarted(view, url, favicon);
|
||||
showView(mProgressContainer);
|
||||
hideView(mWebView);
|
||||
|
||||
if (!Utils.isExternalUrl(url))
|
||||
{
|
||||
final String strippedUrl = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
|
||||
final String title = Storage.getTitleByUrl(strippedUrl);
|
||||
mTitle.setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,9 +33,8 @@ public class QueryResultLoader extends AsyncTaskLoader<Storage>
|
|||
public Storage loadInBackground()
|
||||
{
|
||||
Storage.initAssets(getContext());
|
||||
final Storage storage = new Storage();
|
||||
storage.query(mQuery, mUseLocation, mLat, mLon);
|
||||
return storage;
|
||||
Storage.query(mQuery, mUseLocation, mLat, mLon);
|
||||
return new Storage();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,11 +24,13 @@ public class Storage
|
|||
sIsAssetsInited = true;
|
||||
}
|
||||
|
||||
public native void query(String query, boolean useLocation, double lat, double lon);
|
||||
public native static String getTitleByUrl(String url);
|
||||
|
||||
public native int getResultSize();
|
||||
public native static void query(String query, boolean useLocation, double lat, double lon);
|
||||
|
||||
public native ArticleInfo getArticleInfoByIndex(int index);
|
||||
public native static int getResultSize();
|
||||
|
||||
public native static ArticleInfo getArticleInfoByIndex(int index);
|
||||
|
||||
native private static void nativeInitIndex(AssetManager am);
|
||||
|
||||
|
|
Reference in a new issue