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

Locals.java « discovery « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3b17fe9e965a4e4ccb4b127bd547f7a894d20555 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.mapswithme.maps.discovery;

import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.mapswithme.util.NetworkPolicy;
import com.mapswithme.util.concurrency.UiThread;

final class Locals
{
  public static final Locals INSTANCE = new Locals();

  @Nullable
  private LocalsListener mListener;

  private Locals() {}

  public void setLocalsListener(@Nullable LocalsListener listener)
  {
    mListener = listener;
  }

  public native void nativeRequestLocals(@NonNull NetworkPolicy policy,
                                         double lat, double lon);

  // Called from JNI.
  @MainThread
  void onLocalsReceived(@NonNull LocalExpert[] experts)
  {
    if (!UiThread.isUiThread())
      throw new AssertionError("Must be called from UI thread!");

    if (mListener != null)
      mListener.onLocalsReceived(experts);
  }

  // Called from JNI.
  @MainThread
  void onLocalsErrorReceived(@NonNull LocalsError error)
  {
    if (!UiThread.isUiThread())
      throw new AssertionError("Must be called from UI thread!");

    if (mListener != null)
      mListener.onLocalsErrorReceived(error);
  }

  public interface LocalsListener
  {
    void onLocalsReceived(@NonNull LocalExpert[] experts);
    void onLocalsErrorReceived(@NonNull LocalsError error);
  }
}