Java Code Examples for com.amap.api.maps.offlinemap.OfflineMapStatus#SUCCESS

The following examples show how to use com.amap.api.maps.offlinemap.OfflineMapStatus#SUCCESS . 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: OfflineChild.java    From TraceByAmap with MIT License 6 votes vote down vote up
public boolean onLongClick(View arg0) {
		
//		if (mMapCity.getState() == OfflineMapStatus.LOADING) {
//			amapManager.restart();
//			return false;
//		} 
		
		Log.d("amap-longclick",
				mMapCity.getCity() + " : " + mMapCity.getState());
		if (mMapCity.getState() == OfflineMapStatus.SUCCESS) {
			showDeleteUpdateDialog(mMapCity.getCity());
		} else if (mMapCity.getState() != OfflineMapStatus.CHECKUPDATES) {
			showDeleteDialog(mMapCity.getCity());
		} 
		return false;
	}
 
Example 2
Source File: OfflineMapDownloadService.java    From Maps with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onDownload(int status, int completeCode, String name) {
    StringBuilder sb = new StringBuilder("");

    if (status == OfflineMapStatus.SUCCESS) {
        isCurDownloading = false;
        sb.append(name).append(" 下载完成");
        mNotificationBuilder.setOngoing(false);
        mHandler.sendEmptyMessage(OfflineMapStatus.SUCCESS);
    } else if (status == OfflineMapStatus.ERROR) {
        isCurDownloading = false;
        sb.append("下载失败");
        mNotificationBuilder.setOngoing(false);
    } else if (status == OfflineMapStatus.LOADING) {
        sb.append("正在下载 ").append(name).append(" ").append(completeCode).append("%");
    } else if (status == OfflineMapStatus.UNZIP) {
        sb.append("正在解压 ").append(name).append(" ").append(completeCode).append("%");
    }

    mNotificationBuilder.setContentText(sb);
    mNotificationManager.notify(OFFLINEMAP_DOWNLOAD_NOTIFICATION_ID, mNotificationBuilder.build());
}
 
Example 3
Source File: OfflineMapDownloadService.java    From Maps with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    OfflineMapDownloadService b = a.get();
    if (b != null) {
        if (msg.what == OfflineMapStatus.SUCCESS) {
            b.onHandleIntent();
        }
    }
    super.handleMessage(msg);
}
 
Example 4
Source File: OfflineMapActivity.java    From Maps with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 对一级标签下的二级标签进行设置
 */
@Override
public View getChildView(final int groupPosition,
                         final int childPosition, boolean isLastChild, View convertView,
                         ViewGroup parent) {
    if (convertView == null) {
        convertView = RelativeLayout.inflate(
                getBaseContext(), R.layout.offlinemap_child, null);
    }
    ViewHolder holder = new ViewHolder(convertView);
    holder.cityName.setText(cityMap.get(groupPosition)
            .get(childPosition).getCity());
    holder.citySize.setText((cityMap.get(groupPosition).get(
            childPosition).getSize())
            / (1024 * 1024f) + "MB");

    if (cityMap.get(groupPosition).get(childPosition).getState() == OfflineMapStatus.SUCCESS) {
        holder.cityDown.setText("安装完成");
    } else if (cityMap.get(groupPosition).get(childPosition).getState() == OfflineMapStatus.LOADING) {
        if (groupPosition == OfflineMapActivity.this.groupPosition
                && childPosition == OfflineMapActivity.this.childPosition) {
            holder.cityDown.setText("正在下载" + completeCode + "%");
        } else {
            if (cityMap.get(groupPosition).get(childPosition).getcompleteCode() > 0) {
                holder.cityDown.setText("下载暂停" + cityMap.get(groupPosition).get(childPosition).getcompleteCode() + "%");
            } else {
                holder.cityDown.setText("");
            }
        }
    } else if (cityMap.get(groupPosition).get(childPosition).getState() == OfflineMapStatus.UNZIP) {
        holder.cityDown.setText("正在解压" + completeCode + "%");
    } else if (cityMap.get(groupPosition).get(childPosition).getState() == OfflineMapStatus.LOADING) {
        holder.cityDown.setText("下载");
    }
    return convertView;
}
 
Example 5
Source File: OfflineMapActivity_Old.java    From TraceByAmap with MIT License 4 votes vote down vote up
/**
 * 离线地图下载回调方法
 */
@Override
public void onDownload(int status, int completeCode, String downName) {

	switch (status) {
	case OfflineMapStatus.SUCCESS:
		// changeOfflineMapTitle(OfflineMapStatus.SUCCESS, downName);
		break;
	case OfflineMapStatus.LOADING:
		Log.d("amap-download", "download: " + completeCode + "%" + ","
				+ downName);
		// changeOfflineMapTitle(OfflineMapStatus.LOADING, downName);
		break;
	case OfflineMapStatus.UNZIP:
		Log.d("amap-unzip", "unzip: " + completeCode + "%" + "," + downName);
		// changeOfflineMapTitle(OfflineMapStatus.UNZIP);
		// changeOfflineMapTitle(OfflineMapStatus.UNZIP, downName);
		break;
	case OfflineMapStatus.WAITING:
		Log.d("amap-waiting", "WAITING: " + completeCode + "%" + ","
				+ downName);
		break;
	case OfflineMapStatus.PAUSE:
		Log.d("amap-pause", "pause: " + completeCode + "%" + "," + downName);
		break;
	case OfflineMapStatus.STOP:
		break;
	case OfflineMapStatus.ERROR:
		Log.e("amap-download", "download: " + " ERROR " + downName);
		break;
	case OfflineMapStatus.EXCEPTION_AMAP:
		Log.e("amap-download", "download: " + " EXCEPTION_AMAP " + downName);
		break;
	case OfflineMapStatus.EXCEPTION_NETWORK_LOADING:
		Log.e("amap-download", "download: " + " EXCEPTION_NETWORK_LOADING "
				+ downName);
		Toast.makeText(OfflineMapActivity_Old.this, "网络异常", Toast.LENGTH_SHORT)
				.show();
		amapManager.pause();
		break;
	case OfflineMapStatus.EXCEPTION_SDCARD:
		Log.e("amap-download", "download: " + " EXCEPTION_SDCARD "
				+ downName);
		break;
	default:
		break;
	}

	// changeOfflineMapTitle(status, downName);
	handler.sendEmptyMessage(UPDATE_LIST);

}
 
Example 6
Source File: OfflineChild.java    From TraceByAmap with MIT License 4 votes vote down vote up
@Override
public void handleMessage(Message msg) {
	// TODO Auto-generated method stub
	super.handleMessage(msg);
	int completeCode = (Integer) msg.obj;
	switch (msg.what) {
	case OfflineMapStatus.LOADING:
		
		
		displyaLoadingStatus(completeCode);
		
		
		break;
	case OfflineMapStatus.PAUSE:
		displayPauseStatus(completeCode);
		break;
	case OfflineMapStatus.STOP:
		break;
	case OfflineMapStatus.SUCCESS:
		displaySuccessStatus();
		break;
	case OfflineMapStatus.UNZIP:
		displayUnZIPStatus(completeCode);
		break;
	case OfflineMapStatus.ERROR:
		displayExceptionStatus();
		break;
	case OfflineMapStatus.WAITING:
		displayWaitingStatus(completeCode);
		break;
	case OfflineMapStatus.CHECKUPDATES:
		displayDefault();
		break;
		
	case OfflineMapStatus.EXCEPTION_AMAP:
	case OfflineMapStatus.EXCEPTION_NETWORK_LOADING:
	case OfflineMapStatus.EXCEPTION_SDCARD:
		displayExceptionStatus();
		break;
		
	case OfflineMapStatus.NEW_VERSION:
		displayHasNewVersion();
		break;

	}
}
 
Example 7
Source File: OfflineChild.java    From TraceByAmap with MIT License 4 votes vote down vote up
public void onClick(View view) {
		
//		if(mMapCity.getCity() .equals( "北京")) {
//			new Thread(new Runnable() {
//				
//				@Override
//				public void run() {
//					// TODO Auto-generated method stub
//					for(int i =0; i< 100;i++) {
//						try {
//							amapManager.downloadByCityName("北京");
//							TimeUnit.MILLISECONDS.sleep(500);
//							amapManager.downloadByCityName("上海");
//							TimeUnit.MILLISECONDS.sleep(500);
//						} catch (AMapException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						} catch (InterruptedException e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						}
//					}
//				
//				}
//			}).start();
//			return;
//		}
		
//		// 避免频繁点击事件,避免不断从夫开始下载和暂停下载
//		mOffLineChildView.setEnabled(false);
//		new Handler().postDelayed(new Runnable() {
//			
//			@Override
//			public void run() {
//				mOffLineChildView.setEnabled(true);
//			}
//		},100);// 这个时间段刚刚好

		int completeCode = -1, status = -1;
		if (mMapCity != null) {
			status = mMapCity.getState();
			completeCode = mMapCity.getcompleteCode();

			switch (status) {
			case OfflineMapStatus.UNZIP:
			case OfflineMapStatus.SUCCESS:
				// 解压中何在成功啥不干
				break;
			case OfflineMapStatus.LOADING:
//			case OfflineMapStatus.WAITING:
				pauseDownload();
				// 在下载中的时候点击,表示要暂停
				displayPauseStatus(completeCode);
				break;
			case OfflineMapStatus.PAUSE:
			case OfflineMapStatus.CHECKUPDATES:
			case OfflineMapStatus.ERROR:
			case OfflineMapStatus.WAITING:
//			case OfflineMapStatus.NEW_VERSION:
			default:
				if(startDownload())
					displayWaitingStatus(completeCode);
				else 
					displayExceptionStatus();
//					Toast.makeText(mContext, "SD卡空间不多了", 1000).show();
				// 在暂停中点击,表示要开始下载
				// 在默认状态点击,表示开始下载
				// 在等待中点击,表示要开始下载
				// 要开始下载状态改为等待中,再回调中会自己修改
				break;
			}
			
			Log.e("zxy-child", mMapCity.getCity() + " " + mMapCity.getState());

		}

	}