diff --git a/app/src/main/java/com/example/nemophila/MapsFragment.java b/app/src/main/java/com/example/nemophila/MapsFragment.java index 9c8dd94..5e4a029 100644 --- a/app/src/main/java/com/example/nemophila/MapsFragment.java +++ b/app/src/main/java/com/example/nemophila/MapsFragment.java @@ -85,10 +85,10 @@ // LiveDataへの購読 shopsViewModel.getShopsLiveData().observe(getActivity(), shops -> { -// Toast.makeText(getActivity(), -// String.format("店確認しました"), -// Toast.LENGTH_SHORT) -// .show(); + Toast.makeText(getActivity(), + String.format("店確認しました"), + Toast.LENGTH_SHORT) + .show(); // // if(isLongClick == true) { // Toast.makeText(getActivity(), @@ -115,18 +115,32 @@ } }); + // LiveDataへの購読 + shopsViewModel.getNearShopsLiveData().observe(getActivity(), shops -> { + Toast.makeText(getActivity(), + String.format("店確認しました、ダイアログを表示します"), + Toast.LENGTH_SHORT) + .show(); + + //if(isLongClick == true) { + //長押し時は周辺のピンを全て取得し、ダイアログに表示する + DialogFragment dialogFragment = new MapsDialogFragment(shops); + dialogFragment.show(getActivity().getSupportFragmentManager(),"mapsdialog"); + + //} + }); + //初期画面の座標(現在地をロードするまで表示) //initialLatlng = new LatLng(39,138); initialLatlng = new LatLng(nemophila.getCameraLatitude(), nemophila.getCameraLongitude()); //初期画面に移動 - //mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(initialLatlng, 15f)); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(initialLatlng, nemophila.getZoom())); //画面が動いたとき mMap.setOnCameraIdleListener(() -> { //長押し状態を解除 - isLongClick = false; + //isLongClick = false; //カメラの座標とZOOM倍率を保存 //nowCamera = mMap.getCameraPosition(); nemophila.setCameraLatitude(mMap.getCameraPosition().target.latitude); @@ -167,8 +181,12 @@ // startActivity(intent); //長押しでダイアログを表示 - isLongClick = true; //長押ししたかどうかで動作を判定するため - shopsViewModel.setViewArea(longpushLocation.longitude+1, longpushLocation.latitude+1, longpushLocation.longitude-1, longpushLocation.latitude-1); + //isLongClick = true; //長押ししたかどうかで動作を判定するため + Toast.makeText(getActivity(), + String.format("長押しを受け取れてるよ"), + Toast.LENGTH_SHORT) + .show(); + shopsViewModel.longClickViewArea(longpushLocation.longitude+1, longpushLocation.latitude+1, longpushLocation.longitude-1, longpushLocation.latitude-1); //本番環境は↓の範囲で //shopsViewModel.setViewArea(longpushLocation.longitude+0.0007, longpushLocation.latitude+0.0007, longpushLocation.longitude-0.0007, longpushLocation.latitude-0.0007); });