Example #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.poicategory);

    if (mPoiManager == null) mPoiManager = new PoiManager(this);

    mTitle = (EditText) findViewById(R.id.Title);
    mHidden = (CheckBox) findViewById(R.id.Hidden);
    mIcon = (ImageView) findViewById(R.id.ImageIcon);
    mMinZoom = (EditText) findViewById(R.id.MinZoom);

    Bundle extras = getIntent().getExtras();
    if (extras == null) extras = new Bundle();
    int id = extras.getInt("id", PoiPoint.EMPTY_ID());

    if (id < 0) {
      mPoiCategory = new PoiCategory();
      mTitle.setText(extras.getString("title"));
      mHidden.setChecked(false);
      mIcon.setImageResource(mPoiCategory.IconId);
      mMinZoom.setText("14");
    } else {
      mPoiCategory = mPoiManager.getPoiCategory(id);

      if (mPoiCategory == null) finish();

      mTitle.setText(mPoiCategory.Title);
      mHidden.setChecked(mPoiCategory.Hidden);
      mIcon.setImageResource(mPoiCategory.IconId);
      mMinZoom.setText(Integer.toString(mPoiCategory.MinZoom));
    }

    ((Button) findViewById(R.id.saveButton))
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                doSaveAction();
              }
            });
    ((Button) findViewById(R.id.discardButton))
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                PoiCategoryActivity.this.finish();
              }
            });
    mIcon.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            doSelectIcon();
          }
        });
  }
Example #2
0
  /**
   * 获取兴趣点列表
   *
   * @return
   */
  private List<Map<String, Object>> getData() {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); // 创建List对象	
    WAnalysisFile readFile = new WAnalysisFile(); // 创建自定义类WAnalysisFile对象
    List<PoiPoint> poiList = readFile.getBigPoiPointList(this, tripId); // 获取兴趣点列表
    poiLists = poiList;
    for (int i = 0; i < poiList.size(); i += 1) { // 循环获取兴趣点信息
      Map<String, Object> map = new HashMap<String, Object>();
      PoiPoint poi = poiList.get(i);
      map.put("title", poi.getName()); // 兴趣点标题存储到map中
      String[] poiTel = poi.getTel().split(" "); // 兴趣点多个电话用空格分开的
      String poiTels = "";
      for (int j = 0; j < poiTel.length; j++) {
        if (poiTel.length > 2) {
          break;
        }
        poiTels = poiTels + poiTel[j] + ","; // 拼接兴趣点电话字符串
      }
      if (!"".equals(poiTels)) {
        poiTels = poiTels.substring(0, poiTels.length() - 1); // 去掉末尾的逗号
      }
      map.put("tel", poiTels); // 兴趣点电话存储到map中

      List<String> poiImgList = poi.getImgList();
      if (poiImgList.size() != 0) {
        String tripImg = poi.getImgList().get(0).split("[.]")[0] + ".jpg";
        InputStream iso = null;
        try {
          // 加载图片
          iso =
              this.getAssets()
                  .open(tripId + "/SmallRoute" + "/" + poi.getRouteId() + "/images/" + tripImg);
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        Bitmap bitmap = null;
        bitmap = BitmapFactory.decodeStream(iso);
        map.put("img", bitmap);
      } else {
        int picnum = 0;
        map.put("img", R.drawable.nocolor);
      }
      list.add(map);
    }
    return list;
  }
Example #3
0
  private void doSaveAction() {
    mPoiPoint.Title = mTitle.getText().toString();
    mPoiPoint.CategoryId = (int) mSpinner.getSelectedItemId();
    mPoiPoint.Descr = mDescr.getText().toString();
    mPoiPoint.GeoPoint =
        GeoPoint.fromDouble(
            CoordFormatter.convert(mLat.getText().toString()),
            CoordFormatter.convert(mLon.getText().toString()));
    mPoiPoint.Hidden = mHidden.isChecked();
    try {
      mPoiPoint.Alt = Double.parseDouble(mAlt.getText().toString());
    } catch (NumberFormatException e) {
    }

    mPoiManager.updatePoi(mPoiPoint);
    finish();

    Toast.makeText(PoiActivity.this, R.string.message_saved, Toast.LENGTH_SHORT).show();
  }
Example #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.poi);

    if (mPoiManager == null) mPoiManager = new PoiManager(this);
    mCf = new CoordFormatter(this);

    mTitle = (EditText) findViewById(R.id.Title);
    mLat = (EditText) findViewById(R.id.Lat);
    mLon = (EditText) findViewById(R.id.Lon);
    mAlt = (EditText) findViewById(R.id.Alt);
    mDescr = (EditText) findViewById(R.id.Descr);
    mHidden = (CheckBox) findViewById(R.id.Hidden);

    mLat.setHint(mCf.getHint());
    mLat.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              try {
                mLat.setText(
                    mCf.convertLat(CoordFormatter.convertTrowable(mLat.getText().toString())));
              } catch (Exception e) {
                mLat.setText("");
              }
            }
          }
        });

    mLon.setHint(mCf.getHint());
    mLon.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              try {
                mLon.setText(
                    mCf.convertLon(CoordFormatter.convertTrowable(mLon.getText().toString())));
              } catch (Exception e) {
                mLon.setText("");
              }
            }
          }
        });

    mSpinner = (Spinner) findViewById(R.id.spinnerCategory);
    Cursor c = mPoiManager.getGeoDatabase().getPoiCategoryListCursor();
    startManagingCursor(c);
    SimpleCursorAdapter adapter =
        new SimpleCursorAdapter(
            this,
            R.layout.poicategory_spinner, // android.R.layout.simple_spinner_item,
            c,
            new String[] {"name", "iconid"},
            new int[] {android.R.id.text1, R.id.pic});
    adapter.setDropDownViewResource(R.layout.poicategory_spinner_dropdown);
    mSpinner.setAdapter(adapter);

    Bundle extras = getIntent().getExtras();
    if (extras == null) extras = new Bundle();
    int id = extras.getInt("pointid", PoiPoint.EMPTY_ID());

    if (id < 0) {
      mPoiPoint = new PoiPoint();
      mTitle.setText(extras.getString("title"));
      mSpinner.setSelection(0);
      mLat.setText(mCf.convertLat(extras.getDouble("lat")));
      mLon.setText(mCf.convertLon(extras.getDouble("lon")));
      mAlt.setText(String.format(Locale.UK, "%.1f", extras.getDouble("alt", 0.0)));
      mDescr.setText(extras.getString("descr"));
      mHidden.setChecked(false);
    } else {
      mPoiPoint = mPoiManager.getPoiPoint(id);

      if (mPoiPoint == null) finish();

      mTitle.setText(mPoiPoint.Title);
      for (int pos = 0; pos < mSpinner.getCount(); pos++) {
        if (mSpinner.getItemIdAtPosition(pos) == mPoiPoint.CategoryId) {
          mSpinner.setSelection(pos);
          break;
        }
      }
      mLat.setText(mCf.convertLat(mPoiPoint.GeoPoint.getLatitude()));
      mLon.setText(mCf.convertLon(mPoiPoint.GeoPoint.getLongitude()));
      mAlt.setText(String.format(Locale.UK, "%.1f", mPoiPoint.Alt));
      mDescr.setText(mPoiPoint.Descr);
      mHidden.setChecked(mPoiPoint.Hidden);
    }

    ((Button) findViewById(R.id.saveButton))
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                doSaveAction();
              }
            });
    ((Button) findViewById(R.id.discardButton))
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                PoiActivity.this.finish();
              }
            });
  }