diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 3099599..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -FirstTask \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 9a8b7e5..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index bd4202c..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index b3a73c6..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.8 - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 60b382f..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 9ed535e..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,2128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - - - - - - - - 1442476930625 - - - 1442477487105 - - - 1442478945285 - - - 1442498603483 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/FirstTask.iml b/FirstTask.iml deleted file mode 100644 index bbfbc26..0000000 --- a/FirstTask.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index c282a7b..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# FirstTaskYandexAPI -# f diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app/app.iml b/app/app.iml deleted file mode 100644 index 1647cff..0000000 --- a/app/app.iml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index d436f06..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" - - packagingOptions { - exclude 'META-INF/LICENSE' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/NOTICE' - exclude 'META-INF/NOTICE.txt' - } - - defaultConfig { - applicationId "com.example.yasina.firsttask" - minSdkVersion 17 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - - - - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.0.1' - - compile 'com.google.android.gms:play-services-location:6.5.87' - compile 'com.google.maps.android:android-maps-utils:0.4+' - compile 'com.google.android.gms:play-services-location:6.5.87' - compile 'com.squareup.okhttp:okhttp:2.5.0' - compile 'com.android.support:design:23.0.1' - - compile 'com.fasterxml.jackson.core:jackson-core:2.6.0' - compile 'com.fasterxml.jackson.core:jackson-databind:2.5.4' - compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.0' -} - diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 2cb25d9..0000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /home/yasina/Android/Sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/app/src/androidTest/java/com/example/yasina/firsttask/ApplicationTest.java b/app/src/androidTest/java/com/example/yasina/firsttask/ApplicationTest.java deleted file mode 100644 index cc28a4a..0000000 --- a/app/src/androidTest/java/com/example/yasina/firsttask/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.yasina.firsttask; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index 9e825a7..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/java/com/example/yasina/firsttask/MainActivity.java b/app/src/main/java/com/example/yasina/firsttask/MainActivity.java deleted file mode 100644 index c99a11f..0000000 --- a/app/src/main/java/com/example/yasina/firsttask/MainActivity.java +++ /dev/null @@ -1,233 +0,0 @@ -package com.example.yasina.firsttask; - -import android.app.Activity; -import android.app.Fragment; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentSender; -import android.location.Location; -import android.os.Bundle; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentManager; -import android.util.Log; - -import com.example.yasina.firsttask.model.Building; -import com.example.yasina.firsttask.server.ServerBuilder; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.android.gms.common.ConnectionResult; -import com.google.android.gms.common.GooglePlayServicesUtil; -import com.google.android.gms.common.api.GoogleApiClient; -import com.google.android.gms.location.LocationListener; -import com.google.android.gms.location.LocationRequest; -import com.google.android.gms.location.LocationServices; -import com.google.android.gms.maps.CameraUpdateFactory; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.OnMapReadyCallback; -import com.google.android.gms.maps.SupportMapFragment; -import com.google.android.gms.maps.model.LatLng; -import com.google.android.gms.maps.model.MarkerOptions; -import com.squareup.okhttp.Callback; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Created by yasina on 14.09.15. - */ -public class MainActivity extends FragmentActivity implements - GoogleApiClient.ConnectionCallbacks, - GoogleApiClient.OnConnectionFailedListener, - LocationListener, - OnMapReadyCallback{ - - private static final String TAG = "MainActivity"; - - private static final String KEY_IN_RESOLUTION = "is_in_resolution"; - protected static final int REQUEST_CODE_RESOLUTION = 1; - private GoogleApiClient mGoogleApiClient; - - private boolean mIsInResolution; - private GoogleMap map; - private Location userCurrentLocation; - private ArrayList mBuildingsListPos; - private ObjectMapper objectMapper = new ObjectMapper(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() - .findFragmentById(R.id.map); - mapFragment.getMapAsync(this); - - map = mapFragment.getMap(); - map.setMyLocationEnabled(true); - map.setMapType(GoogleMap.MAP_TYPE_TERRAIN); - - } - @Override - public void onMapReady(GoogleMap map) { - - - } - - - @Override - public void onLocationChanged(Location location){ - - userCurrentLocation = location; - Log.v(TAG, "Latitude: " + location.getLatitude() + - ", Longitude: " + location.getLongitude()); - - getNearestPlaces(location); - - } - private void getNearestPlaces(Location location){ - String url = ServerBuilder.getFullYandexURL(location, 10); - //String url ="https://geocode-maps.yandex.ru/1.x/?&geocode=37.611,55.758&result=5&format=json"; - Log.d(TAG,"url=" + url); - ServerBuilder.get(url, new ComplaintListCallback()); - } - - private class ComplaintListCallback implements Callback { - - @Override - public void onFailure(Request request, IOException e) { - Log.d(TAG, "on Failure = " + e.toString()); - } - - @Override - public void onResponse(Response response) throws IOException { - - String rs = response.body().string(); - Log.d(TAG, rs); - - // mBuildingsList = objectMapper.readValue(response.body().string(), new TypeReference>() { - //}); - mBuildingsListPos = new ArrayList(); - - - Pattern p = Pattern.compile("\"pos\": \".*\""); - Matcher m = p.matcher(rs); - - // if we find a match, get the group - if (m.find()) - { - for(int i=0; i < m.groupCount(); i++) { - - String pos = m.group(i); - - mBuildingsListPos.add(pos); - } - - } - - - for(int i=0; i < mBuildingsListPos.size(); i++) { - Log.d(TAG, mBuildingsListPos.get(i)); - } - - - } - } - - @Override - protected void onStart() { - super.onStart(); - if (mGoogleApiClient == null) { - mGoogleApiClient = new GoogleApiClient.Builder(this) - .addApi(LocationServices.API) - .addConnectionCallbacks(this) - .addOnConnectionFailedListener(this) - .build(); - } - mGoogleApiClient.connect(); - } - - @Override - protected void onStop() { - if (mGoogleApiClient != null) { - mGoogleApiClient.disconnect(); - } - super.onStop(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putBoolean(KEY_IN_RESOLUTION, mIsInResolution); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - switch (requestCode) { - case REQUEST_CODE_RESOLUTION: - retryConnecting(); - break; - } - } - - private void retryConnecting() { - mIsInResolution = false; - if (!mGoogleApiClient.isConnecting()) { - mGoogleApiClient.connect(); - } - } - - @Override - public void onConnected(Bundle connectionHint) { - Log.i(TAG, "GoogleApiClient connected"); - - LocationRequest locationRequest = LocationRequest.create(); - locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); - locationRequest.setInterval(TimeUnit.SECONDS.toMillis(2)); - locationRequest.setFastestInterval(TimeUnit.SECONDS.toMillis(2)); - locationRequest.setSmallestDisplacement(2); - LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this); - } - - @Override - public void onConnectionSuspended(int cause) { - Log.i(TAG, "GoogleApiClient connection suspended"); - retryConnecting(); - } - - @Override - public void onConnectionFailed(ConnectionResult result) { - Log.i(TAG, "GoogleApiClient connection failed: " + result.toString()); - if (!result.hasResolution()) { - GooglePlayServicesUtil.getErrorDialog( - result.getErrorCode(), this, 0, new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - retryConnecting(); - } - }).show(); - return; - } - - if (mIsInResolution) { - return; - } - mIsInResolution = true; - try { - result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION); - } catch (IntentSender.SendIntentException e) { - Log.e(TAG, "Exception while starting resolution activity", e); - retryConnecting(); - } - } - - -} \ No newline at end of file diff --git a/app/src/main/java/com/example/yasina/firsttask/model/Building.java b/app/src/main/java/com/example/yasina/firsttask/model/Building.java deleted file mode 100644 index 8da75de..0000000 --- a/app/src/main/java/com/example/yasina/firsttask/model/Building.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.example.yasina.firsttask.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Created by yasina on 15.09.15. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class Building implements Parcelable{ - - @JsonProperty("Point") - private Point p; - - public Building(){} - - public String getP() { - return p.getPos(); - } - - public void setP(Point p) { - this.p = p; - } - - protected Building(Parcel in) { - p = in.readParcelable(Point.class.getClassLoader()); - } - - public static final Creator CREATOR = new Creator() { - @Override - public Building createFromParcel(Parcel in) { - return new Building(in); - } - - @Override - public Building[] newArray(int size) { - return new Building[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeParcelable(p, flags); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - private static class Point implements Parcelable{ - - @JsonProperty("pos") - String pos; - - public Point(Parcel in) { - pos = in.readString(); - } - - public String getPos() { - return pos; - } - - public void setPos(String pos) { - this.pos = pos; - } - - public static final Creator CREATOR = new Creator() { - @Override - public Point createFromParcel(Parcel in) { - return new Point(in); - } - - @Override - public Point[] newArray(int size) { - return new Point[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(pos); - } - } - - -} diff --git a/app/src/main/java/com/example/yasina/firsttask/server/ServerBuilder.java b/app/src/main/java/com/example/yasina/firsttask/server/ServerBuilder.java deleted file mode 100644 index c49eb81..0000000 --- a/app/src/main/java/com/example/yasina/firsttask/server/ServerBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.example.yasina.firsttask.server; - -import android.location.Location; - -import com.squareup.okhttp.Callback; -import com.squareup.okhttp.MediaType; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.RequestBody; -import com.squareup.okhttp.Response; - -import java.io.IOException; - -/** - * Created by yasina on 14.09.2015. - */ -public class ServerBuilder { - - public static final OkHttpClient client = new OkHttpClient(); - public static final MediaType mediaType_json = MediaType.parse("application/json; charset=utf-8"); - - private static final String yandexURL = "https://geocode-maps.yandex.ru/1.x"; - - public static void get(String url, Callback callback){ - Request request = new Request.Builder() - .header("Host", "geocode-maps.yandex.ru") - .addHeader("Cookie","yandexuid=2570136721424282212") - .url(url) - .build(); - client.newCall(request).enqueue(callback); - } - - public static String getFullYandexURL(Location myLocation, int result){ - return yandexURL + "/?geocode=" + myLocation.getLongitude() + "," + - myLocation.getLatitude() + "&format=json" + "&result=" + result - + "&kind=house"; - } - - -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 70fc32d..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml deleted file mode 100644 index b1cb908..0000000 --- a/app/src/main/res/menu/menu_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index cde69bc..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c133a0c..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index bfa42f0..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 324e72c..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml deleted file mode 100644 index 63fc816..0000000 --- a/app/src/main/res/values-w820dp/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 64dp - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 47c8224..0000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 16dp - 16dp - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index ceaebad..0000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - FirstTask - - Hello world! - Settings - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml deleted file mode 100644 index 766569d..0000000 --- a/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - -