Skip to content

Instantly share code, notes, and snippets.

View rwoloszyn's full-sized avatar

Rafal Woloszyn rwoloszyn

View GitHub Profile
@rwoloszyn
rwoloszyn / MapsActivity.java
Created April 9, 2017 15:45
Switch off UI in Google maps Android
//Done in a MapFragment
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
UiSettings mapUiSettings = mMap.getUiSettings();
mapUiSettings.setCompassEnabled(false);
mapUiSettings.setZoomControlsEnabled(false);
mapUiSettings.setMapToolbarEnabled(false);
}
@rwoloszyn
rwoloszyn / gzipsinkTest.java
Created April 7, 2017 12:57
Test Okio GzipSink
@Test
public void testGzipSource() throws IOException {
String original = "Some super super long string.Some super super long string." +
"Some super super long string." +
"Some super super long string." +
"Some super super long string." +
"Some super super long string." +
"Some super super long string." +
"Some super super long string." +
"Some super super long string.";
@rwoloszyn
rwoloszyn / MapControlsLayer.java
Created October 12, 2016 18:47
Reduce decimal points number for double value
DecimalFormat df = new DecimalFormat("#.####");
df.setRoundingMode(RoundingMode.CEILING);
double newLat = Double.valueOf(df.format(coordinates.latitude));
double newLong = Double.valueOf(df.format(coordinates.longitude));
@rwoloszyn
rwoloszyn / HashCardAdapter.java
Created August 23, 2016 19:02
Enum with integer value
public enum CardViewType {
SUBSCRIBED(1),
REJECTED(2),
NEW(3);
private int value;
private static Map<Integer, CardViewType> map = new HashMap<>();
CardViewType(int value) {
this.value = value;
@rwoloszyn
rwoloszyn / controllers.js
Created June 27, 2016 17:30
Place control in top of ZoomControl in Leaflet
map.zoomControl.removeFrom(map);
// create the control
var autoZoomCheckbox = L.control({position: 'topleft'});
autoZoomCheckbox.onAdd = function (map) {
var div = L.DomUtil.create('div', 'command');
div.innerHTML = '<form><input id="command" type="checkbox"/>Auto fit bounds</form>';
return div;
};
autoZoomCheckbox.addTo(map);
@rwoloszyn
rwoloszyn / controllers.js
Created June 27, 2016 17:19
Add custom control button to leafletmap
//Add center result control button
L.easyButton({
states: [{
stateName: 'zoom-to-forest',
icon: 'glyphicon glyphicon-screenshot',
title: 'Center map to heat results',
onClick: function(btn, map) {
if (typeof $scope.heatLayer != 'undefined'
&& typeof $scope.maxGlobalHeat != 'undefined') {
map.setView($scope.maxGlobalHeat, 10);
@rwoloszyn
rwoloszyn / controllers.js
Created May 31, 2016 13:52
Create unique list in JS with underscorelibrary
function addFailedTask(taskID){
if(taskID != null){
$scope.failedTaskList.push(taskID);
}
$scope.failedTaskList = _.uniq($scope.failedTaskList);
}
@rwoloszyn
rwoloszyn / leaflet-custom-markers.js
Created April 28, 2016 12:57
draw point in some distance betwen two geo points lat/lon
_calculateOffset: function(bearing_angle, radius){
//Calculate destination point based on bearing and distance
//http://www.movable-type.co.uk/scripts/latlong.html
var d2r = L.LatLng.DEG_TO_RAD; //simple convert do radians
var r2d= L.LatLng.RAD_TO_DEG; //simple convert to degrees
var radius = radius/1500;
var lat = this._latlng.lat * d2r;
var lng = this._latlng.lng * d2r;
var angle = bearing_angle * d2r;
var R = 6372.795477598;
@rwoloszyn
rwoloszyn / controllers.js
Created April 28, 2016 09:56
Remove item from array using underscore.js library
$scope.excludedTrips = _.reject($scope.excludedTrips, function(objArr){
return objArr.id == event.id;
});
@rwoloszyn
rwoloszyn / main_single_chart_card.xml
Created April 10, 2016 15:50
Align layouts on the left and right edeges
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/no_answer_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"