com.baidu.mapapi.map.offline.MKOfflineMap Java Examples

The following examples show how to use com.baidu.mapapi.map.offline.MKOfflineMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OfflineMapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onGetOfflineMapState(int type, int state) {
    switch (type) {
        case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
            MKOLUpdateElement update = mOffline.getUpdateInfo(state);
            // 处理下载进度更新提示
            if (update != null) {
                LogUtils.debug(String.format("%s : %d%%", update.cityName, update.ratio));
            }
        }
        break;
        case MKOfflineMap.TYPE_NEW_OFFLINE:
            // 有新离线地图安装
            LogUtils.debug(String.format("add offlinemap num:%d", state));
            break;
        case MKOfflineMap.TYPE_VER_UPDATE:
            // 版本更新提示
            // MKOLUpdateElement e = mOffline.getUpdateInfo(state);
            break;
        default:
            break;
    }
}
 
Example #2
Source File: OfflineMapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
@Override
public void onGetOfflineMapState(int type, int state) {
    switch (type) {
        case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
            MKOLUpdateElement update = mOffline.getUpdateInfo(state);
            // 处理下载进度更新提示
            if (update != null) {
                LogUtils.debug(String.format("%s : %d%%", update.cityName, update.ratio));
            }
        }
        break;
        case MKOfflineMap.TYPE_NEW_OFFLINE:
            // 有新离线地图安装
            LogUtils.debug(String.format("add offlinemap num:%d", state));
            break;
        case MKOfflineMap.TYPE_VER_UPDATE:
            // 版本更新提示
            // MKOLUpdateElement e = mOffline.getUpdateInfo(state);
            break;
        default:
            break;
    }
}
 
Example #3
Source File: DownloadActivity.java    From BaiduMap-TrafficAssistant with MIT License 6 votes vote down vote up
@Override
public void onGetOfflineMapState(int type, int state) {
	switch (type) {
	case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
		MKOLUpdateElement update = mOffline.getUpdateInfo(state);
		// 处理下载进度更新提示
		if (update != null) {
			stateView.setText(String.format("%s : %d%%", update.cityName,
					update.ratio));
			updateView();

			progressBar.setProgress(update.ratio);
		}
	}
		break;
	}

}
 
Example #4
Source File: OfflineMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void getData() {
        mOffline = new MKOfflineMap();
        mOffline.init(this);

        amapManager = new OfflineMapManager(getActivity(), this);

//        try {
//            MapsInitializer.initialize(getActivity());
//            File dir = getActivity().getExternalFilesDir("amap");
//            if (!dir.exists()){
//                dir.mkdir();
//            }
//            MapsInitializer.sdcardDir = dir.getPath();
//        } catch (RemoteException e) {
//            e.printStackTrace();
//        }

        offlineCityList = mOffline.getOfflineCityList();

        if (null != offlineCityList && !offlineCityList.isEmpty()) {

            for (MKOLSearchRecord record : offlineCityList) {
                if (null == record.childCities || record.childCities.isEmpty()) {
                    ArrayList<MKOLSearchRecord> child = new ArrayList<>();
                    child.add(record);
                    record.childCities = child;
                }
                if (1 == record.cityType) {
                    record.childCities.add(0, record);
                }

            }


            mOfflineCityExpandAdapter = new OfflineCityExpandAdapter(getActivity(), offlineCityList);
            mExpandListCity.setAdapter(mOfflineCityExpandAdapter);
        }

    }
 
Example #5
Source File: BaiduDownloadMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void getData() {
    mOffline = new MKOfflineMap();
    mOffline.init(this);

    TimerTask task = new TimerTask() {
        @Override
        public void run() {
            handler.sendEmptyMessage(TIME_UP);
        }
    };

    timer = new Timer(true);
    timer.schedule(task, 1000, 1000);
}
 
Example #6
Source File: BaiduDownloadMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onGetOfflineMapState(int type, int state) {
    switch (type) {
        case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
            MKOLUpdateElement update = mOffline.getUpdateInfo(state);
            // 处理下载进度更新提示
            if (update != null) {
                LogUtils.debug(String.format("%s : %d%%", update.cityName, update.ratio));
            }
        }
        break;
        case MKOfflineMap.TYPE_NEW_OFFLINE:
            // 有新离线地图安装
            LogUtils.debug(String.format("add offlinemap num:%d", state));
            break;
        case MKOfflineMap.TYPE_VER_UPDATE:
            // 版本更新
            final MKOLUpdateElement e = mOffline.getUpdateInfo(state);

            showAlertDialog("提示", e.cityName + "有新版本了,是否更新?", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mOffline.update(e.cityID);
                }
            }, null);

            break;
        default:
            break;
    }
}
 
Example #7
Source File: OfflineMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void getData() {
        mOffline = new MKOfflineMap();
        mOffline.init(this);

        amapManager = new OfflineMapManager(getActivity(), this);

//        try {
//            MapsInitializer.initialize(getActivity());
//            File dir = getActivity().getExternalFilesDir("amap");
//            if (!dir.exists()){
//                dir.mkdir();
//            }
//            MapsInitializer.sdcardDir = dir.getPath();
//        } catch (RemoteException e) {
//            e.printStackTrace();
//        }

        offlineCityList = mOffline.getOfflineCityList();

        if (null != offlineCityList && !offlineCityList.isEmpty()) {

            for (MKOLSearchRecord record : offlineCityList) {
                if (null == record.childCities || record.childCities.isEmpty()) {
                    ArrayList<MKOLSearchRecord> child = new ArrayList<>();
                    child.add(record);
                    record.childCities = child;
                }
                if (1 == record.cityType) {
                    record.childCities.add(0, record);
                }

            }


            mOfflineCityExpandAdapter = new OfflineCityExpandAdapter(getActivity(), offlineCityList);
            mExpandListCity.setAdapter(mOfflineCityExpandAdapter);
        }

    }
 
Example #8
Source File: BaiduDownloadMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void getData() {
    mOffline = new MKOfflineMap();
    mOffline.init(this);

    TimerTask task = new TimerTask() {
        @Override
        public void run() {
            handler.sendEmptyMessage(TIME_UP);
        }
    };

    timer = new Timer(true);
    timer.schedule(task, 1000, 1000);
}
 
Example #9
Source File: BaiduDownloadMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onGetOfflineMapState(int type, int state) {
    switch (type) {
        case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
            MKOLUpdateElement update = mOffline.getUpdateInfo(state);
            // 处理下载进度更新提示
            if (update != null) {
                LogUtils.debug(String.format("%s : %d%%", update.cityName, update.ratio));
            }
        }
        break;
        case MKOfflineMap.TYPE_NEW_OFFLINE:
            // 有新离线地图安装
            LogUtils.debug(String.format("add offlinemap num:%d", state));
            break;
        case MKOfflineMap.TYPE_VER_UPDATE:
            // 版本更新
            final MKOLUpdateElement e = mOffline.getUpdateInfo(state);

            showAlertDialog("提示", e.cityName + "有新版本了,是否更新?", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mOffline.update(e.cityID);
                }
            }, null);

            break;
        default:
            break;
    }
}
 
Example #10
Source File: DownloadActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	this.context = this;
	SDKInitializer.initialize(getApplicationContext());
	setContentView(R.layout.activity_download);
	mOffline = new MKOfflineMap();
	mOffline.init(this);
	initView();
	initAdapter();
	province.setAdapter(arrayAdapterProvince);

}