Added coupon use case for view, update and delete
This commit is contained in:
parent
17177d07e0
commit
5ca1540974
@ -12,6 +12,16 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.coupon.CouponActivity"
|
||||
android:label="@string/title_activity_coupon"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.coupon.CouponsActivity"
|
||||
android:label="@string/title_activity_coupons"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.coupon.AddCouponActivity"
|
||||
android:label="@string/title_activity_add_coupon"
|
||||
@ -22,11 +32,6 @@
|
||||
android:label="@string/title_activity_menu"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.coupon.CouponActivity"
|
||||
android:label="@string/title_activity_coupon"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.ShopActivity"
|
||||
android:label="@string/title_activity_shop"
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package me.gilo.wc.adapter.viewholder
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.text.Html
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import me.gilo.wc.R
|
||||
import me.gilo.wc.ui.coupon.CouponActivity
|
||||
import me.gilo.woodroid.models.Coupon
|
||||
|
||||
class CouponViewHolder(val context: Context, itemView: View) :
|
||||
@ -17,6 +19,13 @@ class CouponViewHolder(val context: Context, itemView: View) :
|
||||
|
||||
tvTitle.text = coupon.code.toUpperCase()
|
||||
tvDescription.text = Html.fromHtml(coupon.description)
|
||||
|
||||
itemView.setOnClickListener{
|
||||
val intent = Intent(context, CouponActivity::class.java)
|
||||
intent.putExtra("couponId", coupon.id)
|
||||
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import me.gilo.wc.R;
|
||||
import me.gilo.wc.ui.coupon.CouponActivity;
|
||||
import me.gilo.wc.ui.coupon.CouponsActivity;
|
||||
import me.gilo.wc.ui.ShopActivity;
|
||||
|
||||
public class MenuViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -37,7 +37,7 @@ public class MenuViewHolder extends RecyclerView.ViewHolder {
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "Coupons":
|
||||
intent = new Intent(context, CouponActivity.class);
|
||||
intent = new Intent(context, CouponsActivity.class);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4,11 +4,20 @@ import android.content.Context
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper
|
||||
import me.gilo.wc.ui.state.ProgressDialogFragment
|
||||
import me.gilo.woodroid.Woocommerce
|
||||
|
||||
open class BaseActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var progressDialog : ProgressDialogFragment
|
||||
|
||||
val woocommerce = Woocommerce.Builder()
|
||||
.setSiteUrl("http://157.230.131.179")
|
||||
.setApiVersion(Woocommerce.API_V2)
|
||||
.setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
.setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
.build()
|
||||
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase))
|
||||
}
|
||||
@ -20,6 +29,10 @@ open class BaseActivity : AppCompatActivity() {
|
||||
progressDialog.show(manager, "progress")
|
||||
}
|
||||
|
||||
fun showLoading() {
|
||||
showLoading("This will only take a sec", "Loading")
|
||||
}
|
||||
|
||||
fun stopShowingLoading() {
|
||||
progressDialog.dismiss()
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import kotlinx.android.synthetic.main.activity_add_coupon.*
|
||||
import kotlinx.android.synthetic.main.content_add_coupon.*
|
||||
import me.gilo.wc.R
|
||||
import me.gilo.wc.ui.BaseActivity
|
||||
import me.gilo.woodroid.Woocommerce
|
||||
import me.gilo.woodroid.models.Coupon
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
@ -13,13 +12,20 @@ import retrofit2.Response
|
||||
|
||||
class AddCouponActivity : BaseActivity() {
|
||||
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_add_coupon)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
title = "Add Coupon"
|
||||
|
||||
bCreate.setOnClickListener { submit() }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun submit() {
|
||||
@ -36,13 +42,6 @@ class AddCouponActivity : BaseActivity() {
|
||||
private fun createCoupon(coupon: Coupon) {
|
||||
showLoading("Loading", "This won't take long")
|
||||
|
||||
val woocommerce = Woocommerce.Builder()
|
||||
.setSiteUrl("http://157.230.131.179")
|
||||
.setApiVersion(Woocommerce.API_V2)
|
||||
.setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
.setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
.build()
|
||||
|
||||
woocommerce.Coupon().create(coupon).enqueue(object : Callback<Coupon> {
|
||||
override fun onResponse(call: Call<Coupon>, response: Response<Coupon>) {
|
||||
val couponResponse = response.body()
|
||||
|
||||
@ -1,26 +1,20 @@
|
||||
package me.gilo.wc.ui.coupon
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.widget.Toast
|
||||
import kotlinx.android.synthetic.main.activity_coupon.*
|
||||
import kotlinx.android.synthetic.main.content_coupon.*
|
||||
import me.gilo.wc.R
|
||||
import me.gilo.wc.adapter.CouponAdapter
|
||||
import me.gilo.wc.ui.BaseActivity
|
||||
import me.gilo.woodroid.Woocommerce
|
||||
import me.gilo.woodroid.models.Coupon
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import java.util.*
|
||||
|
||||
|
||||
|
||||
class CouponActivity : BaseActivity() {
|
||||
|
||||
|
||||
lateinit var adapter : CouponAdapter
|
||||
lateinit var coupons: ArrayList<Coupon>
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_coupon)
|
||||
@ -28,44 +22,89 @@ class CouponActivity : BaseActivity() {
|
||||
|
||||
title = "Coupon"
|
||||
|
||||
val layoutManager = LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
|
||||
rvCoupons.layoutManager = layoutManager
|
||||
rvCoupons.isNestedScrollingEnabled = false
|
||||
val couponId = intent.getIntExtra("couponId", 0)
|
||||
|
||||
coupons = ArrayList()
|
||||
if (couponId != 0){
|
||||
getCoupon(couponId)
|
||||
|
||||
adapter = CouponAdapter(coupons)
|
||||
rvCoupons.adapter = adapter
|
||||
bDelete.setOnClickListener{delete(couponId)}
|
||||
bUpdate.setOnClickListener{
|
||||
val coupon = Coupon()
|
||||
coupon.id = couponId
|
||||
coupon.code = etCode.text.toString()
|
||||
coupon.description = etDescription.text.toString()
|
||||
|
||||
coupons()
|
||||
update(coupon)
|
||||
}
|
||||
|
||||
fab.setOnClickListener{
|
||||
startActivity(Intent(baseContext, AddCouponActivity::class.java))
|
||||
}else{
|
||||
Toast.makeText(baseContext, "You did not pass coupon id", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Not best practise, but works for purposes of demo
|
||||
private fun coupons() {
|
||||
val woocommerce = Woocommerce.Builder()
|
||||
.setSiteUrl("http://157.230.131.179")
|
||||
.setApiVersion(Woocommerce.API_V2)
|
||||
.setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
.setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
.build()
|
||||
private fun getCoupon(couponId: Int) {
|
||||
showLoading()
|
||||
|
||||
woocommerce.Coupon().coupons().enqueue(object : Callback<List<Coupon>> {
|
||||
override fun onResponse(call: Call<List<Coupon>>, response: Response<List<Coupon>>) {
|
||||
val couponResponse = response.body()
|
||||
for (coupon in couponResponse!!) {
|
||||
coupons.add(coupon)
|
||||
woocommerce.Coupon().coupon(couponId).enqueue(object : Callback<Coupon> {
|
||||
override fun onResponse(call: Call<Coupon>, response: Response<Coupon>) {
|
||||
val coupon = response.body()!!
|
||||
|
||||
etCode.setText(coupon.code.toUpperCase())
|
||||
etDescription.setText(coupon.description)
|
||||
|
||||
stopShowingLoading()
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged()
|
||||
override fun onFailure(call: Call<Coupon>, t: Throwable) {
|
||||
stopShowingLoading()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<List<Coupon>>, t: Throwable) {
|
||||
private fun delete(couponId: Int) {
|
||||
showLoading()
|
||||
|
||||
woocommerce.Coupon().delete(couponId).enqueue(object : Callback<Coupon> {
|
||||
override fun onResponse(call: Call<Coupon>, response: Response<Coupon>) {
|
||||
if (response.isSuccessful) {
|
||||
val coupon = response.body()!!
|
||||
|
||||
etCode.setText(coupon.code.toUpperCase())
|
||||
etDescription.setText(coupon.description)
|
||||
|
||||
finish()
|
||||
}else{
|
||||
Toast.makeText(this@CouponActivity, "" + response.code() + " : " + response.message(), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
stopShowingLoading()
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<Coupon>, t: Throwable) {
|
||||
stopShowingLoading()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private fun update(coupon: Coupon) {
|
||||
showLoading()
|
||||
|
||||
woocommerce.Coupon().update(coupon.id, coupon).enqueue(object : Callback<Coupon> {
|
||||
override fun onResponse(call: Call<Coupon>, response: Response<Coupon>) {
|
||||
val coupon = response.body()!!
|
||||
|
||||
etCode.setText(coupon.code.toUpperCase())
|
||||
etDescription.setText(coupon.description)
|
||||
|
||||
stopShowingLoading()
|
||||
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<Coupon>, t: Throwable) {
|
||||
stopShowingLoading()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
65
app/src/main/java/me/gilo/wc/ui/coupon/CouponsActivity.kt
Normal file
65
app/src/main/java/me/gilo/wc/ui/coupon/CouponsActivity.kt
Normal file
@ -0,0 +1,65 @@
|
||||
package me.gilo.wc.ui.coupon
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.activity_coupons.*
|
||||
import kotlinx.android.synthetic.main.content_coupons.*
|
||||
import me.gilo.wc.R
|
||||
import me.gilo.wc.adapter.CouponAdapter
|
||||
import me.gilo.wc.ui.BaseActivity
|
||||
import me.gilo.woodroid.models.Coupon
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import java.util.*
|
||||
|
||||
class CouponsActivity : BaseActivity() {
|
||||
|
||||
|
||||
lateinit var adapter : CouponAdapter
|
||||
lateinit var coupons: ArrayList<Coupon>
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_coupons)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
title = "Coupons"
|
||||
|
||||
val layoutManager = LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
|
||||
rvCoupons.layoutManager = layoutManager
|
||||
rvCoupons.isNestedScrollingEnabled = false
|
||||
|
||||
coupons = ArrayList()
|
||||
|
||||
adapter = CouponAdapter(coupons)
|
||||
rvCoupons.adapter = adapter
|
||||
|
||||
coupons()
|
||||
|
||||
fab.setOnClickListener{
|
||||
startActivity(Intent(baseContext, AddCouponActivity::class.java))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Not best practise, but works for purposes of demo
|
||||
private fun coupons() {
|
||||
woocommerce.Coupon().coupons().enqueue(object : Callback<List<Coupon>> {
|
||||
override fun onResponse(call: Call<List<Coupon>>, response: Response<List<Coupon>>) {
|
||||
val couponResponse = response.body()
|
||||
for (coupon in couponResponse!!) {
|
||||
coupons.add(coupon)
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<List<Coupon>>, t: Throwable) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -23,14 +23,4 @@
|
||||
|
||||
<include layout="@layout/content_coupon"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:src="@drawable/baseline_add_black_18dp"
|
||||
android:tint="#ffffff"
|
||||
android:layout_margin="16dp" />
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
36
app/src/main/res/layout/activity_coupons.xml
Normal file
36
app/src/main/res/layout/activity_coupons.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.coupon.CouponsActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_coupons"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:src="@drawable/baseline_add_black_18dp"
|
||||
android:tint="#ffffff"
|
||||
android:layout_margin="16dp" />
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@ -24,63 +24,27 @@
|
||||
android:background="@drawable/rect_white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="17dp"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="Create a coupon"
|
||||
android:textColor="#9298a4"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="MissingPrefix"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:background="@drawable/rect_white"
|
||||
android:elevation="2dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatEditText
|
||||
android:id="@+id/etCode"
|
||||
android:layout_width="360dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="false"
|
||||
android:cursorVisible="true"
|
||||
android:hint="Coupon code"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="18sp"
|
||||
app:backgroundTint="#ffffff"/>
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@drawable/rect_white"
|
||||
android:elevation="2dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatEditText
|
||||
android:id="@+id/etDescription"
|
||||
android:layout_width="360dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="false"
|
||||
android:cursorVisible="true"
|
||||
android:gravity="top|left"
|
||||
android:hint="Enter text here"
|
||||
android:minLines="3"
|
||||
@ -89,9 +53,7 @@
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="18sp"
|
||||
app:backgroundTint="#ffffff"/>
|
||||
|
||||
</LinearLayout>
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -1,20 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:background="@color/bg"
|
||||
android:orientation="vertical"
|
||||
tools:showIn="@layout/activity_coupon"
|
||||
tools:context=".ui.coupon.CouponActivity">
|
||||
tools:context=".ui.coupon.AddCouponActivity"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:id="@+id/rvCoupons"
|
||||
></android.support.v7.widget.RecyclerView>
|
||||
android:layout_margin="16dp"
|
||||
android:padding="16dp"
|
||||
android:background="@drawable/rect_white"
|
||||
android:orientation="vertical">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
<android.support.v7.widget.AppCompatEditText
|
||||
android:id="@+id/etCode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="true"
|
||||
android:hint="Coupon code"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="18sp"
|
||||
/>
|
||||
|
||||
|
||||
<android.support.v7.widget.AppCompatEditText
|
||||
android:id="@+id/etDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="true"
|
||||
android:gravity="top|left"
|
||||
android:hint="Enter text here"
|
||||
android:minLines="3"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="18sp"
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bDelete"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@color/text_black_5"
|
||||
android:text="Delete"
|
||||
android:layout_weight="1"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="18sp"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/bUpdate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/colorPrimary"
|
||||
android:text="Update"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="18sp"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
20
app/src/main/res/layout/content_coupons.xml
Normal file
20
app/src/main/res/layout/content_coupons.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:showIn="@layout/activity_coupons"
|
||||
tools:context=".ui.coupon.CouponsActivity">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:id="@+id/rvCoupons"
|
||||
></android.support.v7.widget.RecyclerView>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@ -9,5 +9,6 @@
|
||||
<string name="font_medium">fonts/GT-America-Medium.otf</string>
|
||||
<string name="font_regular">fonts/GT-America-Regular.otf</string>
|
||||
<string name="title_activity_add_coupon">AddCouponActivity</string>
|
||||
<string name="title_activity_coupons">CouponsActivity</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -19,6 +19,7 @@ allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ public class Coupon implements Serializable{
|
||||
private int usage_limit_per_user;
|
||||
private int limit_usage_to_x_items;
|
||||
private String[] meta_data;
|
||||
private String id;
|
||||
private int id;
|
||||
private String date_modified_gmt;
|
||||
private String amount;
|
||||
private String date_created;
|
||||
@ -136,11 +136,11 @@ public class Coupon implements Serializable{
|
||||
this.meta_data = meta_data;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user