Exemplo n.º 1
0
 public Place getPlaceById(int placeId) {
   for (Place place : placeLists) {
     if (place.getPlaceId() == placeId) {
       return place;
     }
   }
   return null;
 }
Exemplo n.º 2
0
  public List<Place> getPlaceNearbyPlaceList(Place place, List<Place> placeList) {

    ComparatorDistance comparatorDistance =
        new ComparatorDistance(place.getLongitude(), place.getLatitude());
    Collections.sort(placeList, comparatorDistance);
    for (int i = 0; i < 10; i++) {
      nearbyPlaceList.add(placeList.get(i));
    }
    return nearbyPlaceList;
  }
 @Override
 public void onClick(View v) {
   int position = (Integer) v.getTag();
   Place nearbyPlace = nearbyPlaceList.get(position);
   Intent intent = new Intent();
   intent.putExtra(ConstantField.PLACE_DETAIL, nearbyPlace.toByteArray());
   Class activity = getClassByPlaceType(nearbyPlace.getCategoryId());
   intent.setClass(CommonPlaceDetailActivity.this, activity);
   startActivity(intent);
   activity = null;
 }
Exemplo n.º 4
0
  private void getPlaceDataByFile(String dataPath) {
    try {
      FileUtil fileUtil = new FileUtil();
      ArrayList<FileInputStream> fileInputStreams =
          fileUtil.getFileInputStreams(
              dataPath, ConstantField.PLACE_TAG, ConstantField.EXTENSION, true);
      for (FileInputStream fileInputStream : fileInputStreams) {
        placeList = PlaceList.parseFrom(fileInputStream);
        if (placeList != null) {
          for (Place place : placeList.getListList()) {
            switch (place.getCategoryId()) {
              case PlaceCategoryType.PLACE_SPOT_VALUE:
                spotList.add(place);
                break;
              case PlaceCategoryType.PLACE_HOTEL_VALUE:
                hotelList.add(place);
                break;
              case PlaceCategoryType.PLACE_ENTERTAINMENT_VALUE:
                entertrainList.add(place);
                break;
              case PlaceCategoryType.PLACE_SHOPPING_VALUE:
                shoppingList.add(place);
                break;
              case PlaceCategoryType.PLACE_RESTRAURANT_VALUE:
                restraurantList.add(place);
                break;
              default:
                break;
            }
          }
        }
      }

    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 @Override
 public void onClick(View v) {
   try {
     Class.forName("com.google.android.maps.MapActivity");
     openGPSSettings();
     Intent intent = new Intent();
     intent.putExtra(ConstantField.PLACE_DETAIL, place.toByteArray());
     intent.setClass(CommonPlaceDetailActivity.this, PlaceGoogleMap.class);
     startActivity(intent);
   } catch (Exception e) {
     (Toast.makeText(
             CommonPlaceDetailActivity.this,
             getString(R.string.google_map_not_found1),
             Toast.LENGTH_LONG))
         .show();
   }
 }
  private void init() {
    place = getPlaceById();
    if (place != null) {
      currentCityId = place.getCityId();
      nearbyPlaceList = new ArrayList<Place>();
      List<String> imagePath = place.getImagesList();
      LayoutInflater inflater = getLayoutInflater();
      ArrayList<View> imageViewlist = new ArrayList<View>();
      imageLoader = ImageLoader.getInstance();
      int size = imagePath.size();
      String url = "";
      View view = null;
      ImageView imageView = null;
      for (int i = 0; i < size; i++) {
        view = inflater.inflate(R.layout.place_detail_image, null);
        imageView = (ImageView) view.findViewById(R.id.place_image_item);
        url = imagePath.get(i);
        url = TravelUtil.getImageUrl(currentCityId, url);
        imageLoader.displayImage(url, imageView);
        imageViewlist.add(view);
      }
      imageViews = new ImageView[size];
      main = (ViewGroup) inflater.inflate(R.layout.common_place_detail, null);
      ViewGroup group = (ViewGroup) main.findViewById(R.id.place_images_group);
      ViewPager placeImage = (ViewPager) main.findViewById(R.id.place_images);
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(10, 10);
      params.setMargins(
          (int) getResources().getDimension(R.dimen.image_margin),
          0,
          (int) getResources().getDimension(R.dimen.image_margin),
          0);
      for (int i = 0; i < size; i++) {
        imageView = new ImageView(CommonPlaceDetailActivity.this);
        imageView.setLayoutParams(params);
        imageViews[i] = imageView;
        if (i == 0) {
          imageViews[i].setBackgroundResource(R.drawable.guide_dot_white);
        } else {
          imageViews[i].setBackgroundResource(R.drawable.guide_dot_black);
        }
        group.addView(imageView);
      }
      PlaceImageAdapter sceneryAdapter = new PlaceImageAdapter(imageViewlist);
      if (isSupportService()) {
        ViewGroup serviceGroup = (ViewGroup) main.findViewById(R.id.proServiceGroup);
        serviceGroup.setVisibility(View.VISIBLE);
        ImageView serviceImageView = null;
        LayoutParams layoutParams =
            new LayoutParams(
                (int) this.getResources().getDimension(R.dimen.service_icon2),
                LayoutParams.WRAP_CONTENT);
        for (int id : place.getProvidedServiceIdList()) {

          serviceImageView = new ImageView(CommonPlaceDetailActivity.this);
          serviceImageView.setLayoutParams(layoutParams);
          serviceImageView.setScaleType(ScaleType.FIT_CENTER);
          serviceImageView.setImageResource(TravelUtil.getServiceImage(id));
          serviceGroup.addView(serviceImageView);
        }
      }

      placeImage.setAdapter(sceneryAdapter);
      placeImage.setOnPageChangeListener(placeImageOnPageChangeListener);
      setContentView(main);

      if (isSupportSpecialTrafficStyle()) {
        main.findViewById(R.id.special_trans_group).setVisibility(View.VISIBLE);
        String trafficInfos = place.getTransportation();
        trafficInfos = trafficInfos.replaceAll(":;", "").trim();
        String[] traffic = trafficInfos.split(";");
        specialTrans = (ViewGroup) main.findViewById(R.id.special_trans);
        if (traffic.length > 0) {
          int i = 1;
          String[] trafficDetail = null;
          RelativeLayout.LayoutParams params1 =
              new RelativeLayout.LayoutParams(
                  (int) getResources().getDimension(R.dimen.special_traffic_loaction),
                  LayoutParams.WRAP_CONTENT);
          RelativeLayout.LayoutParams params2 =
              new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
          LayoutParams params3 =
              new LayoutParams(
                  (int) getResources().getDimension(R.dimen.transport_width),
                  (int) getResources().getDimension(R.dimen.transport_height));
          for (String trafficInfo : traffic) {
            row = new RelativeLayout(CommonPlaceDetailActivity.this);
            row.setLayoutParams(params3);
            if (i == traffic.length) {
              row.setBackgroundDrawable(getResources().getDrawable(R.drawable.table5_down));
            } else {
              row.setBackgroundDrawable(getResources().getDrawable(R.drawable.table5_center));
            }

            trafficDetail = trafficInfo.split(":");
            if (trafficDetail.length == 2) {
              locationTextView = new TextView(CommonPlaceDetailActivity.this);
              distanceTextView = new TextView(CommonPlaceDetailActivity.this);
              params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
              params1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
              params1.setMargins(
                  (int) getResources().getDimension(R.dimen.transport_margin_left), 0, 0, 0);
              params2.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
              params2.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
              params2.setMargins(
                  (int) getResources().getDimension(R.dimen.transport_margin_right), 0, 0, 0);
              locationTextView.setLayoutParams(params1);
              distanceTextView.setLayoutParams(params2);
              locationTextView.setTextColor(getResources().getColor(R.color.place_price_color));
              locationTextView.setTextSize(
                  getResources().getDimension(R.dimen.transport_text_size));
              locationTextView.setSingleLine(true);
              locationTextView.setMarqueeRepeatLimit(-1);
              locationTextView.setEllipsize(TruncateAt.MARQUEE);
              locationTextView.setHorizontallyScrolling(true);
              locationTextView.setSelected(true);
              distanceTextView.setTextColor(getResources().getColor(R.color.place_price_color));
              distanceTextView.setTextSize(
                  getResources().getDimension(R.dimen.transport_location_text_size));
              locationTextView.setText(trafficDetail[0]);
              distanceTextView.setText(trafficDetail[1]);
              row.addView(locationTextView);
              row.addView(distanceTextView);
              specialTrans.addView(row, i);
            }
            i++;
          }
        }

      } else {
        main.findViewById(R.id.transport_group).setVisibility(View.VISIBLE);
        TextView transport = (TextView) main.findViewById(R.id.transport);
        transport.setSelected(true);
        transport.setText(place.getTransportation());
      }

      // ticket
      if (isSupportTicket()) {
        String priceDescription = place.getPriceDescription();
        if (priceDescription != null && !priceDescription.equals("")) {
          findViewById(R.id.ticket_group).setVisibility(View.VISIBLE);
          TextView ticket = (TextView) findViewById(R.id.ticket);
          ticket.setText(priceDescription);
        }
      }

      // food
      if (isSupportFood()) {
        String footCate = AppManager.getInstance().getAllSubCatMap().get(place.getSubCategoryId());
        if (footCate != null && !footCate.equals("")) {
          findViewById(R.id.food_group).setVisibility(View.VISIBLE);
          TextView food = (TextView) findViewById(R.id.food);
          food.setText(footCate);
        }
      }

      // openTime
      if (isSupportOpenTime()) {
        String openTimeString = place.getOpenTime();
        if (openTimeString != null && !openTimeString.equals("")) {
          findViewById(R.id.open_time_group).setVisibility(View.VISIBLE);
          if (place.getCategoryId() != PlaceCategoryType.PLACE_SPOT_VALUE) {
            TextView openTimeTitle = (TextView) findViewById(R.id.open_time_title);
            openTimeTitle.setText(getString(R.string.open_time1));
          }

          TextView openTime = (TextView) findViewById(R.id.open_time);
          openTime.setText(openTimeString);
        }
      }

      // avgPrice
      if (isSupportAvgPrice()) {
        String avePriceString = place.getAvgPrice();
        if (avePriceString != null && !avePriceString.equals("")) {
          findViewById(R.id.avg_price_group).setVisibility(View.VISIBLE);
          TextView avgPrice = (TextView) findViewById(R.id.avg_price);
          HashMap<Integer, String> symbolHashMap = AppManager.getInstance().getSymbolMap();
          StringBuffer symbol = new StringBuffer();
          if (symbolHashMap.containsKey(currentCityId)) {
            String symbolStr = symbolHashMap.get(currentCityId);
            symbol.append(symbolStr);
          }
          avgPrice.setText(symbol + avePriceString);
        }
      }

      // specialFood
      if (isSupportSpecialFood()) {
        List<String> typcialDisList = place.getTypicalDishesList();
        if (typcialDisList != null && typcialDisList.size() > 0) {
          findViewById(R.id.special_food_group).setVisibility(View.VISIBLE);
          TextView specialFood = (TextView) findViewById(R.id.special_food);
          StringBuffer typicalDishes = new StringBuffer();
          for (String typcial : typcialDisList) {
            typicalDishes.append(typcial);
            typicalDishes.append("  ");
          }
          specialFood.setText(typicalDishes);
        }
      }

      // tips
      if (isSupportTips()) {
        String tipsString = place.getTips();
        if (tipsString != null && !tipsString.equals("")) {
          findViewById(R.id.tips_group).setVisibility(View.VISIBLE);
          TextView tipsTitles = (TextView) findViewById(R.id.tips_title);
          TextView tips = (TextView) findViewById(R.id.tips);
          tipsTitles.setText(tipsTitle);
          tips.setText(tipsString);
        }
      }

      // park
      if (isSupportPark()) {
        String parkGuideString = place.getParkingGuide();
        if (parkGuideString != null && !parkGuideString.equals("")) {
          findViewById(R.id.park_group).setVisibility(View.VISIBLE);
          TextView park = (TextView) findViewById(R.id.park);
          park.setText(place.getParkingGuide());
        }
      }

      // hotelStart
      if (isSupportHotelStart()) {
        int hotelStartLevel = place.getHotelStar();
        if (hotelStartLevel > 0) {
          findViewById(R.id.hotel_start_group).setVisibility(View.VISIBLE);
          TextView hotelStart = (TextView) findViewById(R.id.hotel_start);
          hotelStart.setText(TravelUtil.getHotelStar(this, hotelStartLevel));
          ViewGroup hotelStartImageGroup = (ViewGroup) findViewById(R.id.hotel_start_image);
          ImageView hotelStartImage;
          LayoutParams layoutParams =
              new LayoutParams(
                  (int) this.getResources().getDimension(R.dimen.hotel_start_icon),
                  LayoutParams.WRAP_CONTENT);
          for (int i = 0; i < place.getHotelStar(); i++) {

            hotelStartImage = new ImageView(CommonPlaceDetailActivity.this);
            hotelStartImage.setLayoutParams(layoutParams);
            hotelStartImage.setPadding(0, 0, 5, 0);
            hotelStartImage.setScaleType(ScaleType.FIT_CENTER);
            hotelStartImage.setImageResource(R.drawable.star_ico);
            hotelStartImageGroup.addView(hotelStartImage);
          }
        }
      }

      // keyword
      if (isSupportKeyWords()) {
        List<String> keyList = place.getKeywordsList();
        if (keyList != null && keyList.size() > 0) {
          findViewById(R.id.keyword_group).setVisibility(View.VISIBLE);
          TextView keyword = (TextView) findViewById(R.id.place_keyword);
          StringBuffer keywordStr = new StringBuffer();
          for (String key : keyList) {
            keywordStr.append(key);
            keywordStr.append("、");
          }
          if (keywordStr.length() > 1) {
            keyword.setText(keywordStr.substring(0, keywordStr.length() - 1));
          }
        }
      }

      // roomprice
      if (isSupportRoomPrice()) {
        String priceString = place.getPrice();
        if (priceString != null && !priceString.equals("")) {
          findViewById(R.id.room_price_group).setVisibility(View.VISIBLE);
          TextView roomPrice = (TextView) findViewById(R.id.room_price);
          HashMap<Integer, String> symbolHashMap = AppManager.getInstance().getSymbolMap();
          StringBuffer symbol = new StringBuffer();
          if (symbolHashMap.containsKey(currentCityId)) {
            String symbolStr = symbolHashMap.get(currentCityId);
            symbol.append(symbolStr);
          }
          symbol.append(priceString);
          symbol.append("起");
          roomPrice.setText(symbol);
        }
      }

      ImageView recommendImage1 = (ImageView) findViewById(R.id.place_detail_recommend_image1);
      ImageView recommendImage2 = (ImageView) findViewById(R.id.place_detail_recommend_image2);
      ImageView recommendImage3 = (ImageView) findViewById(R.id.place_detail_recommend_image3);

      TextView placeDetailTitle = (TextView) findViewById(R.id.place_detail_title);
      TextView placeIntroTitle = (TextView) findViewById(R.id.place_intro_title);
      TextView placeIntro = (TextView) findViewById(R.id.place_intro);
      placeDetailTitle.setText(place.getName());
      placeIntroTitle.setText(getPlaceIntroTitle());
      String introduction = place.getIntroduction();
      introduction = TravelUtil.handlerString(introduction);
      placeIntro.setText("		" + introduction);

      int rank = place.getRank();
      switch (rank) {
        case 1:
          {
            recommendImage1.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage2.setImageDrawable(this.getResources().getDrawable(R.drawable.good2));
            recommendImage3.setImageDrawable(this.getResources().getDrawable(R.drawable.good2));
          }
          break;
        case 2:
          {
            recommendImage1.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage2.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage3.setImageDrawable(this.getResources().getDrawable(R.drawable.good2));
          }
          break;
        case 3:
          {
            recommendImage1.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage2.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
            recommendImage3.setImageDrawable(this.getResources().getDrawable(R.drawable.good));
          }
          break;
        default:
          break;
      }

      if (place.getTelephoneList().size() > 0) {
        ViewGroup phoneGroup = (ViewGroup) findViewById(R.id.phone_group);
        phoneNum = (TextView) findViewById(R.id.phone_num);
        phoneNum.setSelected(true);
        ImageView phoneCall = (ImageView) findViewById(R.id.phone_call);
        phoneGroup.setVisibility(View.VISIBLE);
        StringBuffer phoneNumber = new StringBuffer();
        for (String telephone : place.getTelephoneList()) {
          phoneNumber.append(telephone);
          phoneNumber.append(" ");
        }
        phoneNum.setText(getString(R.string.phone_number) + " " + phoneNumber);
        phoneCall.setOnClickListener(phoneCallOnClickListener);
        phoneGroup.setOnClickListener(phoneCallOnClickListener);
      }

      if (place.getAddressList().size() > 0) {
        ViewGroup addressGroup = (ViewGroup) findViewById(R.id.address_group);
        TextView address = (TextView) findViewById(R.id.address);
        address.setSelected(true);
        ImageView addressMapView = (ImageView) findViewById(R.id.address_map_view);
        addressGroup.setVisibility(View.VISIBLE);
        StringBuffer addressStr = new StringBuffer();
        for (String addres : place.getAddressList()) {
          addressStr.append(addres);
          addressStr.append(" ");
        }
        address.setText(getString(R.string.address) + " " + addressStr);
        addressMapView.setOnClickListener(addressLocateOnClickListener);
        addressGroup.setOnClickListener(addressLocateOnClickListener);
      }

      if (place.getWebsite() != null && !place.getWebsite().equals("")) {
        ViewGroup websiteGroup = (ViewGroup) findViewById(R.id.website_group);
        websiteGroup.setVisibility(View.VISIBLE);
        TextView website = (TextView) findViewById(R.id.website);
        website.setText(place.getWebsite());
      }
      nearbyListGroup = (ViewGroup) findViewById(R.id.nearby_list_group);
      favoriteCount = (TextView) findViewById(R.id.favorite_count);
      collect = (TextView) findViewById(R.id.collect);
      collectBtn = (ImageView) findViewById(R.id.collect_btn);
      collectBtn.setOnClickListener(addFavoriteOnClickListener);
      ImageButton locationButton = (ImageButton) findViewById(R.id.location_button);
      Button indexButton = (Button) findViewById(R.id.index_button);
      indexButton.setOnClickListener(indexOnClickListener);
      ImageView help2Button = (ImageView) findViewById(R.id.help2);
      locationButton.setOnClickListener(locationOnClickListener);
      help2Button.setOnClickListener(helpOnClickListener);
    }
  }