Search in sources :

Example 1 with L7

use of com.jamesfchen.map.model.L7 in project spacecraft-android by JamesfChen.

the class ILbsApiServer method mockRequestLocation.

private void mockRequestLocation() {
    if (listenerlist == null)
        return;
    Type type = new TypeToken<List<L7>>() {
    }.getType();
    List<L7> l7_list = new Gson().fromJson(ResourceUtils.readAssets2String("l7_list.json"), type);
    try {
        Thread.sleep(1500);
        for (L7 l7 : l7_list) {
            double lat = l7.appLocation.lat;
            double lon = l7.appLocation.lon;
            long cid = l7.appCellInfos.get(0).get(0).cid;
            long lac = l7.appCellInfos.get(0).get(0).lac;
            // startservice 回调(onHandleIntent) 和bindservice回调(onServiceConnected) 都是异步,所以sleep模拟onHandleIntent处理耗时,
            // Thread.sleep(500);
            final int N = listenerlist.beginBroadcast();
            for (int i = 0; i < N; i++) {
                ILbsListener l = listenerlist.getBroadcastItem(i);
                if (l == null)
                    continue;
                AppCellInfo appCellInfo = new AppCellInfo();
                appCellInfo.cid = cid;
                appCellInfo.lac = lac;
                appCellInfo.isRegistered = true;
                appCellInfo.isMockData = true;
                AppLocation appLocation = new AppLocation();
                appLocation.lat = lat;
                appLocation.lon = lon;
                appLocation.isMockData = true;
                ++count;
                l.onLocationChanged(appLocation, Collections.singletonList(appCellInfo), count);
            }
            listenerlist.finishBroadcast();
        }
    } catch (InterruptedException | RemoteException e) {
        e.printStackTrace();
    }
}
Also used : Gson(com.google.gson.Gson) L7(com.jamesfchen.map.model.L7) Type(java.lang.reflect.Type) AppCellInfo(com.jamesfchen.map.model.AppCellInfo) ILbsListener(com.jamesfchen.map.ILbsListener) RemoteCallbackList(android.os.RemoteCallbackList) List(java.util.List) AppLocation(com.jamesfchen.map.model.AppLocation) RemoteException(android.os.RemoteException)

Aggregations

RemoteCallbackList (android.os.RemoteCallbackList)1 RemoteException (android.os.RemoteException)1 Gson (com.google.gson.Gson)1 ILbsListener (com.jamesfchen.map.ILbsListener)1 AppCellInfo (com.jamesfchen.map.model.AppCellInfo)1 AppLocation (com.jamesfchen.map.model.AppLocation)1 L7 (com.jamesfchen.map.model.L7)1 Type (java.lang.reflect.Type)1 List (java.util.List)1