forked from organicmaps/organicmaps
Lazy profile rank updates.
This commit is contained in:
parent
e5ef0f94de
commit
c988ebe143
3 changed files with 6 additions and 4 deletions
|
@ -121,7 +121,7 @@ Java_com_mapswithme_maps_editor_OsmOAuth_nativeGetOsmUsername(JNIEnv * env, jcla
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_editor_OsmOAuth_nativeUpdateOsmUserStats(JNIEnv * env, jclass clazz, jstring jUsername)
|
||||
Java_com_mapswithme_maps_editor_OsmOAuth_nativeUpdateOsmUserStats(JNIEnv * env, jclass clazz, jstring jUsername, jboolean forceUpdate)
|
||||
{
|
||||
static jclass const statsClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/editor/data/UserStats");
|
||||
static jmethodID const statsCtor = jni::GetConstructorID(env, statsClazz, "(IILjava/lang/String;J)V");
|
||||
|
@ -130,7 +130,9 @@ Java_com_mapswithme_maps_editor_OsmOAuth_nativeUpdateOsmUserStats(JNIEnv * env,
|
|||
static jmethodID const listenerId = jni::GetStaticMethodID(env, osmAuthClazz, "onUserStatsUpdated", "(Lcom/mapswithme/maps/editor/data/UserStats;)V");
|
||||
|
||||
string const username = jni::ToNativeString(env, jUsername);
|
||||
g_framework->NativeFramework()->UpdateUserStats(username, editor::UserStatsLoader::UpdatePolicy::Force, [username]()
|
||||
auto const policy = forceUpdate ? editor::UserStatsLoader::UpdatePolicy::Force
|
||||
: editor::UserStatsLoader::UpdatePolicy::Lazy;
|
||||
g_framework->NativeFramework()->UpdateUserStats(username, policy, [username]()
|
||||
{
|
||||
editor::UserStats const & userStats = g_framework->NativeFramework()->GetUserStats(username);
|
||||
if (!userStats.IsValid())
|
||||
|
|
|
@ -153,5 +153,5 @@ public final class OsmOAuth
|
|||
@Nullable
|
||||
public static native String nativeGetOsmUsername(String token, String secret);
|
||||
|
||||
public static native void nativeUpdateOsmUserStats(String username);
|
||||
public static native void nativeUpdateOsmUserStats(String username, boolean forceUpdate);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ProfileFragment extends AuthFragment implements View.OnClickListene
|
|||
initViews(view);
|
||||
refreshViews();
|
||||
OsmOAuth.setUserStatsListener(this);
|
||||
OsmOAuth.nativeUpdateOsmUserStats(OsmOAuth.getUsername());
|
||||
OsmOAuth.nativeUpdateOsmUserStats(OsmOAuth.getUsername(), false /*forceUpdate*/);
|
||||
}
|
||||
|
||||
private void initViews(View view)
|
||||
|
|
Loading…
Add table
Reference in a new issue