Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Alejandro Zürcher zurche

👋
View GitHub Profile
View Point.java
package com.example.zurcher.mycoollib;
/**
* Representation of a Latitude/Longitude pair Point in the map.
*/
public class Point {
float mLatitude;
float mLongitude;
public Point(float latitude, float longitude) {
View LatLonDistanceCalculator.java
/**
* This helper is used to calculate the distance between two Latitude/Longitude points in kilometers.
*/
public class LatLonDistanceCalculator {
private static final int EARTH_RADIUS_IN_KILOMETERS = 6371;
public static float calculateDistance(Point pointA,
Point pointB) {
View MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Point buenosAiresObeliscoPoint =
new Point((float) -34.6037389, (float) -58.3815704);
Point nycStatueOfLibertyPoint =
new Point((float) 40.6892494, (float) -74.0445004);
@zurche
zurche / AppInstallerMainActivity.java
Created Nov 25, 2016
An app to install a list of apps.
View AppInstallerMainActivity.java
package com.example.zurcher.appinstaller;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
View CharsInParagraphCounter.java
/**
* Counts chars in each sentence of a given paragraph.
* Sentence end counts as '.', '!' or '?'.
*
* @return ArrayList of integers that correspond to the count of chars of each sentence in the
* paragraph.
*/
private String countCharsInSentences(String paragraph) {
ArrayList<Integer> charsBySentence = new ArrayList<>();
int currentCharCount = 0;
View LatLonDistanceCalculator.java
/**
* This helper is used to calculate the distance between two Latitude/Longitude points in kilometers.
*/
public class LatLonDistanceCalculator {
private static final int EARTH_RADIUS_IN_KILOMETERS = 6371;
public static float calculateDistance(Point pointA,
Point pointB) {
@zurche
zurche / takepicture.java
Created Feb 13, 2017
This is how you take a picture in android
View takepicture.java
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
@zurche
zurche / checkCameraResult.java
Created Feb 13, 2017
This is how you check the image taken by the camera
View checkCameraResult.java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
checkImageLogo(encodeImage(imageBitmap));
}
}
@zurche
zurche / encodeImageInBase64.java
Created Feb 13, 2017
This encodes a bitmap in base64
View encodeImageInBase64.java
private String encodeImage(Bitmap bitmap) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] byteArray = baos.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
}
View VisionAPIService.java
public interface VisionApiService {
@POST("?key=<THIS_IS_WERE_YOU_PUT_YOUR_VISION_API_KEY>")
Call<LogoResponse> checkImageLogo(@Body LogoBodyModel logoBodyModel);
}
You can’t perform that action at this time.