diff --git a/app/src/main/java/com/example/nemophila/MapsActivity.java b/app/src/main/java/com/example/nemophila/MapsActivity.java index 1256256..9b05bb3 100644 --- a/app/src/main/java/com/example/nemophila/MapsActivity.java +++ b/app/src/main/java/com/example/nemophila/MapsActivity.java @@ -7,6 +7,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.DialogFragment; +import androidx.lifecycle.ViewModelProvider; import androidx.navigation.NavController; import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.ui.AppBarConfiguration; @@ -30,18 +31,24 @@ import android.widget.TextView; import android.widget.Toast; +import com.example.nemophila.entities.Shop; +import com.example.nemophila.viewmodels.ShopsViewModel; +import com.google.android.gms.maps.model.Marker; import com.google.android.material.navigation.NavigationView; import java.util.ArrayList; +import java.util.Collection; import java.util.List; public class MapsActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { Nemophila nemophila; + ShopsViewModel shopsViewModel; DialogFragment filterDialog; private Handler handler; + // フィルターのリスト用 ArrayList listData; ListView list; @@ -52,6 +59,7 @@ @Override protected void onCreate(Bundle savedInstanceState) { + shopsViewModel = new ViewModelProvider(this).get(ShopsViewModel.class); super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); @@ -284,6 +292,7 @@ if(isGenre) { //Toast.makeText(MapsActivity.this, listData.get(position).getText(), Toast.LENGTH_SHORT).show(); nemophila.setSelectGenres(listData.get(position).getText()); + } else { nemophila.setSelectFriends(listData.get(position).getText()); } @@ -291,12 +300,35 @@ if(isGenre) { //Toast.makeText(MapsActivity.this, listData.get(position).getText(), Toast.LENGTH_SHORT).show(); nemophila.removeSelectGenres(listData.get(position).getText()); + } else { nemophila.removeSelectFriends(listData.get(position).getText()); } } FilterDataModel data = getItem(position); data.isChecked = b; + Collection shops = shopsViewModel.getPreShoplist(); + + if ( shops != null ) { + System.out.println(shops); + + for (Shop shop : shops) { + if ( shopsViewModel.getMarker(shop) != null) { + //すでに立っているピンをフィルター掛け + Marker setMaker = shopsViewModel.getMarker(shop); + if (!nemophila.getSelectGenres().isEmpty()) { + setMaker.setVisible(false); + } else { + setMaker.setVisible(true); + + } +// if (!nemophila.getSelectFriends().isEmpty()) { +// setMaker.setVisible(false); +// } + + } + } + } } });