Added coupon use case for create
This commit is contained in:
parent
130ac6375e
commit
17177d07e0
@ -12,13 +12,18 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.coupon.AddCouponActivity"
|
||||
android:label="@string/title_activity_add_coupon"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.MenuActivity"
|
||||
android:label="@string/title_activity_menu"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.CouponActivity"
|
||||
android:name=".ui.coupon.CouponActivity"
|
||||
android:label="@string/title_activity_coupon"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
|
||||
34
app/src/main/java/me/gilo/wc/adapter/CouponAdapter.java
Normal file
34
app/src/main/java/me/gilo/wc/adapter/CouponAdapter.java
Normal file
@ -0,0 +1,34 @@
|
||||
package me.gilo.wc.adapter;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import me.gilo.wc.R;
|
||||
import me.gilo.wc.adapter.viewholder.CouponViewHolder;
|
||||
import me.gilo.woodroid.models.Coupon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CouponAdapter extends RecyclerView.Adapter<CouponViewHolder> {
|
||||
private List<Coupon> coupons;
|
||||
|
||||
public CouponAdapter(List<Coupon> coupons) {
|
||||
this.coupons = coupons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CouponViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new CouponViewHolder(parent.getContext(), LayoutInflater.from(parent.getContext()).inflate(R.layout.single_coupon_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(CouponViewHolder holder, int position) {
|
||||
holder.renderView(coupons.get(position));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return coupons.size() == 0 ? 0 : coupons.size();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package me.gilo.wc.adapter.viewholder
|
||||
|
||||
import android.content.Context
|
||||
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.woodroid.models.Coupon
|
||||
|
||||
class CouponViewHolder(val context: Context, itemView: View) :
|
||||
RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
fun renderView(coupon: Coupon) {
|
||||
val tvTitle = itemView.findViewById<TextView>(R.id.tvTitle)
|
||||
val tvDescription = itemView.findViewById<TextView>(R.id.tvDescription)
|
||||
|
||||
tvTitle.text = coupon.code.toUpperCase()
|
||||
tvDescription.text = Html.fromHtml(coupon.description)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,14 +1,12 @@
|
||||
package me.gilo.wc.adapter.viewholder;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import me.gilo.wc.R;
|
||||
import me.gilo.wc.ui.CouponActivity;
|
||||
import me.gilo.wc.ui.coupon.CouponActivity;
|
||||
import me.gilo.wc.ui.ShopActivity;
|
||||
|
||||
public class MenuViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
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
|
||||
@ -9,8 +8,6 @@ import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.squareup.picasso.Picasso
|
||||
import me.gilo.wc.R
|
||||
import me.gilo.wc.ui.CouponActivity
|
||||
import me.gilo.wc.ui.ShopActivity
|
||||
import me.gilo.woodroid.models.Product
|
||||
|
||||
class ProductViewHolder(val context: Context, itemView: View) :
|
||||
|
||||
@ -1,23 +1,26 @@
|
||||
package me.gilo.wc.ui
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper
|
||||
import me.gilo.wc.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_menu.*
|
||||
import kotlinx.android.synthetic.main.content_menu.*
|
||||
import me.gilo.wc.adapter.MenuAdapter
|
||||
import java.util.ArrayList
|
||||
import me.gilo.wc.ui.state.ProgressDialogFragment
|
||||
|
||||
open class BaseActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var progressDialog : ProgressDialogFragment
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase))
|
||||
}
|
||||
|
||||
fun showLoading(title: String, message: String) {
|
||||
val manager = supportFragmentManager
|
||||
progressDialog = ProgressDialogFragment.newInstance(title, message)
|
||||
progressDialog.isCancelable = false
|
||||
progressDialog.show(manager, "progress")
|
||||
}
|
||||
|
||||
fun stopShowingLoading() {
|
||||
progressDialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
package me.gilo.wc.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import me.gilo.wc.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_coupon.*
|
||||
|
||||
class CouponActivity : BaseActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_coupon)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
title = "Coupon"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
59
app/src/main/java/me/gilo/wc/ui/coupon/AddCouponActivity.kt
Normal file
59
app/src/main/java/me/gilo/wc/ui/coupon/AddCouponActivity.kt
Normal file
@ -0,0 +1,59 @@
|
||||
package me.gilo.wc.ui.coupon
|
||||
|
||||
import android.os.Bundle
|
||||
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
|
||||
import retrofit2.Response
|
||||
|
||||
class AddCouponActivity : BaseActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_add_coupon)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
bCreate.setOnClickListener { submit() }
|
||||
|
||||
}
|
||||
|
||||
private fun submit() {
|
||||
val code = etCode.text.toString()
|
||||
val description = etDescription.text.toString()
|
||||
|
||||
val coupon = Coupon()
|
||||
coupon.code = code
|
||||
coupon.description = description
|
||||
|
||||
createCoupon(coupon)
|
||||
}
|
||||
|
||||
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()
|
||||
stopShowingLoading()
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<Coupon>, t: Throwable) {
|
||||
stopShowingLoading()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
73
app/src/main/java/me/gilo/wc/ui/coupon/CouponActivity.kt
Normal file
73
app/src/main/java/me/gilo/wc/ui/coupon/CouponActivity.kt
Normal file
@ -0,0 +1,73 @@
|
||||
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_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)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
title = "Coupon"
|
||||
|
||||
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() {
|
||||
val woocommerce = Woocommerce.Builder()
|
||||
.setSiteUrl("http://157.230.131.179")
|
||||
.setApiVersion(Woocommerce.API_V2)
|
||||
.setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
.setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
.build()
|
||||
|
||||
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) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package me.gilo.wc.ui.state;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import me.gilo.wc.R;
|
||||
|
||||
|
||||
public class ProgressDialogFragment extends DialogFragment {
|
||||
|
||||
private static final String ARG_TITLE= "title";
|
||||
private static final String ARG_MESSAGE= "message";
|
||||
|
||||
String title = "";
|
||||
String message = "";
|
||||
|
||||
public ProgressDialogFragment() {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_TITLE, title);
|
||||
args.putString(ARG_MESSAGE, message);
|
||||
setArguments(args);
|
||||
}
|
||||
|
||||
public static ProgressDialogFragment newInstance(String title, String message) {
|
||||
ProgressDialogFragment fragment = new ProgressDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_TITLE, title);
|
||||
args.putString(ARG_MESSAGE, message);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.loading_view, container);
|
||||
TextView tvTitle = view.findViewById(R.id.tvProgress_title);
|
||||
TextView tvMessage = view.findViewById(R.id.tvProgress_message);
|
||||
|
||||
title = getArguments().getString(ARG_TITLE);
|
||||
message = getArguments().getString(ARG_MESSAGE);
|
||||
|
||||
|
||||
tvTitle.setText(title);
|
||||
tvMessage.setText(message);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
BIN
app/src/main/res/drawable/baseline_add_black_18dp.png
Normal file
BIN
app/src/main/res/drawable/baseline_add_black_18dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 136 B |
26
app/src/main/res/layout/activity_add_coupon.xml
Normal file
26
app/src/main/res/layout/activity_add_coupon.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?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.AddCouponActivity">
|
||||
|
||||
<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_add_coupon"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@ -5,7 +5,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.CouponActivity">
|
||||
tools:context=".ui.coupon.CouponActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_height="wrap_content"
|
||||
@ -23,4 +23,14 @@
|
||||
|
||||
<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>
|
||||
117
app/src/main/res/layout/content_add_coupon.xml
Normal file
117
app/src/main/res/layout/content_add_coupon.xml
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
android:background="@color/bg"
|
||||
android:orientation="vertical"
|
||||
tools:showIn="@layout/activity_add_coupon"
|
||||
tools:context=".ui.coupon.AddCouponActivity"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
>
|
||||
|
||||
<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_margin="16dp"
|
||||
android:padding="16dp"
|
||||
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_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="false"
|
||||
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_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="false"
|
||||
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"
|
||||
app:backgroundTint="#ffffff"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bCreate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:text="Create"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="18sp"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@ -7,6 +7,14 @@
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:showIn="@layout/activity_coupon"
|
||||
tools:context=".ui.CouponActivity">
|
||||
tools:context=".ui.coupon.CouponActivity">
|
||||
|
||||
<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>
|
||||
117
app/src/main/res/layout/fragment_add_coupon.xml
Normal file
117
app/src/main/res/layout/fragment_add_coupon.xml
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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"
|
||||
android:background="@color/bg"
|
||||
android:orientation="vertical"
|
||||
tools:showIn="@layout/activity_add_coupon"
|
||||
tools:context=".ui.coupon.AddCouponActivity"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
>
|
||||
|
||||
<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_margin="16dp"
|
||||
android:padding="16dp"
|
||||
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_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="false"
|
||||
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_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="false"
|
||||
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"
|
||||
app:backgroundTint="#ffffff"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bCreate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:text="Create"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="18sp"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
38
app/src/main/res/layout/loading_view.xml
Normal file
38
app/src/main/res/layout/loading_view.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
|
||||
></ProgressBar>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvProgress_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Please wait..."
|
||||
android:textColor="#333333"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="8dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvProgress_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Fetching Details"
|
||||
android:textColor="#666666"
|
||||
android:textSize="13sp"
|
||||
android:layout_marginTop="4dp"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
45
app/src/main/res/layout/single_coupon_item.xml
Normal file
45
app/src/main/res/layout/single_coupon_item.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/rect_white"
|
||||
android:elevation="2dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
fontPath="@string/font_medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:gravity="left"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDescription"
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:gravity="left"
|
||||
android:maxLines="2"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_5"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@ -8,5 +8,6 @@
|
||||
<string name="font_bold">fonts/GT-America-Bold.otf</string>
|
||||
<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>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
package me.gilo.woodroid.models;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Attribute implements Serializable {
|
||||
int id;
|
||||
private String name;
|
||||
private String slug;
|
||||
private String type;
|
||||
private int position;
|
||||
private boolean visible;
|
||||
private boolean variation;
|
||||
@ -70,4 +69,11 @@ public class Attribute implements Serializable {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user