Java 类com.baidu.mapapi.map.offline.MKOLUpdateElement 实例源码

项目:BikeHelper    文件:OfflineMapManager.java   
public static ArrayList<MKOLUpdateElement> getAllUpdateInfo() {
    ArrayList<MKOLUpdateElement> info = mMKOfflineMap.getAllUpdateInfo();
    if (info == null) {
        return new ArrayList<MKOLUpdateElement>();
    }
    Collections.sort(info, new Comparator<MKOLUpdateElement>() {

        @Override
        public int compare(MKOLUpdateElement lhs, MKOLUpdateElement rhs) {
            if (lhs.cityID < rhs.cityID)
                return -1;
            if (lhs.cityID > rhs.cityID)
                return 1;
            return 0;
        }

    });
    return info;
}
项目:BikeHelper    文件:OfflineMapActivity.java   
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    MKOLUpdateElement element = mData.get(position - 1);
    final int cityID = element.cityID;
    AlertDialog.Builder builder = new Builder(this);
    builder.setTitle(R.string.delete_offline_map);
    String message = "";
    if (element.cityName.startsWith(getString(R.string.country)))
        message = getString(R.string.delete_offline_map_msg_country);
    else
        message = getString(R.string.delete_offline_map_msg);
    message = message.replace("CITY", element.cityName);
    builder.setMessage(message);
    builder.setNegativeButton(R.string.confirm, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            OfflineMapManager.delete(cityID);
            updateOfflineMapsView();
        }
    });
    builder.setPositiveButton(R.string.cancel, null);
    builder.show();
    return true;
}
项目:Tower-develop    文件:BaiduMapOfflineMapPreference.java   
@Override
public void onGetOfflineMapState(int type, int state) {
    switch (type) {
        case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
            MKOLUpdateElement update = mOffline.getUpdateInfo(state);
            // display download progress
            if (update != null) {
                mStateView.setText(String.format("%s : %d%%", update.cityName, update.ratio));
                updateView();
            }
        }
        break;
        case MKOfflineMap.TYPE_NEW_OFFLINE:
            // Prompt offline map update is available
            Log.d("Baidu offline map", String.format("add offlinemap num:%d", state));
            break;
        case MKOfflineMap.TYPE_VER_UPDATE:
            // Not used yet
            break;
        default:
            break;
    }
}
项目:BaiduOfflineDownloadDemo    文件:OfflineMapItem.java   
@Override
public int compareTo(OfflineMapItem o2) {
    // TODO Auto-generated method stub
    int f1 = getStatus() == MKOLUpdateElement.FINISHED ? 1 : 0;
    int f2 = o2.getStatus() == MKOLUpdateElement.FINISHED ? 1 : 0;
    if(f1 != f2){
        return f1 - f2;
    }

    String s1 = getPinyin();
       String s2 = o2.getPinyin();
       int len1 = s1.length();
       int len2 = s2.length();
       int n = Math.min(len1, len2);
       char v1[] = s1.toCharArray();
       char v2[] = s2.toCharArray();
       int pos = 0;
       while (n-- != 0) {
           char c1 = v1[pos];
           char c2 = v2[pos];
           if (c1 != c2) { return c1 - c2; }
           pos++;
       }
       return len1 - len2;
}
项目:BaiduMap-TrafficAssistant    文件:DownloadActivity.java   
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);

    }
项目:BaiduMap-TrafficAssistant    文件:DownloadActivity.java   
@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;
    }

}
项目:BikeHelper    文件:OfflineMapManager.java   
public static ArrayList<MKOLUpdateElement> getAllUpdateInfo() {
    ArrayList<MKOLUpdateElement> info = mMKOfflineMap.getAllUpdateInfo();
    if (info == null) {
        return new ArrayList<MKOLUpdateElement>();
    }
    Collections.sort(info, new Comparator<MKOLUpdateElement>() {

        @Override
        public int compare(MKOLUpdateElement lhs, MKOLUpdateElement rhs) {
            if (lhs.cityID < rhs.cityID)
                return -1;
            if (lhs.cityID > rhs.cityID)
                return 1;
            return 0;
        }

    });
    return info;
}
项目:BikeHelper    文件:OfflineMapActivity.java   
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    MKOLUpdateElement element = mData.get(position - 1);
    final int cityID = element.cityID;
    AlertDialog.Builder builder = new Builder(this);
    builder.setTitle(R.string.delete_offline_map);
    String message = "";
    if (element.cityName.startsWith(getString(R.string.country)))
        message = getString(R.string.delete_offline_map_msg_country);
    else
        message = getString(R.string.delete_offline_map_msg);
    message = message.replace("CITY", element.cityName);
    builder.setMessage(message);
    builder.setNegativeButton(R.string.confirm, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            OfflineMapManager.delete(cityID);
            updateOfflineMapsView();
        }
    });
    builder.setPositiveButton(R.string.cancel, null);
    builder.show();
    return true;
}
项目:FrontOne    文件:OfflineMapActivity.java   
@Override
public void onGetOfflineMapState(int type, int state) {
    // TODO Auto-generated method stub
    switch (type) {
    case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
        MKOLUpdateElement update = mOffline.getUpdateInfo(state);
        // 处理下载进度更新提示
        if (update != null) {
            mRatioTextView.setText(String.format("%d%%", update.ratio));
            if(update.ratio==100){
                mImageButtonDownLoad.setVisibility(View.GONE);
                mRatioTextView.setVisibility(View.GONE);
            }
            updateView();
        }
    }
    }

}
项目:BikeHelper    文件:OfflineMapManager.java   
public static int[] getAllExistedCityIDs() {
    ArrayList<MKOLUpdateElement> downloadedItems = getAllUpdateInfo();
    if (downloadedItems != null) {
        int[] downloadedCityIDs = new int[downloadedItems.size()];
        for (int i = 0; i < downloadedItems.size(); i++) {
            downloadedCityIDs[i] = downloadedItems.get(i).cityID;
        }
        return downloadedCityIDs;
    }
    return new int[0];
}
项目:BikeHelper    文件:OfflineMapActivity.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    MKOLUpdateElement element = mData.get(position - 1);
    if (element.update || element.ratio < 100) {
        if (OfflineMapManager.isDownloading(element.cityID)) {
            OfflineMapManager.pause(element.cityID);
        } else {
            if (element.update) {
                OfflineMapManager.delete(element.cityID);
            }
            OfflineMapManager.start(element.cityID);
        }
        updateOfflineMapsView();
    }
}
项目:Tower-develop    文件:BaiduMapOfflineMapPreference.java   
@Override
public View getView(int index, View view, ViewGroup arg2) {
    MKOLUpdateElement e = (MKOLUpdateElement) getItem(index);
    if (view == null) {
        view = View.inflate(BaiduMapOfflineMapPreference.this.getContext(), R.layout.list_baidumap_offline_localmap_item, null);
    }
    initViewItem(view, e);
    return view;
}
项目:Tower-develop    文件:BaiduMapOfflineMapPreference.java   
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 update = (TextView) view.findViewById(R.id.update);
    TextView ratio = (TextView) view.findViewById(R.id.ratio);
    ratio.setText(e.ratio + "%");
    title.setText(e.cityName);
    if (e.update) {
        update.setText(R.string.pref_baidu_map_offline_preference_download_available);
    } else {
        update.setText(R.string.pref_baidu_map_offline_preference_download_latest);
    }
    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) {
            // Not used yet.
        }
    });
}
项目:BaiduOfflineDownloadDemo    文件:OfflineExpandableListAdapter.java   
public void setData(OfflineMapItem data) {
    this.data = data;

    tvCityname.setText(data.getCityName());
    tvSize.setText(FileUtil.getSizeStr(data.getSize()));

    if(data.getStatus() == MKOLUpdateElement.UNDEFINED){
        ivDownload.setVisibility(View.VISIBLE);

    }else{
        ivDownload.setVisibility(View.INVISIBLE);
    }

    if(data.getStatus() == MKOLUpdateElement.UNDEFINED){
        tvStatus.setText("");

    }else if(data.getStatus() == MKOLUpdateElement.DOWNLOADING){
        tvStatus.setText("(" + data.getProgress() + "%)");

    }else if(data.getStatus() == MKOLUpdateElement.FINISHED){
        tvStatus.setText("(已下载)");

    }else if(data.getStatus() == MKOLUpdateElement.SUSPENDED
            || data.getStatus() >= MKOLUpdateElement.eOLDSMd5Error){
        //暂停、错误,都当作暂停,都是可以继续下载
        tvStatus.setText("(暂停)");               

    }else if(data.getStatus() == MKOLUpdateElement.WAITING){
        tvStatus.setText("(等待)");               

    }else{
        tvStatus.setText("");
    }
}
项目:BaiduOfflineDownloadDemo    文件:OfflineMapAdapter.java   
public void setData(OfflineMapItem data) {
    this.data = data;

    tvCityname.setText(data.getCityName());
    tvSize.setText(FileUtil.getSizeStr(data.getSize()));

    if(data.getStatus() == MKOLUpdateElement.UNDEFINED){
        ivDownload.setVisibility(View.VISIBLE);

    }else{
        ivDownload.setVisibility(View.INVISIBLE);
    }

    if(data.getStatus() == MKOLUpdateElement.UNDEFINED){
        tvStatus.setText("");

    }else if(data.getStatus() == MKOLUpdateElement.DOWNLOADING){
        tvStatus.setText("(" + data.getProgress() + "%)");

    }else if(data.getStatus() == MKOLUpdateElement.FINISHED){
        tvStatus.setText("(已下载)");

    }else if(data.getStatus() == MKOLUpdateElement.SUSPENDED
            || data.getStatus() >= MKOLUpdateElement.eOLDSMd5Error){
        //暂停、未错误,都当作暂停,可以继续下载
        tvStatus.setText("(暂停)");               

    }else if(data.getStatus() == MKOLUpdateElement.WAITING){
        tvStatus.setText("(等待)");               

    }else{
        tvStatus.setText("");
    }
}
项目:BaiduMap-TrafficAssistant    文件:DownloadActivity.java   
/**
 * 更新状态显示
 */
public void updateView() {
    localMapList = mOffline.getAllUpdateInfo();
    if (localMapList == null) {
        localMapList = new ArrayList<MKOLUpdateElement>();
    }
    lAdapter.notifyDataSetChanged();// 更新ListView;
}
项目:BaiduMap-TrafficAssistant    文件:DownloadActivity.java   
@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;
}
项目:BaiduMap-TrafficAssistant    文件:DownloadActivity.java   
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);
        }
    });
}
项目:BikeHelper    文件:OfflineMapManager.java   
public static int[] getAllExistedCityIDs() {
    ArrayList<MKOLUpdateElement> downloadedItems = getAllUpdateInfo();
    if (downloadedItems != null) {
        int[] downloadedCityIDs = new int[downloadedItems.size()];
        for (int i = 0; i < downloadedItems.size(); i++) {
            downloadedCityIDs[i] = downloadedItems.get(i).cityID;
        }
        return downloadedCityIDs;
    }
    return new int[0];
}
项目:BikeHelper    文件:OfflineMapActivity.java   
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    MKOLUpdateElement element = mData.get(position - 1);
    if (element.update || element.ratio < 100) {
        if (OfflineMapManager.isDownloading(element.cityID)) {
            OfflineMapManager.pause(element.cityID);
        } else {
            if (element.update) {
                OfflineMapManager.delete(element.cityID);
            }
            OfflineMapManager.start(element.cityID);
        }
        updateOfflineMapsView();
    }
}
项目:FrontOne    文件:OfflineMapActivity.java   
/**
 * 更新状态显示
 */
public void updateView(){
    mCityList = mOffline.getAllUpdateInfo();
    if (mCityList == null) {
        mCityList = new ArrayList<MKOLUpdateElement>();
    }
    mCityListAdapter.notifyDataSetChanged();
}
项目:BikeHelper    文件:OfflineMapActivity.java   
@Override
public MKOLUpdateElement getItem(int position) {
    return mData.get(position);
}
项目:BaiduOfflineDownloadDemo    文件:OfflineMapItem.java   
public int getStatus() {
    if(mDownInfo != null){
        return mDownInfo.status;
    }
    return MKOLUpdateElement.UNDEFINED;
}
项目:BaiduOfflineDownloadDemo    文件:OfflineMapItem.java   
public MKOLUpdateElement getDownInfo() {
    return mDownInfo;
}
项目:BaiduOfflineDownloadDemo    文件:OfflineMapItem.java   
public void setDownInfo(MKOLUpdateElement mElement) {
    this.mDownInfo = mElement;
}
项目:BaiduOfflineDownloadDemo    文件:BaiduOfflineMapActivity.java   
/**
    * 返回itemsDown.add
    * @param element
    * @param ischeck
    * @return
    */
private OfflineMapItem setElement(MKOLUpdateElement element, boolean ischeck) {
    OfflineMapItem ret = null;

    if (element == null || itemsAll == null) {
        return null;
    }

    if(element.status == MKOLUpdateElement.DOWNLOADING && element.ratio == 100){
        element.status = MKOLUpdateElement.FINISHED;
    }

    for (OfflineMapItem item : itemsAll) {
        if (element.cityID == item.getCityId()) {
            item.setDownInfo(element);

            // 过滤已下载数据
            if (item.getStatus() != MKOLUpdateElement.UNDEFINED) {
                if (ischeck) {
                    if (!itemsDown.contains(item)) {
                        if (itemsDown.add(item)) {
                            ret = item;
                        }
                    }

                } else {
                    if (itemsDown.add(item)) {
                        ret = item;
                    }
                }
            }
            if (!isWake && item.getStatus() == MKOLUpdateElement.WAITING) {
                int id = item.getCityId();
                if (id > 0) {
                    mOffline.start(id);
                }
                isWake = true;
            }
            break;
        }
    }

    return ret;
}
项目:BaiduOfflineDownloadDemo    文件:OfflineMapManagerAdapter.java   
public void setData(OfflineMapItem data) {
    this.data = data;

    tvCityname.setText(data.getCityName());
    tvCityname.setTextColor(Color.BLACK);

    tvSize.setText(FileUtil.getSizeStr(data.getSize()));

    if(expandedCityIds.contains(data.getCityId())){
        lyEditPanel.setVisibility(View.VISIBLE);
        ivExpande.setImageResource(R.drawable.ic_offline_u);
    }else{
        lyEditPanel.setVisibility(View.GONE);
        ivExpande.setImageResource(R.drawable.ic_offline_d);
    }

    if(data.getStatus() == MKOLUpdateElement.DOWNLOADING){
        tvCityname.setTextColor(Color.BLUE);

        tvStatus.setText("正在下载" + data.getProgress() + "%");
        btnDown.setText("暂停");
        pbDownload.setProgress(data.getProgress());

        btnDown.setVisibility(View.VISIBLE);
              pbDownload.setVisibility(View.VISIBLE);
              tvStatus.setVisibility(View.VISIBLE);

    }else if(data.getStatus() == MKOLUpdateElement.FINISHED){
        if(data.isHavaUpdate()){
            tvCityname.setTextColor(Color.BLUE);

            tvStatus.setText("有更新");
            btnDown.setText("更新");
            pbDownload.setProgress(data.getProgress());

            btnDown.setVisibility(View.VISIBLE);
               pbDownload.setVisibility(View.VISIBLE);
               tvStatus.setVisibility(View.VISIBLE);

        }else{
            btnDown.setVisibility(View.GONE);
               pbDownload.setVisibility(View.GONE);
               tvStatus.setVisibility(View.GONE);
        }

    }else if(data.getStatus() == MKOLUpdateElement.SUSPENDED
            || data.getStatus() == MKOLUpdateElement.UNDEFINED
            || data.getStatus() >= MKOLUpdateElement.eOLDSMd5Error){
        tvCityname.setTextColor(Color.BLUE);

        //暂停、未知、错误,都是继续下载
        tvStatus.setText("暂停");
        btnDown.setText("继续");
        pbDownload.setProgress(data.getProgress());

        btnDown.setVisibility(View.VISIBLE);
              pbDownload.setVisibility(View.VISIBLE);
              tvStatus.setVisibility(View.VISIBLE);

    }else if(data.getStatus() == MKOLUpdateElement.WAITING){
        tvCityname.setTextColor(Color.BLUE);

        tvStatus.setText("等待");
        btnDown.setText("暂停");
        pbDownload.setProgress(data.getProgress());

        btnDown.setVisibility(View.VISIBLE);
              pbDownload.setVisibility(View.VISIBLE);
              tvStatus.setVisibility(View.VISIBLE);

    }else{
        btnDown.setVisibility(View.GONE);
              pbDownload.setVisibility(View.GONE);
              tvStatus.setVisibility(View.GONE);
    }
}
项目:BikeHelper    文件:OfflineMapActivity.java   
@Override
public MKOLUpdateElement getItem(int position) {
    return mData.get(position);
}