public void filter(String searchBrand) { searchBrand = searchBrand.toLowerCase(Locale.getDefault()); data.clear(); if (searchBrand.length() == 0) { data.addAll(searchOffers); notifyDataSetChanged(); } else { ArrayList<NonExclusiveOffers> tempList = new ArrayList<NonExclusiveOffers>(searchOffers); ArrayList<Brands> brandsFromDatabase = new ArrayList<Brands>( shopistaDatabase.getBrandsForGivenKeyword( searchBrand, StaticVariables.Brand_Type.both)); for (int z = 0; z < tempList.size(); z++) { for (int y = 0; y < brandsFromDatabase.size(); y++) { if (tempList.get(z).getOffer_brand_id().equals(brandsFromDatabase.get(y).getBrand_id())) { data.add(tempList.get(z)); } } } } if (data.size() == 0) { data.addAll(searchOffers); notifyDataSetChanged(); Toast.makeText(mcontext, "No Match Found !", Toast.LENGTH_LONG).show(); } else { notifyDataSetChanged(); } }
@Override public void onMapReady(GoogleMap googleMap) { mygoogleMap = googleMap; googleMap.setMyLocationEnabled(true); ArrayList<StoreInfo> markerData = databaseHelper.getLatLongForMap(singleOffer.getStore_id()); mygoogleMap.setMyLocationEnabled(true); for (int i = 0; i < markerData.size(); i++) { mygoogleMap.addMarker( new MarkerOptions() .position( new LatLng( Double.parseDouble(markerData.get(i).getLatitude()), Double.parseDouble(markerData.get(i).getLongitude()))) .title(markerData.get(i).getLocation_name())); mygoogleMap.animateCamera( CameraUpdateFactory.newLatLngZoom( new LatLng( Double.parseDouble(markerData.get(i).getLatitude()), Double.parseDouble(markerData.get(i).getLongitude())), 10)); } mygoogleMap.getUiSettings().setZoomControlsEnabled(true); }
@Override public void onBindViewHolder(final OfferDiscountRushViewHolder holder, int position) { final NonExclusiveOffers current = data.get(position); holder.card_background_offer_discount.setDrawingCacheEnabled(true); if (holder.brand_icon != null) imageLoader.DisplayImage(current.getOffer_brand_logo(), holder.brand_icon); if (holder.brand_name != null) holder.brand_name.setText(current.getOffer_brand_name()); if (holder.category != null) holder.category.setText( shopistaDatabase.getMajorCategoryForGivenBrand(current.getOffer_brand_id())); if (holder.offer_description != null) { holder.offer_description.setText(current.getOffer_description()); holder.offer_description.setTextSize(22); holder.offer_description.setTypeface( Typeface.createFromAsset(mcontext.getAssets(), "handwritingfont.ttf")); } if (holder.endDate != null) { holder.endDate.setText("Ends on - " + current.getOffer_end_date()); holder.endDate.setTextSize(22); holder.endDate.setTypeface( Typeface.createFromAsset(mcontext.getAssets(), "handwritingfont.ttf")); } if (holder.card_background_offer_discount != null) { imageLoader.DisplayCardBackgroundImage( current.getOffer_image(), holder.card_background_offer_discount); } if (holder.mall_in != null) { Malls mall = new Malls(); mall = shopistaDatabase.getSingleMall(current.getOffer_mall_id()); holder.mall_in.setText("" + mall.getMall_name() + ", " + mall.getMall_area()); } holder.share.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra( Intent.EXTRA_TEXT, StaticVariables.OFFER_HEADER + current.getOffer_brand_name() + "\n\n" + current.getOffer_description() + "\n" + StaticVariables.OFFER_FOOTER); mcontext.startActivity(Intent.createChooser(intent, "Share via")); } }); holder.cardview.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent increment_popularity = new Intent(mcontext, IncreasePopularityCount.class); increment_popularity.putExtra("offer_number", current.getOffer_number()); mcontext.startService(increment_popularity); Intent intent = new Intent(mcontext, Information.class); intent.putExtra("brand_id", current.getOffer_brand_id()); mcontext.startActivity(intent); } }); }