Skip to content

Coupon list

Basic example

With these few lines of code:

startActivity(
    NearITUIBindings.getInstance(this@YourActivity)
                        .couponListIntentBuilder()
                        .setTitle("My coupon list")
                        .build())
startActivity(
    NearITUIBindings.getInstance(YourActivity.this)
                        .couponListIntentBuilder()
                        .setTitle("My coupon list")
                        .build());

you are able to show the list of coupons with this sorting rationale:

  • valid coupons
  • not yet active coupons

each set is ordered by the date the user earned the coupons.

coupon list

You can include the already redeemed coupons, chaining this method to the builder: includeRedeemed()

Advanced Examples

Filter Coupons

When you create a coupon list builder, you can chain one of the following methods to get just a set of coupons:

  • validCoupons()
  • expiredCoupons()
  • inactiveCoupons()
  • redeemedCoupons()

For example:

startActivity(
    NearITUIBindings.getInstance(this@YourActivity)
                        .couponListIntentBuilder()
                        .validCoupons()
                        .build())
startActivity(
    NearITUIBindings.getInstance(YourActivity.this)
                        .couponListIntentBuilder()
                        .validCoupons()
                        .build());

Custom behaviour

You are able to set the behaviour and look of the coupon detail that it is going to be shown when an user taps on one item of the list.

You can set a placeholder resource image for coupons with no icon:

setIconPlaceholderResourceId(icon: Int)
setIconPlaceholderResourceId(int icon);

You can set a resource image for a custom separator:

setSeparatorResourceId(separator: Int)
setSeparatorResourceId(int separator);

You can disable the separator: setNoSeparator()

You can disable the icon: setNoIcon()

You can enable dialog closing when tapping outside of it: enableTapOutsideToClose()


Read more about the coupon detail UI and how to tweak it here.

Fragment mode

If you want to list the coupon list in your activity, place this fragment in your container:

val couponListFragment: Fragment = NearITUIBindings.getInstance(this)
                .couponListFragmentBuilder()
                .build()
Fragment couponListFragment = NearITUIBindings.getInstance(this)
                .couponListFragmentBuilder()
                .build();

Manually handle coupons

You can get the coupon instance list directly from the SDK and decide what to do with them.

To get the coupon list, call:

NearItManager.getInstance().getCoupons(object : CouponListener {

    override fun onCouponsDownloaded(coupons: MutableList<Coupon>?) {

    }

    override fun onCouponDownloadError(s: String) {

    }
})
NearItManager.getInstance().getCoupons(new CouponListener() {

    @Override
    public void onCouponsDownloaded(List<Coupon> list) {

    }

    @Override
    public void onCouponDownloadError(String s) {

    }
});

UI Customization

Like any other UI component provided by this library, you can change the look overriding colors, dimensions and strings resources.

For example, if you need to change the validity text colors, you can place these colors in your res/values/colors.xml:

<!--    ...     -->
<color name="nearit_ui_coupon_list_valid_text_color">@color/your_color</color>
<color name="nearit_ui_coupon_list_inactive_text_color">@color/your_color</color>
<color name="nearit_ui_coupon_list_expired_text_color">@color/your_color</color>
<color name="nearit_ui_coupon_list_redeemed_text_color">@color/your_color</color>
<!--    ...     -->

The same for strings, dimensions and styles. The following file contains the resources you can override to customize the coupon list appearance:

Coupon list resources

Just keep in mind that changing dimensions can cause unpredictable distortion problems to our layouts.