Skip to content

Instantly share code, notes, and snippets.

View dambroz's full-sized avatar

Denis dambroz

View GitHub Profile
@dambroz
dambroz / Add_Existing_Project_To_Git.md
Last active January 24, 2019 14:53 — forked from alexpchin/Add_Existing_Project_To_Git.md
Add Existing Project To Git Repo

#Adding an existing project to GitHub using the command line

Simple steps to add existing project to Github.

1. Create a new repository on GitHub.

In Terminal, change the current working directory to your local project.

##2. Initialize the local directory as a Git repository.

git init
private boolean isOnline() {
try {
int timeoutMs = 1500;
Socket sock = new Socket();
SocketAddress sockaddr = new InetSocketAddress("8.8.8.8", 53);
sock.connect(sockaddr, timeoutMs);
sock.close();
return true;
@dambroz
dambroz / CoordinateConverter
Created June 7, 2018 14:28
Convert wgs to webmercator
public class CoordinateConverter {
private static final double ANGULAR_UNIT = 0.017453292519943295;
private static final double RADIUS = 6378137.0;
public static Coordinate coordinateToWebMercator(double lat, double lon) {
if (Math.abs(lon) > 180 || Math.abs(lat) > 90) {
return new Coordinate(lon, lat);
}
public class CustomExceptionHandler implements UncaughtExceptionHandler {
private File logsFolder;
private Context mContext;
private Logger mLogger = LoggerFactory.getLogger(CustomExceptionHandler.class);
public CustomExceptionHandler(File logsFolder, Context context) {
this.logsFolder = logsFolder;
this.mContext = context;
}
@Override
mDownloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request req = new DownloadManager.Request(uri);
req.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
lastDownload = mDownloadManager.enqueue(req);
String urlEndPart = "&barriers=&polylineBarriers=&polygonBarriers=&outSR=4326&ignoreInvalidLocations=true&accumulateAttributeNames=&impedanceAttributeName=Длина&restrictionAttributeNames=&attributeParameterValues=&restrictUTurns=esriNFSBAllowBacktrack&useHierarchy=false&returnDirections=true&returnRoutes=true&returnStops=false&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&directionsLanguage=en-US&directionsStyleName=NA+Desktop&outputLines=esriNAOutputLineTrueShape&findBestSequence=false&preserveFirstStop=true&preserveLastStop=true&useTimeWindows=false&startTime=&outputGeometryPrecision=&outputGeometryPrecisionUnits=esriUnknownUnits&directionsTimeAttributeName=&directionsLengthUnits=esriNAUMiles&f=pjson";
String fullUrl = gitRoute;
if (fullUrl == null || fullUrl.isEmpty()) {
fullUrl = arcgisRouteUrl;
}
if (wmtsLayerUrl == null) {
fullUrl = arcgisRouteUrl + "/solve?stops="
+ String.format(Locale.ENGLISH, "%f,%f;%f,%f", carPosition._longitude._degrees,
ca
// Строим
String jsonResponse = new String(arg2);
Gson gson = new Gson();
RoutePath routePath = gson.fromJson(jsonResponse, RoutePath.class);
Routes route = routePath.getRoutes();
Polyline polyline = getPolylineForRoutes(route);
if (polyline.getPathCount() > 0 && polyline.getPathSize(0) > 0) {
Graphic graphic = new Graphic(polyline, new SimpleLineSymbol(Color.MAGENTA, 4));
routeGraphicLayer.addGraphic(graphic);
isRouteBuild.set(true);
if (Build.VERSION.SDK_INT >= 23) {
// Doze Mode
am.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, time, pending);
} else if (Build.VERSION.SDK_INT >= 19) {
am.setExact(AlarmManager.RTC_WAKEUP, time, pending);
} else {
am.set(AlarmManager.RTC_WAKEUP, time, pending);
}
@SuppressLint("NewApi")
private void startAlarmManagerForDataReceiveLoop(PendingIntent pendingIntent, long triggerAtMillis) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + triggerAtMillis, pendingIntent);
} else {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + triggerAtMillis, pendingIntent);
}
public interface IApp {
@NonNull
FileConfig getFileConfig();
}
public class CustomApplication extends MultiDexApplication implements IApp {
private FileConfig fileConfig = new FileConfig();
}
@Override