Ejemplo n.º 1
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_product_detail, container, false);
    iCartCount = (ICartCount) getActivity();
    ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager_product);
    ProductPagerAdapter productPagerAdapter =
        new ProductPagerAdapter(
            getActivity().getSupportFragmentManager(), product.getProductImageUrls());
    viewPager.setAdapter(productPagerAdapter);
    tvCounter = (TextView) view.findViewById(R.id.tv_toolbar_counter);
    setTextViewCounter();
    if (itemCounter != 0) {
      tvCounter.setVisibility(View.VISIBLE);
    }
    setToolbar(view);

    Button btnAdd = (Button) view.findViewById(R.id.btn_product_add);
    btnAdd.setOnClickListener(this);

    TextView tvTitle = (TextView) view.findViewById(R.id.tv_product_title);
    TextView tvAvailable = (TextView) view.findViewById(R.id.tv_product_available);
    TextView tvSize = (TextView) view.findViewById(R.id.tv_product_size);
    tvTitle.setText(product.getTitle());
    if (product.getInStock()) {
      tvAvailable.setText("In Stock");
    } else {
      tvAvailable.setText("Not available");
    }
    tvSize.setText(product.getCurrentPrice());

    return view;
  }
Ejemplo n.º 2
0
 @Override
 public void onCreate(@Nullable Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   product = (Product) getArguments().get(Constants.ARGS_PRODUCT);
   Log.i(TAG, "producnt " + product.getTitle());
   //        ((AppCompatActivity) getActivity()).getSupportActionBar().hide();
   SharedPreferences sp =
       getActivity()
           .getSharedPreferences(getString(R.string.sp_chart_counter), Context.MODE_PRIVATE);
   itemCounter = sp.getInt(getString(R.string.sp_counter_key), 0);
 }
Ejemplo n.º 3
0
 @Override
 public void onClick(View v) {
   itemCounter++;
   tvCounter.setVisibility(View.VISIBLE);
   setTextViewCounter();
   iCartCount.getCartCount(
       itemCounter,
       new Wish(
           product.getProductId(),
           product.getProductImageUrls().get(0),
           product.getTitle(),
           true // is cart
           ));
   FragmentManager fm = getActivity().getSupportFragmentManager();
   //        fm.beginTransaction().replace(R.id.container, CartFragment.newInstance(),
   // CartFragment.TAG).commit(); //display cart from SP
   getActivity().startService(WishService.makeIntent(getActivity(), null)); // this will show wish
 }