Skip to content

Commit be4ee04

Browse files
committed
rework
1 parent c1c6bb7 commit be4ee04

37 files changed

+1033
-0
lines changed

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
10+
# Built application files
11+
/*/build/
12+
13+
# Crashlytics configuations
14+
com_crashlytics_export_strings.xml
15+
16+
# Local configuration file (sdk path, etc)
17+
local.properties
18+
19+
# Gradle generated files
20+
.gradle/
21+
22+
# Signing files
23+
.signing/
24+
25+
# User-specific configurations
26+
.idea/libraries/
27+
.idea/workspace.xml
28+
.idea/tasks.xml
29+
.idea/.name
30+
.idea/compiler.xml
31+
.idea/copyright/profiles_settings.xml
32+
.idea/encodings.xml
33+
.idea/misc.xml
34+
.idea/modules.xml
35+
.idea/scopes/scope_settings.xml
36+
.idea/vcs.xml
37+
*.iml
38+
39+
# OS-specific files
40+
.DS_Store
41+
.DS_Store?
42+
._*
43+
.Spotlight-V100
44+
.Trashes
45+
ehthumbs.db
46+
Thumbs.db

.idea/gradle.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/app-release.apk

1.57 MB
Binary file not shown.

app/build.gradle

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion '25.0.0'
6+
7+
defaultConfig {
8+
applicationId "info.androidhive.retrofit"
9+
minSdkVersion 15
10+
targetSdkVersion 23
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
25+
// retrofit, gson
26+
//compile 'com.squareup.retrofit2:logging-interceptor:3.6.0'
27+
// recycler view
28+
compile 'com.android.support:appcompat-v7:23.3.0'
29+
compile 'com.google.code.gson:gson:2.6.2'
30+
compile 'com.squareup.retrofit2:retrofit:2.0.2'
31+
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
32+
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
33+
compile 'com.android.support:recyclerview-v7:23.3.0'
34+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
35+
compile 'com.android.support:design:23.4.0'
36+
testCompile 'junit:junit:4.12'
37+
compile 'com.android.support:cardview-v7:25.3.1'
38+
}

app/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/apple/Softwares/adt-bundle-mac-x86_64-20140702/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.rgb.pbtracker;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="info.androidhive.retrofit">
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme">
13+
<activity
14+
android:name=".activity.MainActivity"
15+
android:label="@string/app_name"
16+
android:theme="@style/AppTheme.NoActionBar">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package com.rgb.pbtracker.activity;
2+
3+
import android.content.Context;
4+
import android.location.Location;
5+
import android.location.LocationListener;
6+
import android.location.LocationManager;
7+
import android.os.Bundle;
8+
import android.support.design.widget.FloatingActionButton;
9+
import android.support.v7.app.AppCompatActivity;
10+
import android.support.v7.widget.LinearLayoutManager;
11+
import android.support.v7.widget.RecyclerView;
12+
import android.support.v7.widget.Toolbar;
13+
import android.util.Log;
14+
import android.view.View;
15+
import android.widget.TextView;
16+
import android.widget.Toast;
17+
18+
import com.rgb.pbtracker.adapter.CustomerAdapter;
19+
import com.rgb.pbtracker.model.Customer;
20+
import com.rgb.pbtracker.model.CustomerResponse;
21+
import com.rgb.pbtracker.rest.APIClient;
22+
import com.rgb.pbtracker.rest.APIInterface;
23+
24+
import java.util.List;
25+
26+
import info.androidhive.retrofit.R;
27+
28+
import retrofit2.Call;
29+
import retrofit2.Callback;
30+
import retrofit2.Response;
31+
32+
public class MainActivity extends AppCompatActivity implements LocationListener {
33+
34+
private static final String TAG = "MainActivity";
35+
private TextView locationText;
36+
private LocationManager locationManager;
37+
38+
@Override
39+
protected void onCreate(Bundle savedInstanceState) {
40+
super.onCreate(savedInstanceState);
41+
setContentView(R.layout.activity_main);
42+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
43+
setSupportActionBar(toolbar);
44+
45+
final APIInterface apiService =
46+
APIClient.getClient().create(APIInterface.class);
47+
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
48+
locationText = (TextView)findViewById(R.id.location);
49+
fab.setOnClickListener(new View.OnClickListener() {
50+
@Override
51+
public void onClick(final View view) {
52+
//Call<String> outbound = apiService.makeOutboundCalls();
53+
getLocation();
54+
// outbound.enqueue(new Callback<String>() {
55+
// @Override
56+
// public void onResponse(Call<String> call, Response<String> response) {
57+
// int statusCode = response.code();
58+
// Snackbar.make(view, "Calling Numbers.."+statusCode, Snackbar.LENGTH_LONG)
59+
// .setAction("Action", null).show();
60+
// }
61+
//
62+
// @Override
63+
// public void onFailure(Call<String> call, Throwable t) {
64+
// // Log error here since request failed
65+
// Log.e(TAG, t.toString());
66+
// Snackbar.make(view, t.toString(), Snackbar.LENGTH_LONG)
67+
// .setAction("Action", null).show();
68+
// }
69+
// });
70+
}
71+
});
72+
73+
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.movies_recycler_view);
74+
recyclerView.setLayoutManager(new LinearLayoutManager(this));
75+
76+
Call<CustomerResponse> call = apiService.getCustomerData();
77+
call.enqueue(new Callback<CustomerResponse>() {
78+
@Override
79+
public void onResponse(Call<CustomerResponse> call, Response<CustomerResponse> response) {
80+
int statusCode = response.code();
81+
List<Customer> customers = response.body().getCustomers();
82+
recyclerView.setAdapter(new CustomerAdapter(customers, R.layout.list_item_customer, getApplicationContext()));
83+
}
84+
85+
@Override
86+
public void onFailure(Call<CustomerResponse> call, Throwable t) {
87+
// Log error here since request failed
88+
Log.e(TAG, t.toString());
89+
}
90+
});
91+
}
92+
93+
void getLocation() {
94+
try {
95+
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
96+
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 5, this);
97+
}
98+
catch(SecurityException e) {
99+
e.printStackTrace();
100+
}
101+
}
102+
103+
@Override
104+
public void onLocationChanged(Location location) {
105+
locationText.setText("Current Location: " + location.getLatitude() + ", " + location.getLongitude());
106+
}
107+
108+
@Override
109+
public void onProviderDisabled(String provider) {
110+
Toast.makeText(MainActivity.this, "Please Enable GPS and Internet", Toast.LENGTH_SHORT).show();
111+
}
112+
113+
@Override
114+
public void onStatusChanged(String provider, int status, Bundle extras) {
115+
116+
}
117+
118+
@Override
119+
public void onProviderEnabled(String provider) {
120+
121+
}
122+
123+
}

0 commit comments

Comments
 (0)