This file contains 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
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) { |
This file contains 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
/** | |
* 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) { |
This file contains 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
@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); |
This file contains 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
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 { |
This file contains 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
/** | |
* 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; |
This file contains 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
/** | |
* 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) { |
This file contains 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
private void dispatchTakePictureIntent() { | |
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
if (takePictureIntent.resolveActivity(getPackageManager()) != null) { | |
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); | |
} | |
} |
This file contains 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
@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)); | |
} | |
} |
This file contains 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
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); | |
} |
This file contains 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 VisionApiService { | |
@POST("?key=<THIS_IS_WERE_YOU_PUT_YOUR_VISION_API_KEY>") | |
Call<LogoResponse> checkImageLogo(@Body LogoBodyModel logoBodyModel); | |
} |
OlderNewer