Skip to content

Commit

Permalink
Add slider images close #33
Browse files Browse the repository at this point in the history
Fix potential bug
Change color for the loading toast
  • Loading branch information
Scot SCRIVEN authored and Scot SCRIVEN committed Apr 18, 2016
1 parent 16cb61b commit f4e96c1
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 30 deletions.
Binary file modified app/app-release.apk
Binary file not shown.
11 changes: 11 additions & 0 deletions app/app.iml
Expand Up @@ -85,13 +85,17 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v13/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/commons/0.8.5.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/core/0.8.5.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.chrisbanes.photoview/library/1.2.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.satyan/sugar/1.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.hkm.loyalslider/library/1.8.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.koushikdutta.async/androidasync/2.1.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.koushikdutta.ion/ion/2.1.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/jp.wasabeef/glide-transformations/2.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.dm7.barcodescanner/core/1.8.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.dm7.barcodescanner/zxing/1.8.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.zhanghai.android.materialprogressbar/library/1.1.5/jars" />
Expand All @@ -117,15 +121,21 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="commons-beanutils-1.9.2" level="project" />
<orderEntry type="library" exported="" name="jsoup-1.8.3" level="project" />
<orderEntry type="library" exported="" name="picasso-2.5.2" level="project" />
<orderEntry type="library" exported="" name="load-toast-1.0.10" level="project" />
<orderEntry type="library" exported="" name="sugar-1.5" level="project" />
<orderEntry type="library" exported="" name="gpuimage-library-1.3.0" level="project" />
<orderEntry type="library" exported="" name="jackson-annotations-2.7.3" level="project" />
<orderEntry type="library" exported="" name="core-3.2.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.2.1" level="project" />
<orderEntry type="library" exported="" name="library-1.8.3" level="project" />
<orderEntry type="library" exported="" name="core-1.8.4" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.3.0" level="project" />
<orderEntry type="library" exported="" name="library-1.2.4" level="project" />
<orderEntry type="library" exported="" name="library-1.1.5" level="project" />
<orderEntry type="library" exported="" name="httpclient-4.3.6" level="project" />
<orderEntry type="library" exported="" name="glide-transformations-2.0.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.7.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.3.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.3.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.3.0" level="project" />
Expand All @@ -138,6 +148,7 @@
<orderEntry type="library" exported="" name="jackson-databind-2.7.3" level="project" />
<orderEntry type="library" exported="" name="commons-collections-3.2.2" level="project" />
<orderEntry type="library" exported="" name="commons-0.8.5.7" level="project" />
<orderEntry type="library" exported="" name="support-v13-23.3.0" level="project" />
<orderEntry type="library" exported="" name="commons-validator-1.5.0" level="project" />
<orderEntry type="library" exported="" name="androidasync-2.1.7" level="project" />
<orderEntry type="library" exported="" name="ion-2.1.7" level="project" />
Expand Down
6 changes: 4 additions & 2 deletions app/build.gradle
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "openfoodfacts.github.scrachx.openfood"
minSdkVersion 15
targetSdkVersion 21
versionCode 8
versionName "0.1.7"
versionCode 9
versionName "0.1.8"
}

useLibrary 'org.apache.http.legacy'
Expand Down Expand Up @@ -60,6 +60,8 @@ dependencies {

compile 'com.koushikdutta.ion:ion:2.+'

compile 'com.hkm.loyalslider:library:1.8.3'

compile 'org.jsoup:jsoup:1.8.3'

compile 'com.github.satyan:sugar:1.5'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Expand Up @@ -37,5 +37,6 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

</manifest>
Expand Up @@ -11,28 +11,30 @@
import android.widget.ImageView;
import android.widget.TextView;


import com.hkm.slider.Indicators.PagerIndicator;
import com.hkm.slider.SliderLayout;
import com.hkm.slider.SliderTypes.DefaultSliderView;
import com.hkm.slider.TransformerL;
import com.koushikdutta.ion.Ion;

import openfoodfacts.github.scrachx.openfood.R;
import openfoodfacts.github.scrachx.openfood.models.State;
import openfoodfacts.github.scrachx.openfood.views.ProductActivity;

/**
* Created by scotscriven on 04/05/15.
*/
public class SummaryProductFragment extends Fragment {

ImageView imgProduct;
TextView nameProduct, barCodeProduct, quantityProduct, packagingProduct, brandProduct, manufacturingProduct,
cityProduct, storeProduct, countryProduct, categoryProduct;
SliderLayout sliderImages;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_summary_product,container,false);

String imgUrl;

imgProduct = (ImageView) rootView.findViewById(R.id.imageViewProduct);
nameProduct = (TextView) rootView.findViewById(R.id.textNameProduct);
barCodeProduct = (TextView) rootView.findViewById(R.id.textBarcodeProduct);
quantityProduct = (TextView) rootView.findViewById(R.id.textQuantityProduct);
Expand All @@ -43,16 +45,38 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
cityProduct = (TextView) rootView.findViewById(R.id.textCityProduct);
storeProduct = (TextView) rootView.findViewById(R.id.textStoreProduct);
countryProduct = (TextView) rootView.findViewById(R.id.textCountryProduct);
sliderImages = (SliderLayout) rootView.findViewById(R.id.slider);

Intent intent = getActivity().getIntent();
State state = (State) intent.getExtras().getSerializable("state");

if(state.getProduct().getImageUrl().isEmpty()){
imgUrl = state.getProduct().getImageSmallUrl();
}else{
imgUrl = state.getProduct().getImageUrl();
DefaultSliderView sliderViewImageDefault;
if(state.getProduct().getImageUrl() != null) {
sliderViewImageDefault = new DefaultSliderView(getActivity());
sliderViewImageDefault
.description("Default")
.image(state.getProduct().getImageUrl());
sliderImages.addSlider(sliderViewImageDefault);
}
if(state.getProduct().getImageIngredientsUrl() != null) {
sliderViewImageDefault = new DefaultSliderView(getActivity());
sliderViewImageDefault
.description("Ingredients")
.image(state.getProduct().getImageIngredientsUrl());
sliderImages.addSlider(sliderViewImageDefault);
}
setImageView(imgUrl);
if(state.getProduct().getImageNutritionUrl() != null) {
sliderViewImageDefault = new DefaultSliderView(getActivity());
sliderViewImageDefault
.description("Nutrition")
.image(state.getProduct().getImageNutritionUrl());

sliderImages.addSlider(sliderViewImageDefault);
}
sliderImages.setCustomIndicator((PagerIndicator) rootView.findViewById(R.id.custom_indicator));
sliderImages.setDuration(5000);
sliderImages.startAutoCycle();

nameProduct.setText(state.getProduct().getProductName());
barCodeProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtBarcode) + "</b>" + ' ' + state.getProduct().getCode()));
quantityProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtQuantity) + "</b>" + ' ' + state.getProduct().getQuantity()));
Expand All @@ -73,11 +97,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
return rootView;
}

public void setImageView(String imgUrl){
Ion.with(imgProduct)
.placeholder(R.drawable.placeholder_thumb)
.error(R.drawable.error_image)
.resizeWidth(600)
.load(imgUrl);
@Override
public void onStop() {
sliderImages.stopAutoCycle();
super.onStop();
}
}
Expand Up @@ -94,6 +94,8 @@ public void onStart() {
super.onStart();
save.setClickable(false);
lt.setText(context.getString(R.string.toast_retrieving));
lt.setBackgroundColor(getResources().getColor(R.color.indigo_600));
lt.setTextColor(getResources().getColor(R.color.white));
lt.show();
}

Expand Down
Expand Up @@ -32,6 +32,8 @@ public void getProduct(final String barcode, final Activity activity, final ZXin
public void onStart() {
// called before request is started
lt.setText(activity.getString(R.string.toast_retrieving));
lt.setBackgroundColor(activity.getResources().getColor(R.color.indigo_600));
lt.setTextColor(activity.getResources().getColor(R.color.white));
lt.show();
}

Expand Down Expand Up @@ -122,6 +124,8 @@ public void getProduct(final String barcode, final Activity activity){
public void onStart() {
// called before request is started
lt.setText(activity.getString(R.string.toast_retrieving));
lt.setBackgroundColor(activity.getResources().getColor(R.color.indigo_600));
lt.setTextColor(activity.getResources().getColor(R.color.white));
lt.show();
}

Expand Down Expand Up @@ -213,6 +217,8 @@ public void searchProduct(final String name, final Activity activity, final OnPr
public void onStart() {
// called before request is started
lt.setText(activity.getString(R.string.toast_retrieving));
lt.setBackgroundColor(activity.getResources().getColor(R.color.indigo_600));
lt.setTextColor(activity.getResources().getColor(R.color.white));
lt.show();
}

Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.res.Resources;
import android.widget.ListView;
import android.widget.Toast;
import com.loopj.android.http.JsonHttpResponseHandler;
Expand Down Expand Up @@ -34,6 +35,8 @@ public void post(final Activity activity, RequestParams params, final String img
public void onStart () {
// called before request is started
lt.setText(activity.getString(R.string.toastSending));
lt.setBackgroundColor(activity.getResources().getColor(R.color.indigo_600));
lt.setTextColor(activity.getResources().getColor(R.color.white));
lt.show();
}

Expand Down Expand Up @@ -84,6 +87,8 @@ public void postImg(final Activity activity, final RequestParams params, final S
public void onStart () {
// called before request is started
lt.setText(activity.getString(R.string.toastSending));
lt.setBackgroundColor(activity.getResources().getColor(R.color.indigo_600));
lt.setTextColor(activity.getResources().getColor(R.color.white));
lt.show();
}

Expand Down
Expand Up @@ -23,6 +23,9 @@
"states_tags",
"labels_tags",
"image_small_url",
"image_nutrition_url",
"image_front_url",
"url",
"code",
"traces_tags",
"lang",
Expand Down Expand Up @@ -138,6 +141,14 @@ public class Product implements Serializable{
private List<Object> labelsTags = new ArrayList<Object>();
@JsonProperty("image_small_url")
private String imageSmallUrl;
@JsonProperty("image_nutrition_url")
private String imageNutritionUrl;
@JsonProperty("image_front_url")
private String imageFrontUrl;
@JsonProperty("image_ingredients_url")
private String imageIngredientsUrl;
@JsonProperty("url")
private String url;
@JsonProperty("code")
private String code;
@JsonProperty("traces_tags")
Expand Down Expand Up @@ -529,6 +540,106 @@ public Product withImageSmallUrl(String imageSmallUrl) {
return this;
}

/**
*
* @return
* The imageFrontUrl
*/
@JsonProperty("image_front_url")
public String getImageFrontUrl() {
return imageFrontUrl;
}

/**
*
* @param imageFrontUrl
* The image_front_url
*/
@JsonProperty("image_front_url")
public void setImageFrontUrl(String imageFrontUrl) {
this.imageFrontUrl = imageFrontUrl;
}

public Product withImageFrontUrl(String imageFrontUrl) {
this.imageFrontUrl = imageFrontUrl;
return this;
}

/**
*
* @return
* The imageIngredientsUrl
*/
@JsonProperty("image_ingredients_url")
public String getImageIngredientsUrl() {
return imageIngredientsUrl;
}

/**
*
* @param imageIngredientsUrl
* The image_ingredients_url
*/
@JsonProperty("image_ingredients_url")
public void setImageIngredientsUrl(String imageIngredientsUrl) {
this.imageIngredientsUrl = imageIngredientsUrl;
}

public Product withImageIngredientsUrl(String imageIngredientsUrl) {
this.imageIngredientsUrl = imageIngredientsUrl;
return this;
}

/**
*
* @return
* The imageNutritionUrl
*/
@JsonProperty("image_nutrition_url")
public String getImageNutritionUrl() {
return imageNutritionUrl;
}

/**
*
* @param imageNutritionUrl
* The image_small_url
*/
@JsonProperty("image_nutrition_url")
public void setImageNutritionUrl(String imageNutritionUrl) {
this.imageNutritionUrl = imageNutritionUrl;
}

public Product withImageNutritionUrl(String imageNutritionUrl) {
this.imageNutritionUrl = imageNutritionUrl;
return this;
}

/**
*
* @return
* The url
*/
@JsonProperty("url")
public String getUrl() {
return url;
}

/**
*
* @param url
* The url
*/
@JsonProperty("url")
public void url(String url) {
this.url = url;
}

public Product withUrl(String url) {
this.url = url;
return this;
}

/**
*
* @return
Expand Down Expand Up @@ -2931,6 +3042,7 @@ public String toString() {
", nutritionGradeFr='" + nutritionGradeFr + '\'' +
", nutrientLevels=" + nutrientLevels +
", id='" + id + '\'' +
", url='" + url + '\'' +
", storesTags=" + storesTags +
", countries='" + countries + '\'' +
", purchasePlacesTags=" + purchasePlacesTags +
Expand Down Expand Up @@ -2976,6 +3088,7 @@ public String toString() {
", checkers=" + checkers +
", complete=" + complete +
", additionalProperties=" + additionalProperties +
", imageNutritionUrl='" + imageNutritionUrl + '\'' +
'}';
}
}
Expand Up @@ -45,6 +45,16 @@ public static String getUriByCurrentLanguage() {
return url;
}

public static String getUriProductByCurrentLanguage() {
String url;
if (Locale.getDefault().getLanguage().contains("fr")){
url = "http://fr.openfoodfacts.org/produit/";
} else {
url = "http://world.openfoodfacts.org/product/";
}
return url;
}

public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
Expand Down

0 comments on commit f4e96c1

Please sign in to comment.