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
/** | |
* 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
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
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 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 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
<android.support.v7.widget.Toolbar | |
android:id="@+id/your_toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
app:popupTheme="@style/AppTheme.PopupOverlay" > | |
<ImageView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:id="@+id/your_icon" |
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 GoogleLocationApiManager implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, | |
ResultCallback<LocationSettingsResult>, LocationListener { | |
private static final String TAG = GoogleLocationApiManager.class.getSimpleName(); | |
private static final int LOCATION_REQUEST_INTERVAL = 10000; | |
private static final int LOCATION_REQUEST_FASTEST_INTERVAL = 5000; | |
private static final int LOCATION_REQUEST_PRIORITY = LocationRequest.PRIORITY_HIGH_ACCURACY; | |
private GoogleApiClient mGoogleApiClient; | |
private LocationSettingsRequest.Builder mLocationSettingsRequestBuilder; |
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
Display display = getWindowManager().getDefaultDisplay(); | |
View view = findViewById(R.id.YOUR_VIEW_ID); | |
view.measure(display.getWidth(), display.getHeight()); | |
view.getMeasuredWidth(); // view width | |
view.getMeasuredHeight(); //view height |
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 GeofenceCallback { | |
void onGeofenceResultAvailable(); | |
} |