Showing
4 changed files
with
464 additions
and
43 deletions
| ... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' | ... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' |
| 2 | 2 | ||
| 3 | ext { | 3 | ext { |
| 4 | PUBLISH_GROUP_ID = 'ly.warp' | 4 | PUBLISH_GROUP_ID = 'ly.warp' |
| 5 | - PUBLISH_VERSION = '4.5.5.4r28' | 5 | + PUBLISH_VERSION = '4.5.5.4r29' |
| 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
| 7 | } | 7 | } |
| 8 | 8 | ... | ... |
| ... | @@ -5,6 +5,9 @@ import android.content.ActivityNotFoundException; | ... | @@ -5,6 +5,9 @@ import android.content.ActivityNotFoundException; |
| 5 | import android.content.Context; | 5 | import android.content.Context; |
| 6 | import android.content.Intent; | 6 | import android.content.Intent; |
| 7 | import android.content.pm.PackageManager; | 7 | import android.content.pm.PackageManager; |
| 8 | +import android.graphics.Bitmap; | ||
| 9 | +import android.graphics.Canvas; | ||
| 10 | +import android.graphics.drawable.Drawable; | ||
| 8 | import android.net.Uri; | 11 | import android.net.Uri; |
| 9 | import android.os.Bundle; | 12 | import android.os.Bundle; |
| 10 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
| ... | @@ -15,6 +18,7 @@ import android.widget.LinearLayout; | ... | @@ -15,6 +18,7 @@ import android.widget.LinearLayout; |
| 15 | import android.widget.TextView; | 18 | import android.widget.TextView; |
| 16 | 19 | ||
| 17 | import androidx.annotation.NonNull; | 20 | import androidx.annotation.NonNull; |
| 21 | +import androidx.annotation.Nullable; | ||
| 18 | import androidx.appcompat.app.AlertDialog; | 22 | import androidx.appcompat.app.AlertDialog; |
| 19 | import androidx.core.app.ActivityCompat; | 23 | import androidx.core.app.ActivityCompat; |
| 20 | import androidx.core.content.ContextCompat; | 24 | import androidx.core.content.ContextCompat; |
| ... | @@ -22,11 +26,14 @@ import androidx.fragment.app.FragmentActivity; | ... | @@ -22,11 +26,14 @@ import androidx.fragment.app.FragmentActivity; |
| 22 | 26 | ||
| 23 | import com.bumptech.glide.Glide; | 27 | import com.bumptech.glide.Glide; |
| 24 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 28 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| 29 | +import com.bumptech.glide.request.target.CustomTarget; | ||
| 30 | +import com.bumptech.glide.request.transition.Transition; | ||
| 25 | import com.google.android.gms.maps.CameraUpdate; | 31 | import com.google.android.gms.maps.CameraUpdate; |
| 26 | import com.google.android.gms.maps.CameraUpdateFactory; | 32 | import com.google.android.gms.maps.CameraUpdateFactory; |
| 27 | import com.google.android.gms.maps.GoogleMap; | 33 | import com.google.android.gms.maps.GoogleMap; |
| 28 | import com.google.android.gms.maps.OnMapReadyCallback; | 34 | import com.google.android.gms.maps.OnMapReadyCallback; |
| 29 | import com.google.android.gms.maps.SupportMapFragment; | 35 | import com.google.android.gms.maps.SupportMapFragment; |
| 36 | +import com.google.android.gms.maps.model.BitmapDescriptorFactory; | ||
| 30 | import com.google.android.gms.maps.model.LatLng; | 37 | import com.google.android.gms.maps.model.LatLng; |
| 31 | import com.google.android.gms.maps.model.Marker; | 38 | import com.google.android.gms.maps.model.Marker; |
| 32 | import com.google.android.gms.maps.model.MarkerOptions; | 39 | import com.google.android.gms.maps.model.MarkerOptions; |
| ... | @@ -312,21 +319,11 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -312,21 +319,11 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 312 | mMerchantList.clear(); | 319 | mMerchantList.clear(); |
| 313 | mMerchantList.addAll(result); | 320 | mMerchantList.addAll(result); |
| 314 | 321 | ||
| 315 | -// if (mClusterManager != null) { | ||
| 316 | -// mMap.clear(); | ||
| 317 | -// mClusterManager.clearItems(); | ||
| 318 | -// if (result != null) { | ||
| 319 | -// mClusterManager.addItems(result); | ||
| 320 | -// } | ||
| 321 | -// mClusterManager.cluster(); | ||
| 322 | -// } | ||
| 323 | - | ||
| 324 | int nonNullCoords = 0; | 322 | int nonNullCoords = 0; |
| 325 | for (Merchant merchCoords : result) { | 323 | for (Merchant merchCoords : result) { |
| 326 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { | 324 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { |
| 327 | nonNullCoords++; | 325 | nonNullCoords++; |
| 328 | } else { | 326 | } else { |
| 329 | -// mMerchantParent = merchCoords; | ||
| 330 | mMerchantParentList.add(merchCoords); | 327 | mMerchantParentList.add(merchCoords); |
| 331 | } | 328 | } |
| 332 | } | 329 | } |
| ... | @@ -337,12 +334,74 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -337,12 +334,74 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 337 | } | 334 | } |
| 338 | 335 | ||
| 339 | for (Merchant merch : result) { | 336 | for (Merchant merch : result) { |
| 337 | + if (!TextUtils.isEmpty(merch.getImgPreview())) { | ||
| 338 | + Glide.with(ShopsActivity.this) | ||
| 339 | + .asBitmap() | ||
| 340 | + .load(R.drawable.map_pin) | ||
| 341 | + .into(new CustomTarget<Bitmap>() { | ||
| 342 | + @Override | ||
| 343 | + public void onResourceReady(@NonNull Bitmap staticImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 344 | + Glide.with(ShopsActivity.this) | ||
| 345 | + .asBitmap() | ||
| 346 | + .load(merch.getImgPreview()) | ||
| 347 | + .into(new CustomTarget<Bitmap>() { | ||
| 348 | + @Override | ||
| 349 | + public void onResourceReady(@NonNull Bitmap poiImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 350 | + Bitmap combinedBitmap = overlayBitmaps(staticImage, poiImage, 48, 48, 0.2f); | ||
| 340 | mMap.addMarker(new MarkerOptions() | 351 | mMap.addMarker(new MarkerOptions() |
| 341 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | 352 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) |
| 353 | + .icon(BitmapDescriptorFactory.fromBitmap(combinedBitmap)) | ||
| 342 | .anchor(0.5f, 0.5f) | 354 | .anchor(0.5f, 0.5f) |
| 343 | .title(merch.getTitle()) | 355 | .title(merch.getTitle()) |
| 344 | .snippet(merch.getUuid())); | 356 | .snippet(merch.getUuid())); |
| 345 | } | 357 | } |
| 358 | + | ||
| 359 | + @Override | ||
| 360 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 361 | + mMap.addMarker(new MarkerOptions() | ||
| 362 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 363 | + .anchor(0.5f, 0.5f) | ||
| 364 | + .title(merch.getTitle()) | ||
| 365 | + .snippet(merch.getUuid())); | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + @Override | ||
| 369 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 370 | + mMap.addMarker(new MarkerOptions() | ||
| 371 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 372 | + .anchor(0.5f, 0.5f) | ||
| 373 | + .title(merch.getTitle()) | ||
| 374 | + .snippet(merch.getUuid())); | ||
| 375 | + } | ||
| 376 | + }); | ||
| 377 | + } | ||
| 378 | + | ||
| 379 | + @Override | ||
| 380 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 381 | + mMap.addMarker(new MarkerOptions() | ||
| 382 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 383 | + .anchor(0.5f, 0.5f) | ||
| 384 | + .title(merch.getTitle()) | ||
| 385 | + .snippet(merch.getUuid())); | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + @Override | ||
| 389 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 390 | + mMap.addMarker(new MarkerOptions() | ||
| 391 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 392 | + .anchor(0.5f, 0.5f) | ||
| 393 | + .title(merch.getTitle()) | ||
| 394 | + .snippet(merch.getUuid())); | ||
| 395 | + } | ||
| 396 | + }); | ||
| 397 | + } else { | ||
| 398 | + mMap.addMarker(new MarkerOptions() | ||
| 399 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 400 | + .anchor(0.5f, 0.5f) | ||
| 401 | + .title(merch.getTitle()) | ||
| 402 | + .snippet(merch.getUuid())); | ||
| 403 | + } | ||
| 404 | + } | ||
| 346 | } | 405 | } |
| 347 | 406 | ||
| 348 | @Override | 407 | @Override |
| ... | @@ -362,21 +421,11 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -362,21 +421,11 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 362 | mMerchantList.clear(); | 421 | mMerchantList.clear(); |
| 363 | mMerchantList.addAll(result); | 422 | mMerchantList.addAll(result); |
| 364 | 423 | ||
| 365 | - // if (mClusterManager != null) { | ||
| 366 | -// mMap.clear(); | ||
| 367 | -// mClusterManager.clearItems(); | ||
| 368 | -// if (result != null) { | ||
| 369 | -// mClusterManager.addItems(result); | ||
| 370 | -// } | ||
| 371 | -// mClusterManager.cluster(); | ||
| 372 | -// } | ||
| 373 | - | ||
| 374 | int nonNullCoords = 0; | 424 | int nonNullCoords = 0; |
| 375 | for (Merchant merchCoords : result) { | 425 | for (Merchant merchCoords : result) { |
| 376 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { | 426 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { |
| 377 | nonNullCoords++; | 427 | nonNullCoords++; |
| 378 | } else { | 428 | } else { |
| 379 | -// mMerchantParent = merchCoords; | ||
| 380 | mMerchantParentList.add(merchCoords); | 429 | mMerchantParentList.add(merchCoords); |
| 381 | } | 430 | } |
| 382 | } | 431 | } |
| ... | @@ -386,25 +435,147 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -386,25 +435,147 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 386 | return; | 435 | return; |
| 387 | } | 436 | } |
| 388 | 437 | ||
| 389 | -// if (mMerchantParent != null) { | ||
| 390 | if (mMerchantParentList != null && mMerchantParentList.size() > 0) { | 438 | if (mMerchantParentList != null && mMerchantParentList.size() > 0) { |
| 391 | for (Merchant parentMerch : mMerchantParentList) { | 439 | for (Merchant parentMerch : mMerchantParentList) { |
| 392 | for (Merchant merch : result) { | 440 | for (Merchant merch : result) { |
| 393 | if (parentMerch.getUuid().equals(merch.getParent())) { | 441 | if (parentMerch.getUuid().equals(merch.getParent())) { |
| 394 | merch.setImg_preview(parentMerch.getImgPreview()); | 442 | merch.setImg_preview(parentMerch.getImgPreview()); |
| 395 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { | 443 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { |
| 444 | + if (!TextUtils.isEmpty(merch.getImgPreview())) { | ||
| 445 | + Glide.with(ShopsActivity.this) | ||
| 446 | + .asBitmap() | ||
| 447 | + .load(R.drawable.map_pin) | ||
| 448 | + .into(new CustomTarget<Bitmap>() { | ||
| 449 | + @Override | ||
| 450 | + public void onResourceReady(@NonNull Bitmap staticImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 451 | + Glide.with(ShopsActivity.this) | ||
| 452 | + .asBitmap() | ||
| 453 | + .load(merch.getImgPreview()) | ||
| 454 | + .into(new CustomTarget<Bitmap>() { | ||
| 455 | + @Override | ||
| 456 | + public void onResourceReady(@NonNull Bitmap poiImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 457 | + Bitmap combinedBitmap = overlayBitmaps(staticImage, poiImage, 48, 48, 0.2f); | ||
| 396 | mMap.addMarker(new MarkerOptions() | 458 | mMap.addMarker(new MarkerOptions() |
| 397 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | 459 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) |
| 460 | + .icon(BitmapDescriptorFactory.fromBitmap(combinedBitmap)) | ||
| 398 | .anchor(0.5f, 0.5f) | 461 | .anchor(0.5f, 0.5f) |
| 399 | .title(merch.getTitle()) | 462 | .title(merch.getTitle()) |
| 400 | .snippet(merch.getUuid())); | 463 | .snippet(merch.getUuid())); |
| 401 | } | 464 | } |
| 465 | + | ||
| 466 | + @Override | ||
| 467 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 468 | + mMap.addMarker(new MarkerOptions() | ||
| 469 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 470 | + .anchor(0.5f, 0.5f) | ||
| 471 | + .title(merch.getTitle()) | ||
| 472 | + .snippet(merch.getUuid())); | ||
| 473 | + } | ||
| 474 | + | ||
| 475 | + @Override | ||
| 476 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 477 | + mMap.addMarker(new MarkerOptions() | ||
| 478 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 479 | + .anchor(0.5f, 0.5f) | ||
| 480 | + .title(merch.getTitle()) | ||
| 481 | + .snippet(merch.getUuid())); | ||
| 482 | + } | ||
| 483 | + }); | ||
| 484 | + } | ||
| 485 | + | ||
| 486 | + @Override | ||
| 487 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 488 | + mMap.addMarker(new MarkerOptions() | ||
| 489 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 490 | + .anchor(0.5f, 0.5f) | ||
| 491 | + .title(merch.getTitle()) | ||
| 492 | + .snippet(merch.getUuid())); | ||
| 493 | + } | ||
| 494 | + | ||
| 495 | + @Override | ||
| 496 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 497 | + mMap.addMarker(new MarkerOptions() | ||
| 498 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 499 | + .anchor(0.5f, 0.5f) | ||
| 500 | + .title(merch.getTitle()) | ||
| 501 | + .snippet(merch.getUuid())); | ||
| 502 | + } | ||
| 503 | + }); | ||
| 504 | + } else { | ||
| 505 | + mMap.addMarker(new MarkerOptions() | ||
| 506 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 507 | + .anchor(0.5f, 0.5f) | ||
| 508 | + .title(merch.getTitle()) | ||
| 509 | + .snippet(merch.getUuid())); | ||
| 510 | + } | ||
| 511 | + } | ||
| 402 | } | 512 | } |
| 403 | } | 513 | } |
| 404 | } | 514 | } |
| 405 | } else { | 515 | } else { |
| 406 | for (Merchant merch : result) { | 516 | for (Merchant merch : result) { |
| 407 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { | 517 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { |
| 518 | + if (!TextUtils.isEmpty(merch.getImgPreview())) { | ||
| 519 | + Glide.with(ShopsActivity.this) | ||
| 520 | + .asBitmap() | ||
| 521 | + .load(R.drawable.map_pin) | ||
| 522 | + .into(new CustomTarget<Bitmap>() { | ||
| 523 | + @Override | ||
| 524 | + public void onResourceReady(@NonNull Bitmap staticImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 525 | + Glide.with(ShopsActivity.this) | ||
| 526 | + .asBitmap() | ||
| 527 | + .load(merch.getImgPreview()) | ||
| 528 | + .into(new CustomTarget<Bitmap>() { | ||
| 529 | + @Override | ||
| 530 | + public void onResourceReady(@NonNull Bitmap poiImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 531 | + Bitmap combinedBitmap = overlayBitmaps(staticImage, poiImage, 48, 48, 0.2f); | ||
| 532 | + mMap.addMarker(new MarkerOptions() | ||
| 533 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 534 | + .icon(BitmapDescriptorFactory.fromBitmap(combinedBitmap)) | ||
| 535 | + .anchor(0.5f, 0.5f) | ||
| 536 | + .title(merch.getTitle()) | ||
| 537 | + .snippet(merch.getUuid())); | ||
| 538 | + } | ||
| 539 | + | ||
| 540 | + @Override | ||
| 541 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 542 | + mMap.addMarker(new MarkerOptions() | ||
| 543 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 544 | + .anchor(0.5f, 0.5f) | ||
| 545 | + .title(merch.getTitle()) | ||
| 546 | + .snippet(merch.getUuid())); | ||
| 547 | + } | ||
| 548 | + | ||
| 549 | + @Override | ||
| 550 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 551 | + mMap.addMarker(new MarkerOptions() | ||
| 552 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 553 | + .anchor(0.5f, 0.5f) | ||
| 554 | + .title(merch.getTitle()) | ||
| 555 | + .snippet(merch.getUuid())); | ||
| 556 | + } | ||
| 557 | + }); | ||
| 558 | + } | ||
| 559 | + | ||
| 560 | + @Override | ||
| 561 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 562 | + mMap.addMarker(new MarkerOptions() | ||
| 563 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 564 | + .anchor(0.5f, 0.5f) | ||
| 565 | + .title(merch.getTitle()) | ||
| 566 | + .snippet(merch.getUuid())); | ||
| 567 | + } | ||
| 568 | + | ||
| 569 | + @Override | ||
| 570 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 571 | + mMap.addMarker(new MarkerOptions() | ||
| 572 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 573 | + .anchor(0.5f, 0.5f) | ||
| 574 | + .title(merch.getTitle()) | ||
| 575 | + .snippet(merch.getUuid())); | ||
| 576 | + } | ||
| 577 | + }); | ||
| 578 | + } else { | ||
| 408 | mMap.addMarker(new MarkerOptions() | 579 | mMap.addMarker(new MarkerOptions() |
| 409 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | 580 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) |
| 410 | .anchor(0.5f, 0.5f) | 581 | .anchor(0.5f, 0.5f) |
| ... | @@ -414,6 +585,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -414,6 +585,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 414 | } | 585 | } |
| 415 | } | 586 | } |
| 416 | } | 587 | } |
| 588 | + } | ||
| 417 | 589 | ||
| 418 | @Override | 590 | @Override |
| 419 | public void onFailure(int errorCode) { | 591 | public void onFailure(int errorCode) { |
| ... | @@ -421,6 +593,37 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -421,6 +593,37 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 421 | } | 593 | } |
| 422 | }; | 594 | }; |
| 423 | 595 | ||
| 596 | + private Bitmap overlayBitmaps(Bitmap staticImage, Bitmap poiImage, int poiImageWidth, int poiImageHeight, float scale) { | ||
| 597 | + // Resize the POI image | ||
| 598 | + Bitmap resizedPoiImage; | ||
| 599 | + int poiImageWidthScale = 0; | ||
| 600 | + int poiImageHeightScale = 0; | ||
| 601 | + if (scale == 0) | ||
| 602 | + resizedPoiImage = Bitmap.createScaledBitmap(poiImage, poiImageWidth, poiImageHeight, false); | ||
| 603 | + else { | ||
| 604 | + // Calculate the new dimensions for the POI image | ||
| 605 | + poiImageWidthScale = (int) (poiImage.getWidth() * scale); | ||
| 606 | + poiImageHeightScale = (int) (poiImage.getHeight() * scale); | ||
| 607 | + resizedPoiImage = Bitmap.createScaledBitmap(poiImage, poiImageWidthScale, poiImageHeightScale, false); | ||
| 608 | + } | ||
| 609 | + | ||
| 610 | + // Create a new bitmap with the same size as the static image | ||
| 611 | + Bitmap combinedBitmap = Bitmap.createBitmap(staticImage.getWidth(), staticImage.getHeight(), staticImage.getConfig()); | ||
| 612 | + Canvas canvas = new Canvas(combinedBitmap); | ||
| 613 | + | ||
| 614 | + // Draw the static image on the canvas | ||
| 615 | + canvas.drawBitmap(staticImage, 0, 0, null); | ||
| 616 | + | ||
| 617 | + // Calculate the position to center the resized POI image on the static image | ||
| 618 | + int left = (staticImage.getWidth() - resizedPoiImage.getWidth()) / 2; | ||
| 619 | + int top = (staticImage.getHeight() - resizedPoiImage.getHeight()) / 3; | ||
| 620 | + | ||
| 621 | + // Draw the resized POI image on the canvas | ||
| 622 | + canvas.drawBitmap(resizedPoiImage, left, top, null); | ||
| 623 | + | ||
| 624 | + return combinedBitmap; | ||
| 625 | + } | ||
| 626 | + | ||
| 424 | // =========================================================== | 627 | // =========================================================== |
| 425 | // Inner and Anonymous Classes | 628 | // Inner and Anonymous Classes |
| 426 | // =========================================================== | 629 | // =========================================================== | ... | ... |
| ... | @@ -5,6 +5,9 @@ import android.content.ActivityNotFoundException; | ... | @@ -5,6 +5,9 @@ import android.content.ActivityNotFoundException; |
| 5 | import android.content.Context; | 5 | import android.content.Context; |
| 6 | import android.content.Intent; | 6 | import android.content.Intent; |
| 7 | import android.content.pm.PackageManager; | 7 | import android.content.pm.PackageManager; |
| 8 | +import android.graphics.Bitmap; | ||
| 9 | +import android.graphics.Canvas; | ||
| 10 | +import android.graphics.drawable.Drawable; | ||
| 8 | import android.net.Uri; | 11 | import android.net.Uri; |
| 9 | import android.os.Bundle; | 12 | import android.os.Bundle; |
| 10 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
| ... | @@ -15,6 +18,7 @@ import android.widget.LinearLayout; | ... | @@ -15,6 +18,7 @@ import android.widget.LinearLayout; |
| 15 | import android.widget.TextView; | 18 | import android.widget.TextView; |
| 16 | 19 | ||
| 17 | import androidx.annotation.NonNull; | 20 | import androidx.annotation.NonNull; |
| 21 | +import androidx.annotation.Nullable; | ||
| 18 | import androidx.appcompat.app.AlertDialog; | 22 | import androidx.appcompat.app.AlertDialog; |
| 19 | import androidx.core.app.ActivityCompat; | 23 | import androidx.core.app.ActivityCompat; |
| 20 | import androidx.core.content.ContextCompat; | 24 | import androidx.core.content.ContextCompat; |
| ... | @@ -22,6 +26,8 @@ import androidx.fragment.app.FragmentActivity; | ... | @@ -22,6 +26,8 @@ import androidx.fragment.app.FragmentActivity; |
| 22 | 26 | ||
| 23 | import com.bumptech.glide.Glide; | 27 | import com.bumptech.glide.Glide; |
| 24 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 28 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| 29 | +import com.bumptech.glide.request.target.CustomTarget; | ||
| 30 | +import com.bumptech.glide.request.transition.Transition; | ||
| 25 | import com.google.android.material.bottomsheet.BottomSheetDialog; | 31 | import com.google.android.material.bottomsheet.BottomSheetDialog; |
| 26 | import com.huawei.hms.maps.CameraUpdate; | 32 | import com.huawei.hms.maps.CameraUpdate; |
| 27 | import com.huawei.hms.maps.CameraUpdateFactory; | 33 | import com.huawei.hms.maps.CameraUpdateFactory; |
| ... | @@ -29,6 +35,7 @@ import com.huawei.hms.maps.HuaweiMap; | ... | @@ -29,6 +35,7 @@ import com.huawei.hms.maps.HuaweiMap; |
| 29 | import com.huawei.hms.maps.MapsInitializer; | 35 | import com.huawei.hms.maps.MapsInitializer; |
| 30 | import com.huawei.hms.maps.OnMapReadyCallback; | 36 | import com.huawei.hms.maps.OnMapReadyCallback; |
| 31 | import com.huawei.hms.maps.SupportMapFragment; | 37 | import com.huawei.hms.maps.SupportMapFragment; |
| 38 | +import com.huawei.hms.maps.model.BitmapDescriptorFactory; | ||
| 32 | import com.huawei.hms.maps.model.LatLng; | 39 | import com.huawei.hms.maps.model.LatLng; |
| 33 | import com.huawei.hms.maps.model.Marker; | 40 | import com.huawei.hms.maps.model.Marker; |
| 34 | import com.huawei.hms.maps.model.MarkerOptions; | 41 | import com.huawei.hms.maps.model.MarkerOptions; |
| ... | @@ -329,21 +336,11 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -329,21 +336,11 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 329 | mMerchantList.clear(); | 336 | mMerchantList.clear(); |
| 330 | mMerchantList.addAll(result); | 337 | mMerchantList.addAll(result); |
| 331 | 338 | ||
| 332 | -// if (mClusterManager != null) { | ||
| 333 | -// mMap.clear(); | ||
| 334 | -// mClusterManager.clearItems(); | ||
| 335 | -// if (result != null) { | ||
| 336 | -// mClusterManager.addItems(result); | ||
| 337 | -// } | ||
| 338 | -// mClusterManager.cluster(); | ||
| 339 | -// } | ||
| 340 | - | ||
| 341 | int nonNullCoords = 0; | 339 | int nonNullCoords = 0; |
| 342 | for (Merchant merchCoords : result) { | 340 | for (Merchant merchCoords : result) { |
| 343 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { | 341 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { |
| 344 | nonNullCoords++; | 342 | nonNullCoords++; |
| 345 | } else { | 343 | } else { |
| 346 | -// mMerchantParent = merchCoords; | ||
| 347 | mMerchantParentList.add(merchCoords); | 344 | mMerchantParentList.add(merchCoords); |
| 348 | } | 345 | } |
| 349 | } | 346 | } |
| ... | @@ -354,13 +351,80 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -354,13 +351,80 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 354 | } | 351 | } |
| 355 | 352 | ||
| 356 | for (Merchant merch : result) { | 353 | for (Merchant merch : result) { |
| 354 | + if (!TextUtils.isEmpty(merch.getImgPreview())) { | ||
| 355 | + Glide.with(ShopsHuaweiActivity.this) | ||
| 356 | + .asBitmap() | ||
| 357 | + .load(R.drawable.map_pin) | ||
| 358 | + .into(new CustomTarget<Bitmap>() { | ||
| 359 | + @Override | ||
| 360 | + public void onResourceReady(@NonNull Bitmap staticImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 361 | + Glide.with(ShopsHuaweiActivity.this) | ||
| 362 | + .asBitmap() | ||
| 363 | + .load(merch.getImgPreview()) | ||
| 364 | + .into(new CustomTarget<Bitmap>() { | ||
| 365 | + @Override | ||
| 366 | + public void onResourceReady(@NonNull Bitmap poiImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 367 | + Bitmap combinedBitmap = overlayBitmaps(staticImage, poiImage, 48, 48, 0.2f); | ||
| 357 | mMap.addMarker(new MarkerOptions() | 368 | mMap.addMarker(new MarkerOptions() |
| 358 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | 369 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) |
| 370 | + .icon(BitmapDescriptorFactory.fromBitmap(combinedBitmap)) | ||
| 359 | .anchor(0.5f, 0.5f) | 371 | .anchor(0.5f, 0.5f) |
| 360 | .title(merch.getTitle()) | 372 | .title(merch.getTitle()) |
| 361 | .snippet(merch.getUuid()) | 373 | .snippet(merch.getUuid()) |
| 362 | .clusterable(true)); | 374 | .clusterable(true)); |
| 363 | } | 375 | } |
| 376 | + | ||
| 377 | + @Override | ||
| 378 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 379 | + mMap.addMarker(new MarkerOptions() | ||
| 380 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 381 | + .anchor(0.5f, 0.5f) | ||
| 382 | + .title(merch.getTitle()) | ||
| 383 | + .snippet(merch.getUuid()) | ||
| 384 | + .clusterable(true)); | ||
| 385 | + } | ||
| 386 | + | ||
| 387 | + @Override | ||
| 388 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 389 | + mMap.addMarker(new MarkerOptions() | ||
| 390 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 391 | + .anchor(0.5f, 0.5f) | ||
| 392 | + .title(merch.getTitle()) | ||
| 393 | + .snippet(merch.getUuid()) | ||
| 394 | + .clusterable(true)); | ||
| 395 | + } | ||
| 396 | + }); | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + @Override | ||
| 400 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 401 | + mMap.addMarker(new MarkerOptions() | ||
| 402 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 403 | + .anchor(0.5f, 0.5f) | ||
| 404 | + .title(merch.getTitle()) | ||
| 405 | + .snippet(merch.getUuid()) | ||
| 406 | + .clusterable(true)); | ||
| 407 | + } | ||
| 408 | + | ||
| 409 | + @Override | ||
| 410 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 411 | + mMap.addMarker(new MarkerOptions() | ||
| 412 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 413 | + .anchor(0.5f, 0.5f) | ||
| 414 | + .title(merch.getTitle()) | ||
| 415 | + .snippet(merch.getUuid()) | ||
| 416 | + .clusterable(true)); | ||
| 417 | + } | ||
| 418 | + }); | ||
| 419 | + } else { | ||
| 420 | + mMap.addMarker(new MarkerOptions() | ||
| 421 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 422 | + .anchor(0.5f, 0.5f) | ||
| 423 | + .title(merch.getTitle()) | ||
| 424 | + .snippet(merch.getUuid()) | ||
| 425 | + .clusterable(true)); | ||
| 426 | + } | ||
| 427 | + } | ||
| 364 | } | 428 | } |
| 365 | 429 | ||
| 366 | @Override | 430 | @Override |
| ... | @@ -380,21 +444,11 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -380,21 +444,11 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 380 | mMerchantList.clear(); | 444 | mMerchantList.clear(); |
| 381 | mMerchantList.addAll(result); | 445 | mMerchantList.addAll(result); |
| 382 | 446 | ||
| 383 | - // if (mClusterManager != null) { | ||
| 384 | -// mMap.clear(); | ||
| 385 | -// mClusterManager.clearItems(); | ||
| 386 | -// if (result != null) { | ||
| 387 | -// mClusterManager.addItems(result); | ||
| 388 | -// } | ||
| 389 | -// mClusterManager.cluster(); | ||
| 390 | -// } | ||
| 391 | - | ||
| 392 | int nonNullCoords = 0; | 447 | int nonNullCoords = 0; |
| 393 | for (Merchant merchCoords : result) { | 448 | for (Merchant merchCoords : result) { |
| 394 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { | 449 | if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) { |
| 395 | nonNullCoords++; | 450 | nonNullCoords++; |
| 396 | } else { | 451 | } else { |
| 397 | -// mMerchantParent = merchCoords; | ||
| 398 | mMerchantParentList.add(merchCoords); | 452 | mMerchantParentList.add(merchCoords); |
| 399 | } | 453 | } |
| 400 | } | 454 | } |
| ... | @@ -404,13 +458,59 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -404,13 +458,59 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 404 | return; | 458 | return; |
| 405 | } | 459 | } |
| 406 | 460 | ||
| 407 | -// if (mMerchantParent != null) { | ||
| 408 | if (mMerchantParentList != null && mMerchantParentList.size() > 0) { | 461 | if (mMerchantParentList != null && mMerchantParentList.size() > 0) { |
| 409 | for (Merchant parentMerch : mMerchantParentList) { | 462 | for (Merchant parentMerch : mMerchantParentList) { |
| 410 | for (Merchant merch : result) { | 463 | for (Merchant merch : result) { |
| 411 | if (parentMerch.getUuid().equals(merch.getParent())) { | 464 | if (parentMerch.getUuid().equals(merch.getParent())) { |
| 412 | merch.setImg_preview(parentMerch.getImgPreview()); | 465 | merch.setImg_preview(parentMerch.getImgPreview()); |
| 413 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { | 466 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { |
| 467 | + if (!TextUtils.isEmpty(merch.getImgPreview())) { | ||
| 468 | + Glide.with(ShopsHuaweiActivity.this) | ||
| 469 | + .asBitmap() | ||
| 470 | + .load(R.drawable.map_pin) | ||
| 471 | + .into(new CustomTarget<Bitmap>() { | ||
| 472 | + @Override | ||
| 473 | + public void onResourceReady(@NonNull Bitmap staticImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 474 | + Glide.with(ShopsHuaweiActivity.this) | ||
| 475 | + .asBitmap() | ||
| 476 | + .load(merch.getImgPreview()) | ||
| 477 | + .into(new CustomTarget<Bitmap>() { | ||
| 478 | + @Override | ||
| 479 | + public void onResourceReady(@NonNull Bitmap poiImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 480 | + Bitmap combinedBitmap = overlayBitmaps(staticImage, poiImage, 48, 48, 0.2f); | ||
| 481 | + mMap.addMarker(new MarkerOptions() | ||
| 482 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 483 | + .icon(BitmapDescriptorFactory.fromBitmap(combinedBitmap)) | ||
| 484 | + .anchor(0.5f, 0.5f) | ||
| 485 | + .title(merch.getTitle()) | ||
| 486 | + .snippet(merch.getUuid()) | ||
| 487 | + .clusterable(true)); | ||
| 488 | + } | ||
| 489 | + | ||
| 490 | + @Override | ||
| 491 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 492 | + mMap.addMarker(new MarkerOptions() | ||
| 493 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 494 | + .anchor(0.5f, 0.5f) | ||
| 495 | + .title(merch.getTitle()) | ||
| 496 | + .snippet(merch.getUuid()) | ||
| 497 | + .clusterable(true)); | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + @Override | ||
| 501 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 502 | + mMap.addMarker(new MarkerOptions() | ||
| 503 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 504 | + .anchor(0.5f, 0.5f) | ||
| 505 | + .title(merch.getTitle()) | ||
| 506 | + .snippet(merch.getUuid()) | ||
| 507 | + .clusterable(true)); | ||
| 508 | + } | ||
| 509 | + }); | ||
| 510 | + } | ||
| 511 | + | ||
| 512 | + @Override | ||
| 513 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 414 | mMap.addMarker(new MarkerOptions() | 514 | mMap.addMarker(new MarkerOptions() |
| 415 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | 515 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) |
| 416 | .anchor(0.5f, 0.5f) | 516 | .anchor(0.5f, 0.5f) |
| ... | @@ -418,19 +518,106 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -418,19 +518,106 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 418 | .snippet(merch.getUuid()) | 518 | .snippet(merch.getUuid()) |
| 419 | .clusterable(true)); | 519 | .clusterable(true)); |
| 420 | } | 520 | } |
| 521 | + | ||
| 522 | + @Override | ||
| 523 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 524 | + mMap.addMarker(new MarkerOptions() | ||
| 525 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 526 | + .anchor(0.5f, 0.5f) | ||
| 527 | + .title(merch.getTitle()) | ||
| 528 | + .snippet(merch.getUuid()) | ||
| 529 | + .clusterable(true)); | ||
| 530 | + } | ||
| 531 | + }); | ||
| 532 | + } else { | ||
| 533 | + mMap.addMarker(new MarkerOptions() | ||
| 534 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 535 | + .anchor(0.5f, 0.5f) | ||
| 536 | + .title(merch.getTitle()) | ||
| 537 | + .snippet(merch.getUuid()) | ||
| 538 | + .clusterable(true)); | ||
| 539 | + } | ||
| 540 | + } | ||
| 421 | } | 541 | } |
| 422 | } | 542 | } |
| 423 | } | 543 | } |
| 424 | } else { | 544 | } else { |
| 425 | for (Merchant merch : result) { | 545 | for (Merchant merch : result) { |
| 426 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { | 546 | if (merch.getLatitude() != 0.0 && merch.getLongitude() != 0.0) { |
| 547 | + if (!TextUtils.isEmpty(merch.getImgPreview())) { | ||
| 548 | + Glide.with(ShopsHuaweiActivity.this) | ||
| 549 | + .asBitmap() | ||
| 550 | + .load(R.drawable.map_pin) | ||
| 551 | + .into(new CustomTarget<Bitmap>() { | ||
| 552 | + @Override | ||
| 553 | + public void onResourceReady(@NonNull Bitmap staticImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 554 | + Glide.with(ShopsHuaweiActivity.this) | ||
| 555 | + .asBitmap() | ||
| 556 | + .load(merch.getImgPreview()) | ||
| 557 | + .into(new CustomTarget<Bitmap>() { | ||
| 558 | + @Override | ||
| 559 | + public void onResourceReady(@NonNull Bitmap poiImage, @Nullable Transition<? super Bitmap> transition) { | ||
| 560 | + Bitmap combinedBitmap = overlayBitmaps(staticImage, poiImage, 48, 48, 0.2f); | ||
| 427 | mMap.addMarker(new MarkerOptions() | 561 | mMap.addMarker(new MarkerOptions() |
| 428 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | 562 | .position(new LatLng(merch.getLatitude(), merch.getLongitude())) |
| 563 | + .icon(BitmapDescriptorFactory.fromBitmap(combinedBitmap)) | ||
| 429 | .anchor(0.5f, 0.5f) | 564 | .anchor(0.5f, 0.5f) |
| 430 | .title(merch.getTitle()) | 565 | .title(merch.getTitle()) |
| 431 | .snippet(merch.getUuid()) | 566 | .snippet(merch.getUuid()) |
| 432 | .clusterable(true)); | 567 | .clusterable(true)); |
| 433 | } | 568 | } |
| 569 | + | ||
| 570 | + @Override | ||
| 571 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 572 | + mMap.addMarker(new MarkerOptions() | ||
| 573 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 574 | + .anchor(0.5f, 0.5f) | ||
| 575 | + .title(merch.getTitle()) | ||
| 576 | + .snippet(merch.getUuid()) | ||
| 577 | + .clusterable(true)); | ||
| 578 | + } | ||
| 579 | + | ||
| 580 | + @Override | ||
| 581 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 582 | + mMap.addMarker(new MarkerOptions() | ||
| 583 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 584 | + .anchor(0.5f, 0.5f) | ||
| 585 | + .title(merch.getTitle()) | ||
| 586 | + .snippet(merch.getUuid()) | ||
| 587 | + .clusterable(true)); | ||
| 588 | + } | ||
| 589 | + }); | ||
| 590 | + } | ||
| 591 | + | ||
| 592 | + @Override | ||
| 593 | + public void onLoadCleared(@Nullable Drawable placeholder) { | ||
| 594 | + mMap.addMarker(new MarkerOptions() | ||
| 595 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 596 | + .anchor(0.5f, 0.5f) | ||
| 597 | + .title(merch.getTitle()) | ||
| 598 | + .snippet(merch.getUuid()) | ||
| 599 | + .clusterable(true)); | ||
| 600 | + } | ||
| 601 | + | ||
| 602 | + @Override | ||
| 603 | + public void onLoadFailed(@Nullable Drawable errorDrawable) { | ||
| 604 | + mMap.addMarker(new MarkerOptions() | ||
| 605 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 606 | + .anchor(0.5f, 0.5f) | ||
| 607 | + .title(merch.getTitle()) | ||
| 608 | + .snippet(merch.getUuid()) | ||
| 609 | + .clusterable(true)); | ||
| 610 | + } | ||
| 611 | + }); | ||
| 612 | + } else { | ||
| 613 | + mMap.addMarker(new MarkerOptions() | ||
| 614 | + .position(new LatLng(merch.getLatitude(), merch.getLongitude())) | ||
| 615 | + .anchor(0.5f, 0.5f) | ||
| 616 | + .title(merch.getTitle()) | ||
| 617 | + .snippet(merch.getUuid()) | ||
| 618 | + .clusterable(true)); | ||
| 619 | + } | ||
| 620 | + } | ||
| 434 | } | 621 | } |
| 435 | } | 622 | } |
| 436 | } | 623 | } |
| ... | @@ -441,6 +628,37 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -441,6 +628,37 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 441 | } | 628 | } |
| 442 | }; | 629 | }; |
| 443 | 630 | ||
| 631 | + private Bitmap overlayBitmaps(Bitmap staticImage, Bitmap poiImage, int poiImageWidth, int poiImageHeight, float scale) { | ||
| 632 | + // Resize the POI image | ||
| 633 | + Bitmap resizedPoiImage; | ||
| 634 | + int poiImageWidthScale = 0; | ||
| 635 | + int poiImageHeightScale = 0; | ||
| 636 | + if (scale == 0) | ||
| 637 | + resizedPoiImage = Bitmap.createScaledBitmap(poiImage, poiImageWidth, poiImageHeight, false); | ||
| 638 | + else { | ||
| 639 | + // Calculate the new dimensions for the POI image | ||
| 640 | + poiImageWidthScale = (int) (poiImage.getWidth() * scale); | ||
| 641 | + poiImageHeightScale = (int) (poiImage.getHeight() * scale); | ||
| 642 | + resizedPoiImage = Bitmap.createScaledBitmap(poiImage, poiImageWidthScale, poiImageHeightScale, false); | ||
| 643 | + } | ||
| 644 | + | ||
| 645 | + // Create a new bitmap with the same size as the static image | ||
| 646 | + Bitmap combinedBitmap = Bitmap.createBitmap(staticImage.getWidth(), staticImage.getHeight(), staticImage.getConfig()); | ||
| 647 | + Canvas canvas = new Canvas(combinedBitmap); | ||
| 648 | + | ||
| 649 | + // Draw the static image on the canvas | ||
| 650 | + canvas.drawBitmap(staticImage, 0, 0, null); | ||
| 651 | + | ||
| 652 | + // Calculate the position to center the resized POI image on the static image | ||
| 653 | + int left = (staticImage.getWidth() - resizedPoiImage.getWidth()) / 2; | ||
| 654 | + int top = (staticImage.getHeight() - resizedPoiImage.getHeight()) / 3; | ||
| 655 | + | ||
| 656 | + // Draw the resized POI image on the canvas | ||
| 657 | + canvas.drawBitmap(resizedPoiImage, left, top, null); | ||
| 658 | + | ||
| 659 | + return combinedBitmap; | ||
| 660 | + } | ||
| 661 | + | ||
| 444 | // =========================================================== | 662 | // =========================================================== |
| 445 | // Inner and Anonymous Classes | 663 | // Inner and Anonymous Classes |
| 446 | // =========================================================== | 664 | // =========================================================== | ... | ... |
4.01 KB
-
Please register or login to post a comment