Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
#2 added map
Browse files Browse the repository at this point in the history
  • Loading branch information
Malah committed Feb 5, 2019
1 parent cc4392d commit 81afe40
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 46 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/fr/istic/hbmlh/photoloc/MapsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import fr.istic.hbmlh.photoloc.adapter.MapItemAdapter;
import fr.istic.hbmlh.photoloc.model.PhotoLoc;
import fr.istic.hbmlh.photoloc.repository.PhotoLocRepository;
import fr.istic.hbmlh.photoloc.repository.impl.RepositoriesImpl;
Expand Down Expand Up @@ -44,6 +45,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setInfoWindowAdapter(new MapItemAdapter(this));
photoLocRepository.findAll().observe(this, photoLocs -> photoLocs.forEach(this::addMarker));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package fr.istic.hbmlh.photoloc.adapter;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Marker;
import com.squareup.picasso.Picasso;

public class MapItemAdapter implements GoogleMap.InfoWindowAdapter {

private ImageView imageView;

public MapItemAdapter(Context context) {
imageView = new ImageView(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(lp);
}

@Override
public View getInfoWindow(Marker marker) {
Picasso.get().load("file://" + marker.getTitle())
.resize(300, 300).centerCrop()
.into(imageView);
return imageView;
}

@Override
public View getInfoContents(Marker marker) {
return null;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.location.Location;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
Expand All @@ -16,7 +17,6 @@

import fr.istic.hbmlh.photoloc.exception.PhotoLocException;
import fr.istic.hbmlh.photoloc.model.PhotoLoc;
import fr.istic.hbmlh.photoloc.repository.AsyncRepository;
import fr.istic.hbmlh.photoloc.repository.PhotoLocRepository;
import fr.istic.hbmlh.photoloc.service.LocationService;
import fr.istic.hbmlh.photoloc.service.PhotoService;
Expand Down Expand Up @@ -76,7 +76,7 @@ public void saveLastPhoto() {
photoLoc.setLatitude(locToSet.getLatitude());
photoLoc.setLongitude(locToSet.getLongitude());
}
new AsyncRepository<Void>(() -> photoLocRepository.insert(photoLoc)).execute();
AsyncTask.execute(() -> photoLocRepository.insert(photoLoc));
lastPicturePath = null;
}
}

0 comments on commit 81afe40

Please sign in to comment.