forked from gdgvilnius/MaistoBankas
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
585d87a
commit 9bda4b6
Showing
10 changed files
with
159 additions
and
6 deletions.
There are no files selected for viewing
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 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 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 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
25 changes: 25 additions & 0 deletions
25
app/src/main/java/lt/andro/maistobankas/MainApplication.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package lt.andro.maistobankas; | ||
|
||
import android.app.Application; | ||
|
||
import lt.andro.maistobankas.api.ItemInfoProviders; | ||
import lt.andro.maistobankas.api.MainService; | ||
import lt.andro.maistobankas.util.Utils; | ||
import retrofit.RestAdapter; | ||
import retrofit.converter.GsonConverter; | ||
|
||
/** | ||
* @since 2014-03-29 11:58 | ||
*/ | ||
public class MainApplication extends Application { | ||
public static MainService mainService; | ||
|
||
public MainApplication() { | ||
final RestAdapter restAdapter = new RestAdapter.Builder() | ||
.setEndpoint(ItemInfoProviders.getServicesEndpoint()) | ||
.setConverter(new GsonConverter(Utils.getGson())) | ||
.setLogLevel(RestAdapter.LogLevel.FULL).build(); | ||
|
||
mainService = restAdapter.create(MainService.class); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/lt/andro/maistobankas/api/ItemInfoProviders.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package lt.andro.maistobankas.api; | ||
|
||
/** | ||
* @since 2014-03-29 11:55 | ||
*/ | ||
public class ItemInfoProviders { | ||
private static final String SERVICES_ENDPOINT = "http://somedomain.com/";//TODO add real service endpoint | ||
|
||
public static String getServicesEndpoint() { | ||
return SERVICES_ENDPOINT; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/lt/andro/maistobankas/api/MainService.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package lt.andro.maistobankas.api; | ||
|
||
import lt.andro.maistobankas.api.entity.ItemInfoResponse; | ||
import retrofit.Callback; | ||
import retrofit.http.GET; | ||
import retrofit.http.Path; | ||
|
||
/** | ||
* @since 2014-03-29 11:34 | ||
*/ | ||
public interface MainService { | ||
|
||
@GET("/cards/by-gtin/{gtin}?format=json") | ||
void getItemInfo(@Path("gtin") String globalTradeItemNumber, Callback<ItemInfoResponse> callback); | ||
} |
55 changes: 55 additions & 0 deletions
55
app/src/main/java/lt/andro/maistobankas/api/entity/ItemInfoResponse.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package lt.andro.maistobankas.api.entity; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @since 2014-03-29 11:50 | ||
*/ | ||
public class ItemInfoResponse { | ||
|
||
String title; | ||
String amount; | ||
boolean isDiscount; | ||
double discount; | ||
double price; | ||
/** | ||
* Global Trade Item Number | ||
*/ | ||
String gtin; | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public String getAmount() { | ||
return amount; | ||
} | ||
|
||
public boolean isDiscount() { | ||
return isDiscount; | ||
} | ||
|
||
public double getDiscount() { | ||
return discount; | ||
} | ||
|
||
public double getPrice() { | ||
return price; | ||
} | ||
|
||
public String getGtin() { | ||
return gtin; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return com.google.common.base.Objects.toStringHelper(this) | ||
.add("title", title) | ||
.add("amount", amount) | ||
.add("isDiscount", isDiscount) | ||
.add("discount", discount) | ||
.add("price", price) | ||
.add("gtin", gtin) | ||
.toString(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package lt.andro.maistobankas.util; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
/** | ||
* @since 2014-03-29 12:23 | ||
*/ | ||
public class Utils { | ||
private static Gson gson; | ||
|
||
public static Gson getGson() { | ||
if (gson == null) { | ||
gson = new GsonBuilder().create(); | ||
} | ||
return gson; | ||
} | ||
} |
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