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

The following examples show how to use com.baidu.mapapi.map.offline.MKOLUpdateElement. 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: 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 #2
Source File: DownloadActivity.java    From BaiduMap-TrafficAssistant with MIT License 6 votes vote down vote up
private void initView() {

		province = (Spinner) findViewById(R.id.province);
		city = (Spinner) findViewById(R.id.city);

		province.setOnItemSelectedListener(this);
		city.setOnItemSelectedListener(this);

		// cityNameView = (EditText) findViewById(R.id.city);
		stateView = (TextView) findViewById(R.id.state);
		progressBar = (ProgressBar) findViewById(R.id.progressBar);

		// 获取已下过的离线地图信息
		localMapList = mOffline.getAllUpdateInfo();
		if (localMapList == null) {
			localMapList = new ArrayList<MKOLUpdateElement>();
		}

		ListView localMapListView = (ListView) findViewById(R.id.localmaplist);
		lAdapter = new LocalMapAdapter();
		localMapListView.setAdapter(lAdapter);

	}
 
Example #3
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 #4
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 #5
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 #6
Source File: DownloadActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
void initViewItem(View view, final MKOLUpdateElement e) {
	Button display = (Button) view.findViewById(R.id.display);
	Button remove = (Button) view.findViewById(R.id.remove);
	TextView title = (TextView) view.findViewById(R.id.title);
	TextView ratio = (TextView) view.findViewById(R.id.ratio);
	ratio.setText(e.ratio + "%");
	title.setText(e.cityName);
	if (e.ratio != 100) {
		display.setEnabled(false);
	} else {
		display.setEnabled(true);
	}
	remove.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			mOffline.remove(e.cityID);
			updateView();
		}
	});
	display.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			Intent intent = new Intent();
			intent.putExtra("x", e.geoPt.longitude);// 获得该城市中心点的经纬度;
			intent.putExtra("y", e.geoPt.latitude);
			intent.setClass(context, ShowActivity.class);
			startActivity(intent);
		}
	});
}
 
Example #7
Source File: DownloadActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
@Override
public View getView(int index, View view, ViewGroup arg2) {
	MKOLUpdateElement e = (MKOLUpdateElement) getItem(index);
	view = View.inflate(context, R.layout.offline_localmap_list, null);
	initViewItem(view, e);
	return view;
}
 
Example #8
Source File: DownloadActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
/**
 * 更新状态显示
 */
public void updateView() {
	localMapList = mOffline.getAllUpdateInfo();
	if (localMapList == null) {
		localMapList = new ArrayList<MKOLUpdateElement>();
	}
	lAdapter.notifyDataSetChanged();// 更新ListView;
}
 
Example #9
Source File: BaiduDownloadCityAdapter.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (null == convertView) {
        convertView = getInflater().inflate(R.layout.item_download_city, parent, false);
    }
    TextView textCity = ViewHolder.get(convertView, R.id.text_city);
    final Button btnOptions = ViewHolder.get(convertView, R.id.btn_options);

    final MKOLUpdateElement city = getList().get(position);
    textCity.setText(city.cityName + ",大小:" + formatDataSize(city.size) + (city.ratio != 100 ? (" (" + city.ratio + "%)") : "") + (city.update ? " [可更新]" : ""));

    if (city.status == MKOLUpdateElement.DOWNLOADING){
        btnOptions.setText("暂停");
    }else if (city.status == MKOLUpdateElement.SUSPENDED){
        btnOptions.setText("开始");
    }else if (city.update){
        btnOptions.setText("更新");
    }else {
        btnOptions.setText("删除");
    }
    btnOptions.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != onClickBadiduDownloadOptionsListener){
                onClickBadiduDownloadOptionsListener.onClickBaiduDownloadOptions(btnOptions.getText().toString().trim(), city);
            }
        }
    });

    return convertView;
}
 
Example #10
Source File: BaiduDownloadMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onClickBaiduDownloadOptions(String option, MKOLUpdateElement city) {
    if ("暂停".equals(option)){
        mOffline.pause(city.cityID);
    }else if ("删除".equals(option)){
        delCity(city);
    }else if ("开始".equals(option)){
        mOffline.start(city.cityID);
    }else if ("更新".equals(option)){
        mOffline.update(city.cityID);
    }
}
 
Example #11
Source File: BaiduDownloadMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void getList() {
    if (null != mOffline) {
        List<MKOLUpdateElement> list = mOffline.getAllUpdateInfo();

        if (null == cityAdapter) {
            cityAdapter = new BaiduDownloadCityAdapter(getActivity(), list);
            cityAdapter.setOnClickBadiduDownloadOptionsListener(this);
            listOffline.setAdapter(cityAdapter);
        } else {
            cityAdapter.setList(list, true);
            cityAdapter.notifyDataSetChanged();
        }
    }

}
 
Example #12
Source File: BaiduDownloadCityAdapter.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (null == convertView) {
        convertView = getInflater().inflate(R.layout.item_download_city, parent, false);
    }
    TextView textCity = ViewHolder.get(convertView, R.id.text_city);
    final Button btnOptions = ViewHolder.get(convertView, R.id.btn_options);

    final MKOLUpdateElement city = getList().get(position);
    textCity.setText(city.cityName + ",大小:" + formatDataSize(city.size) + (city.ratio != 100 ? (" (" + city.ratio + "%)") : "") + (city.update ? " [可更新]" : ""));

    if (city.status == MKOLUpdateElement.DOWNLOADING){
        btnOptions.setText("暂停");
    }else if (city.status == MKOLUpdateElement.SUSPENDED){
        btnOptions.setText("开始");
    }else if (city.update){
        btnOptions.setText("更新");
    }else {
        btnOptions.setText("删除");
    }
    btnOptions.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != onClickBadiduDownloadOptionsListener){
                onClickBadiduDownloadOptionsListener.onClickBaiduDownloadOptions(btnOptions.getText().toString().trim(), city);
            }
        }
    });

    return convertView;
}
 
Example #13
Source File: BaiduDownloadMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClickBaiduDownloadOptions(String option, MKOLUpdateElement city) {
    if ("暂停".equals(option)){
        mOffline.pause(city.cityID);
    }else if ("删除".equals(option)){
        delCity(city);
    }else if ("开始".equals(option)){
        mOffline.start(city.cityID);
    }else if ("更新".equals(option)){
        mOffline.update(city.cityID);
    }
}
 
Example #14
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 #15
Source File: BaiduDownloadMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void getList() {
    if (null != mOffline) {
        List<MKOLUpdateElement> list = mOffline.getAllUpdateInfo();

        if (null == cityAdapter) {
            cityAdapter = new BaiduDownloadCityAdapter(getActivity(), list);
            cityAdapter.setOnClickBadiduDownloadOptionsListener(this);
            listOffline.setAdapter(cityAdapter);
        } else {
            cityAdapter.setList(list, true);
            cityAdapter.notifyDataSetChanged();
        }
    }

}
 
Example #16
Source File: BaiduDownloadMapFragment.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    MKOLUpdateElement element = (MKOLUpdateElement) listOffline.getAdapter().getItem(position);
    delCity(element);
}
 
Example #17
Source File: BaiduDownloadMapFragment.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    MKOLUpdateElement element = (MKOLUpdateElement) listOffline.getAdapter().getItem(position);
    delCity(element);
}
 
Example #18
Source File: BaiduDownloadCityAdapter.java    From BmapLite with Apache License 2.0 2 votes vote down vote up
public BaiduDownloadCityAdapter(Context context, List<MKOLUpdateElement> list) {
    super(context, list);

}
 
Example #19
Source File: BaiduDownloadCityAdapter.java    From BmapLite with GNU General Public License v3.0 2 votes vote down vote up
public BaiduDownloadCityAdapter(Context context, List<MKOLUpdateElement> list) {
    super(context, list);

}
 
Example #20
Source File: BaiduDownloadCityAdapter.java    From BmapLite with GNU General Public License v3.0 votes vote down vote up
void onClickBaiduDownloadOptions(String option, MKOLUpdateElement city); 
Example #21
Source File: BaiduDownloadCityAdapter.java    From BmapLite with Apache License 2.0 votes vote down vote up
void onClickBaiduDownloadOptions(String option, MKOLUpdateElement city);