Skip to content

Commit

Permalink
Fix #104 & #132
Browse files Browse the repository at this point in the history
  • Loading branch information
itchix committed Sep 29, 2016
1 parent c847cf7 commit 8dee07d
Showing 1 changed file with 25 additions and 31 deletions.
Expand Up @@ -3,42 +3,36 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hkm.slider.Animations.DescriptionAnimation;
import com.hkm.slider.Indicators.PagerIndicator;
import com.hkm.slider.SliderLayout;
import com.hkm.slider.SliderTypes.AdjustableSlide;
import com.hkm.slider.SliderTypes.BaseSliderView;
import com.hkm.slider.SliderTypes.DefaultSliderView;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.BindView;
import openfoodfacts.github.scrachx.openfood.R;
import openfoodfacts.github.scrachx.openfood.models.State;

public class SummaryProductFragment extends BaseFragment {

@Bind(R.id.textNameProduct) TextView nameProduct;
@Bind(R.id.textBarcodeProduct) TextView barCodeProduct;
@Bind(R.id.textQuantityProduct) TextView quantityProduct;
@Bind(R.id.textPackagingProduct) TextView packagingProduct;
@Bind(R.id.textBrandProduct) TextView brandProduct;
@Bind(R.id.textManufacturingProduct) TextView manufacturingProduct;
@Bind(R.id.textCityProduct) TextView cityProduct;
@Bind(R.id.textStoreProduct) TextView storeProduct;
@Bind(R.id.textCountryProduct) TextView countryProduct;
@Bind(R.id.textCategoryProduct) TextView categoryProduct;
@Bind(R.id.slider) SliderLayout sliderImages;
@Bind(R.id.custom_indicator) PagerIndicator pagerIndicator;
@BindView(R.id.textNameProduct) TextView nameProduct;
@BindView(R.id.textBarcodeProduct) TextView barCodeProduct;
@BindView(R.id.textQuantityProduct) TextView quantityProduct;
@BindView(R.id.textPackagingProduct) TextView packagingProduct;
@BindView(R.id.textBrandProduct) TextView brandProduct;
@BindView(R.id.textManufacturingProduct) TextView manufacturingProduct;
@BindView(R.id.textCityProduct) TextView cityProduct;
@BindView(R.id.textStoreProduct) TextView storeProduct;
@BindView(R.id.textCountryProduct) TextView countryProduct;
@BindView(R.id.textCategoryProduct) TextView categoryProduct;
@BindView(R.id.slider) SliderLayout sliderImages;
@BindView(R.id.custom_indicator) PagerIndicator pagerIndicator;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand Down Expand Up @@ -76,54 +70,54 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
sliderImages.setDuration(5500);
sliderImages.startAutoCycle();

if(!state.getProduct().getProductName().trim().isEmpty()) {
if(state.getProduct().getProductName() != null && !state.getProduct().getProductName().trim().isEmpty()) {
nameProduct.setText(state.getProduct().getProductName());
} else {
nameProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getCode().trim().isEmpty()) {
if(state.getProduct().getCode() != null && !state.getProduct().getCode().trim().isEmpty()) {
barCodeProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtBarcode) + "</b>" + ' ' + state.getProduct().getCode()));
} else {
barCodeProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getQuantity().trim().isEmpty()) {
if(state.getProduct().getQuantity() != null && !state.getProduct().getQuantity().trim().isEmpty()) {
quantityProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtQuantity) + "</b>" + ' ' + state.getProduct().getQuantity()));
} else {
quantityProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getPackaging().trim().isEmpty()) {
if(state.getProduct().getPackaging() != null && !state.getProduct().getPackaging().trim().isEmpty()) {
packagingProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtPackaging) + "</b>" + ' ' + state.getProduct().getPackaging()));
} else {
packagingProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getBrands().trim().isEmpty()) {
if(state.getProduct().getBrands() != null && !state.getProduct().getBrands().trim().isEmpty()) {
brandProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtBrands) + "</b>" + ' ' + state.getProduct().getBrands()));
} else {
brandProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getManufacturingPlaces().trim().isEmpty()) {
if(state.getProduct().getManufacturingPlaces() != null && !state.getProduct().getManufacturingPlaces().trim().isEmpty()) {
manufacturingProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtManufacturing) + "</b>" + ' ' + state.getProduct().getManufacturingPlaces()));
} else {
manufacturingProduct.setVisibility(View.GONE);
}
String categ;
if (!state.getProduct().getCategories().trim().isEmpty()) {
categoryProduct.setVisibility(View.GONE);
} else {
if (state.getProduct().getCategories() != null && !state.getProduct().getCategories().trim().isEmpty()) {
categ = state.getProduct().getCategories().replace(",", ", ");
categoryProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtCategories) + "</b>" + ' ' + categ));
} else {
categoryProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getCitiesTags().toString().trim().equals("[]")) {
if(state.getProduct().getCitiesTags() != null && !state.getProduct().getCitiesTags().toString().trim().equals("[]")) {
cityProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtCity) + "</b>" + ' ' + state.getProduct().getCitiesTags().toString().replace("[", "").replace("]", "")));
} else {
cityProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getStores().trim().isEmpty()) {
if(state.getProduct().getStores() != null && !state.getProduct().getStores().trim().isEmpty()) {
storeProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtStores) + "</b>" + ' ' + state.getProduct().getStores()));
} else {
storeProduct.setVisibility(View.GONE);
}
if(!state.getProduct().getCountries().trim().isEmpty()) {
if(state.getProduct().getCountries() != null && !state.getProduct().getCountries().trim().isEmpty()) {
countryProduct.setText(Html.fromHtml("<b>" + getString(R.string.txtCountries) + "</b>" + ' ' + state.getProduct().getCountries()));
} else {
countryProduct.setVisibility(View.GONE);
Expand Down

0 comments on commit 8dee07d

Please sign in to comment.