示例#1
0
  private void goToMyLocation() {

    LogManager.d("mapView height" + mapView.getMeasuredHeight());
    View parent = (View) mapView.getParent();
    LogManager.d("mapView height" + parent.getMeasuredHeight());

    if (mCurrentLocation == null) {

      LogManager.d("找不到当前位置");

      map_view_enable.setVisibility(View.VISIBLE);
      mapView.setVisibility(View.GONE);
      searchButton.setEnabled(false);
      // setMapCenter(mDefaultCurrentLocation);
    } else {
      searchButton.setEnabled(true);
      map_view_enable.setVisibility(View.GONE);
      mapView.setVisibility(View.VISIBLE);
      int getLatitude = (int) (mCurrentLocation.getLatitude() * 1e6);
      int getLongitude = (int) (mCurrentLocation.getLongitude() * 1e6);

      GeoPoint geoPoint = null;
      if (debugChinaDevice) {
        int latitude = (int) (44.648837 * 1e6);
        int longitude = (int) (10.920087000000001 * 1e6);
        geoPoint = new GeoPoint(latitude, longitude);
      } else {
        geoPoint = new GeoPoint(getLatitude, getLongitude);
      }
      setMapCenter(geoPoint);
    }
  }
示例#2
0
  /**
   * @param publicModel
   * @param aggregatedAccountType 使用{AggregatedAccountType 这个类}
   * @return
   */
  public static String synchChartReportProtocal(
      RequestPublicModel publicModel, int aggregatedAccountType, String lastUpdate) {
    String result = null;
    try {
      JSONObject jsonObj = new JSONObject();
      JSONObject synchChartObj = new JSONObject();
      synchChartObj.put("bankName", publicModel.getBankName());
      synchChartObj.put("channel", publicModel.getChannel());
      synchChartObj.put("customerCode", publicModel.getCustomerCode());
      synchChartObj.put("enterpriseId", publicModel.getEnterpriseId());
      synchChartObj.put("serviceType", ServiceType.SYNCHCHART);
      synchChartObj.put("userAgent", publicModel.getUserAgent());
      synchChartObj.put("sessionId", publicModel.getSessionId());
      synchChartObj.put("token", publicModel.getToken());
      if (lastUpdate != null || !lastUpdate.equals("")) {
        synchChartObj.put("lastUpdate", lastUpdate);
      }
      synchChartObj.put("aggregatedAccountType", aggregatedAccountType);

      jsonObj.put("SynchChartRequest", synchChartObj);
      result = jsonObj.toString();
    } catch (Exception e) {
      LogManager.e("synchChartReportProtocal is error" + e.getLocalizedMessage());
    }
    return result;
  }
  /**
   * @param accountCode
   * @param publicModel
   * @param amount
   * @param purposeDescription
   * @param destCardCode
   * @param cardNumber
   * @param title
   * @param name
   * @return
   */
  public static String CheckRechargeCardReportProtocal(
      String accountCode,
      RequestPublicModel publicModel,
      double amount,
      String purposeDescription,
      String destCardCode,
      String cardNumber,
      String title,
      String name,
      String currency) {
    String result = null;
    try {
      JSONObject jsonObj = new JSONObject();
      JSONObject checkRechargeCardObj = new JSONObject();
      checkRechargeCardObj.put("serviceType", ServiceType.checkRechargeCard);
      checkRechargeCardObj.put("bankName", publicModel.getBankName());
      checkRechargeCardObj.put("enterpriseId", publicModel.getEnterpriseId());
      checkRechargeCardObj.put("customerCode", publicModel.getCustomerCode());
      checkRechargeCardObj.put("channel", publicModel.getChannel());
      checkRechargeCardObj.put("userAgent", publicModel.getUserAgent());
      checkRechargeCardObj.put("sessionId", publicModel.getSessionId());
      checkRechargeCardObj.put("token", publicModel.getToken());
      checkRechargeCardObj.put("amount", amount);
      checkRechargeCardObj.put("purposeDescription", purposeDescription);
      checkRechargeCardObj.put("destCardCode", destCardCode);
      checkRechargeCardObj.put("cardNumber", cardNumber);
      checkRechargeCardObj.put("title", title);
      checkRechargeCardObj.put("name", name);
      checkRechargeCardObj.put("accountCode", accountCode);
      checkRechargeCardObj.put("currency", currency);
      if (App.isNewPaymentsUpdate) {
        checkRechargeCardObj.put("transferCheck", true);
      }

      jsonObj.put("CheckRechargeCardRequest", checkRechargeCardObj);
      result = jsonObj.toString();
    } catch (Exception e) {
      LogManager.e("CheckRechargeCardReportProtocal is error" + e.getLocalizedMessage());
    }
    return result;
  }
  /**
   * @param json
   * @return
   */
  public static CheckRechargeCardResponseModel ParseCheckRechargeCardResponse(String json) {
    CheckRechargeCardResponseModel checkRechargeCardResponse = new CheckRechargeCardResponseModel();
    if (json == null) {
      return null;
    }

    try {
      JSONObject jsonObj = new JSONObject(json);
      JSONObject checkRechargeCardUpObj = jsonObj.getJSONObject("CheckRechargeCardResponse");

      checkRechargeCardResponse.responsePublicModel.setResultCode(
          checkRechargeCardUpObj.getInt("resultCode"));
      checkRechargeCardResponse.responsePublicModel.setResultDescription(
          checkRechargeCardUpObj.optString("resultDescription"));
      if (checkRechargeCardResponse.responsePublicModel.getResultCode() != 0) {
        JSONObject eventManagementObj = checkRechargeCardUpObj.getJSONObject("eventManagement");
        checkRechargeCardResponse.responsePublicModel.eventManagement.setErrorCode(
            eventManagementObj.optString("errorCode"));
        checkRechargeCardResponse.responsePublicModel.eventManagement.setErrorDescription(
            eventManagementObj.optString("errorDescription"));
        return checkRechargeCardResponse;
      }
      checkRechargeCardResponse.responsePublicModel.setTransactionId(
          checkRechargeCardUpObj.optString("transactionId"));

      if (App.isNewPaymentsUpdate) {
        checkRechargeCardResponse.setTransferId(checkRechargeCardUpObj.optString("transferId"));
      }
      checkRechargeCardResponse.setCharges(checkRechargeCardUpObj.optDouble("charges"));
      checkRechargeCardResponse.setExecutionDate(checkRechargeCardUpObj.optString("executionDate"));
      checkRechargeCardResponse.setSrcbankName(checkRechargeCardUpObj.optString("srcbankName"));
      checkRechargeCardResponse.setSrcBranchName(checkRechargeCardUpObj.optString("srcBranchName"));

    } catch (Exception e) {
      LogManager.e("ParseCheckRechargeCardResponse is error" + e.getLocalizedMessage());
    }
    return checkRechargeCardResponse;
  }
示例#5
0
  @Override
  protected void onAttachedToWindow() {
    LogManager.d("onattach");

    super.onAttachedToWindow();
    Location cache = getCachedLocation();
    if (isBetterLocation(cache, mCurrentLocation)) {
      setCurrentLocation(cache);
    }

    // Check status of GPS and NETWORK
    boolean gpsProviderFlag = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    boolean networkProviderFlag =
        locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if ((!gpsProviderFlag || !networkProviderFlag) && mFirstShow) {
      Log.d("Location", "No location provider is enabled");
      mFirstShow = false;
      buildAlertMessageNoLocationService();
    } else {
      if (gpsProviderFlag) {
        locationManager.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 10000, 0, mLocationListener1);
      }
      if (networkProviderFlag) {
        locationManager.requestLocationUpdates(
            LocationManager.NETWORK_PROVIDER, 10000, 0, mLocationListener2);
      }

      addCurrentLocationOverlay();
      // (int)(37 * 1000000), (int)(111.37 * 1000000)
      // for direction test
      // addBank(geoBeijing);
      mMapShowingForLocationUpdate = true;
      mapView.invalidate();
      Handler handler = new Handler();

      Runnable myRunnable =
          new Runnable() {
            public void run() {
              locationManager.removeUpdates(mLocationListener1);
              locationManager.removeUpdates(mLocationListener2);
            }
          };

      handler.postDelayed(myRunnable, 300000);

      httpSearchHandler =
          new Handler() {
            @Override
            public void handleMessage(Message msg) {
              if (HttpConnectionUtil.SUCCESS == msg.what) {
                String response = (String) msg.getData().get("response");
                Log.d("map", "response : " + response);
                GeocodeResult geocodeResult = new GeocodeResult();
                geocodeResult.setValues(response);

                mapCon.setZoom(defaultZoom);
                mapCon.setCenter(geocodeResult.getGeoPoint());

              } else {
                Toast.makeText(getContext(), "error", Toast.LENGTH_LONG).show();
              }
            }
          };
    }
    goToMyLocation();
  }
示例#6
0
  public void init() {

    LogManager.d("init");

    geoBeijing = new GeoPoint((int) (39.932 * 1000000), (int) (116.461 * 1000000));
    mDefaultCurrentLocation =
        new GeoPoint((int) (41.892910 * 1000000), (int) (12.48251990 * 1000000));

    mapView = (MapView) findViewById(R.id.map_view);
    map_view_enable = findViewById(R.id.map_view_enable);
    mapView.getLayoutParams().height = BaseActivity.screen_height * 1 / 2;
    map_view_enable.getLayoutParams().height = BaseActivity.screen_height * 1 / 2;
    mapView.setOnTouchListener(this);
    mapView.setSaveEnabled(true);
    mapView.setBuiltInZoomControls(false);

    mapCon = mapView.getController();
    mapCon.setZoom(defaultZoom);

    // geo = new Geocoder(getContext(), Locale.CHINA);
    mapCon.setCenter(mDefaultCurrentLocation);
    mapView.setTraffic(false);
    mapView.setSatellite(false);

    mPopView = (ViewGroup) mapActivity.getLayoutInflater().inflate(R.layout.map_popover, null);

    // MapActivity mapActivity = (MapActivity)getContext();
    // WindowManager windowManager = mapActivity.getWindowManager();
    // int width = windowManager.getDefaultDisplay().getWidth();

    mapView.addView(
        mPopView,
        new MapView.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT,
            null,
            MapView.LayoutParams.TOP_LEFT));
    mPopView.setVisibility(View.GONE);
    overlays = mapView.getOverlays();

    Drawable currentLocationMarker =
        this.getContext().getResources().getDrawable(R.drawable.user_location);
    mCurrentLocationOverlay = new MapItemizedOverlay(currentLocationMarker, this);
    mCurrentLocationOverlay.showPop = false;
    Drawable search = this.getContext().getResources().getDrawable(R.drawable.pin);

    bankOverlay = new MapItemizedOverlay(search, this);

    overlays.add(mCurrentLocationOverlay);
    overlays.add(bankOverlay);

    locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);

    mLocationListener1 =
        new LocationListener() {
          public void onLocationChanged(Location location) {
            Log.e(
                "Location",
                "GPSListener  "
                    + "latitude:"
                    + Double.toString(location.getLatitude())
                    + " longtitude:"
                    + Double.toString(location.getLongitude())
                    + " from:"
                    + location.getProvider());
            if (isBetterLocation(location, mCurrentLocation)) {
              setCurrentLocation(location);
              if (mMapShowingForLocationUpdate) {
                addCurrentLocationOverlay();
              }
            }
          }

          public void onStatusChanged(String provider, int status, Bundle extras) {}

          public void onProviderEnabled(String provider) {}

          public void onProviderDisabled(String provider) {}
        };

    mLocationListener2 =
        new LocationListener() {
          private boolean mFirstLaunch;

          public void onLocationChanged(Location location) {
            Log.e(
                "Location",
                "NetworkListener  "
                    + "latitude:"
                    + Double.toString(location.getLatitude())
                    + " longtitude:"
                    + Double.toString(location.getLongitude())
                    + " from:"
                    + location.getProvider());
            if (isBetterLocation(location, mCurrentLocation)) {
              setCurrentLocation(location);
              if (mMapShowingForLocationUpdate) {
                addCurrentLocationOverlay();
              }
            }
            if (mFirstLaunch == true) {
              mFirstLaunch = false;
              locationManager.removeUpdates(mLocationListener2);
            }
          }

          public void onStatusChanged(String provider, int status, Bundle extras) {}

          public void onProviderEnabled(String provider) {}

          public void onProviderDisabled(String provider) {}
        };
    myLocation = (ImageButton) findViewById(R.id.my_location);
    mapLayer = (ImageButton) findViewById(R.id.map_layer);
    showItems = (ImageButton) findViewById(R.id.show_items);
    searchButton = (ImageButton) findViewById(R.id.search_btn);
    searchEdt = (EditText) findViewById(R.id.search_input);
    distance_input = (EditText) findViewById(R.id.distance_input);
    if (App.app.initValue) {

      searchEdt.setText("05387");

      searchEdt.setText("via del tintoretto,200,roma");
    }

    searchButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // BaseMapActivity baseactivity = (BaseMapActivity)getContext();
            // baseactivity.hideKeyboard(searchButton);
            KeyBoardUtils.hideSoftInputFromWindow(mapActivity, searchEdt.getWindowToken());
            ProgressOverlay progressOverlay = new ProgressOverlay(getContext());
            progressOverlay.show(
                "searching...",
                new OnProgressEvent() {

                  @Override
                  public void onProgress() {

                    // Locale locale =
                    // getResources().getConfiguration().locale;

                    final String keyText = searchEdt.getText().toString();
                    searchGeoPoint = searchLocation(keyText);
                    if (searchGeoPoint != null) {
                      searchBarch(keyText);
                    }
                  }
                });
          }
        });

    mapLayer.setOnClickListener(
        new OnClickListener() {

          int i;

          @Override
          public void onClick(View v) {

            i++;
            int value = i % 2;
            switch (value) {
              case 0:
                mapView.setTraffic(false);
                mapView.setSatellite(false);
                break;
              case 1:
                mapView.setTraffic(false);
                mapView.setSatellite(true);

                break;
            }
          }
        });
    showItems.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (enter_distance_layout.getVisibility() == View.VISIBLE) {
              enter_distance_layout.setVisibility(View.GONE);
            } else {

              enter_distance_layout.setVisibility(View.VISIBLE);
            }
          }
        });
    myLocation.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            goToMyLocation();
          }
        });
    handler = new Handler();
    enter_distance_layout = (ViewGroup) findViewById(R.id.enter_distance_layout);
  }
示例#7
0
  public static SynchChartModel parseSynchChartResponse(String json) {

    SynchChartModel synchChartModel = new SynchChartModel();
    List<AggregatedAccount> aggregatedAccountsList = new ArrayList<AggregatedAccount>();
    if (json == null) {
      LogManager.d("parseSynchChartResponse" + "json null!");
      return null;
    }

    try {
      JSONObject jsonObj = new JSONObject(json);
      JSONObject synchChartObj = jsonObj.getJSONObject("SynchChartResponse");

      synchChartModel.responsePublicModel.setResultCode(synchChartObj.getInt("resultCode"));
      synchChartModel.responsePublicModel.setResultDescription(
          synchChartObj.optString("resultDescription"));
      if (synchChartModel.responsePublicModel.getResultCode() != 0) {
        JSONObject eventManagementObj = synchChartObj.getJSONObject("eventManagement");
        synchChartModel.responsePublicModel.eventManagement.setErrorCode(
            eventManagementObj.optString("errorCode"));
        synchChartModel.responsePublicModel.eventManagement.setErrorDescription(
            eventManagementObj.optString("errorDescription"));
        return synchChartModel;
      }

      synchChartModel.responsePublicModel.setTransactionId(
          synchChartObj.optString("transactionId"));
      JSONArray aggregatedAccountsArray = synchChartObj.optJSONArray("aggregatedAccounts");
      for (int i = 0; i < aggregatedAccountsArray.length(); i++) {
        AggregatedAccount aggregatedAccount = new AggregatedAccount();
        aggregatedAccount.setAccountCode(
            aggregatedAccountsArray.getJSONObject(i).optString("accountCode"));
        aggregatedAccount.setAggregatedAccountType(
            aggregatedAccountsArray.getJSONObject(i).optString("aggregatedAccountType"));
        aggregatedAccount.setAvailableBalance(
            aggregatedAccountsArray.getJSONObject(i).optDouble("availableBalance"));
        aggregatedAccount.setBankServiceCode(
            aggregatedAccountsArray.getJSONObject(i).optString("bankServiceCode"));
        aggregatedAccount.setTotalAmount(
            aggregatedAccountsArray.getJSONObject(i).optDouble("totalAmount"));
        JSONArray synchChartArray = aggregatedAccountsArray.getJSONObject(i).optJSONArray("charts");

        List<ChartModel> chartsList = new ArrayList<ChartModel>();
        for (int j = 0; j < synchChartArray.length(); j++) {
          ChartModel chartModel = new ChartModel();
          chartModel.setDate(synchChartArray.getJSONObject(j).optString("date"));
          chartModel.setInvestmentId(synchChartArray.getJSONObject(j).optInt("investmentId"));
          chartModel.setValue(synchChartArray.getJSONObject(j).optDouble("value"));
          chartsList.add(chartModel);
        }
        aggregatedAccount.setCharts(chartsList);
        aggregatedAccountsList.add(aggregatedAccount);

        add(aggregatedAccount);
      }
      synchChartModel.setAggregatedAccountsList(aggregatedAccountsList);
    } catch (Exception e) {
      LogManager.e("parseSynchChartResponse is error" + e.getLocalizedMessage());
    }

    return synchChartModel;
  }