This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MapsPresenterImpl implements MapsPresenter, LocationCallback, GeofenceCallback { | |
private static final String TAG = MapsPresenterImpl.class.getSimpleName(); | |
private MapsView view; | |
private GoogleLocationApiManager googleLocationApiManager; | |
private GeofencingManager geofencingManager; | |
private List<CompanyLocation> companyLocationList = new ArrayList<>(); | |
public MapsPresenterImpl(MapsView view, FragmentActivity fragmentActivity, Context context) { | |
if(view == null) throw new NullPointerException("view can not be NULL"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface MapsPresenter { | |
void connectToLocationService(); | |
void disconnectFromLocationService(); | |
void fetchCompanyLocations(); | |
void onMapReady(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface MapsView { | |
void generateMap(); | |
void updateLocationOnMap(Location location); | |
void showGeofences(List<CompanyLocation> companyLocationList); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, MapsView { | |
private GoogleMap mMap; | |
private MapsPresenter presenter; | |
private Marker currentPosition; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_maps); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Just a dummy container class in order to | |
* collect {@link com.google.android.gms.location.Geofence} | |
* and {@link com.google.android.gms.maps.model.LatLng} in one entity | |
*/ | |
public class CompanyLocation { | |
private LatLng coordinates; | |
private Geofence geofence; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final AlertDialog dialog = new AlertDialog.Builder(context) | |
.setView(v) | |
.setTitle(R.string.my_title) | |
.setPositiveButton(android.R.string.ok, null) //Set to null. We override the onclick | |
.setNegativeButton(android.R.string.cancel, null) | |
.create(); | |
dialog.setOnShowListener(new DialogInterface.OnShowListener() { | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Color; | |
import android.location.Location; | |
import android.os.Bundle; | |
import android.support.v4.app.FragmentActivity; | |
import com.google.android.gms.maps.CameraUpdateFactory; | |
import com.google.android.gms.maps.GoogleMap; | |
import com.google.android.gms.maps.OnMapReadyCallback; | |
import com.google.android.gms.maps.SupportMapFragment; | |
import com.google.android.gms.maps.model.BitmapDescriptorFactory; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.android.gms.location.Geofence; | |
import com.google.android.gms.maps.model.LatLng; | |
/** | |
* Just a dummy container class in order to | |
* collect {@link com.google.android.gms.location.Geofence} | |
* and {@link com.google.android.gms.maps.model.LatLng} in one entity | |
*/ | |
public class CompanyLocation { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
productFlavors { | |
newYorkTimes { | |
... | |
} | |
theGuardian { | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
productFlavors { | |
newYorkTimes { | |
applicationId "com.nyt.rss" | |
buildConfigField 'String', 'HOST', '"http://nytimes.com"' | |
} | |
theGuardian { | |
applicationId "com.theguardian.rss" | |
buildConfigField 'String', 'HOST', '"http://theguardian.com"' |