Added filter draw on sample app
@ -58,6 +58,7 @@ dependencies {
|
||||
|
||||
implementation 'com.squareup.picasso:picasso:2.5.2'
|
||||
|
||||
implementation 'com.android.support:support-v4:28.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
|
||||
@ -12,6 +12,11 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.product.NavigatioDrawerActivity"
|
||||
android:label="@string/title_activity_navigatio_drawer"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.product.ProductActivity"
|
||||
android:label="@string/title_activity_product"
|
||||
|
||||
@ -5,6 +5,7 @@ import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import me.gilo.wc.ui.MenuActivity
|
||||
import me.gilo.wc.ui.product.ShopActivity
|
||||
import me.gilo.woodroid.Woocommerce
|
||||
import me.gilo.woodroid.models.Coupon
|
||||
import me.gilo.woodroid.models.Product
|
||||
@ -21,36 +22,8 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
startActivity(Intent(baseContext, MenuActivity::class.java));
|
||||
startActivity(Intent(baseContext, ShopActivity::class.java));
|
||||
finish()
|
||||
|
||||
}
|
||||
|
||||
// private fun coupons() {
|
||||
// val woocommerce = Woocommerce.Builder()
|
||||
// .setSiteUrl("http://157.230.131.179")
|
||||
// .setApiVersion("2")
|
||||
// .setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
// .setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
// .build()
|
||||
//
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("Products")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
//
|
||||
// woocommerce.Coupon().coupons().enqueue(object : Callback<List<Coupon>> {
|
||||
// override fun onResponse(call: Call<List<Coupon>>, response: Response<List<Coupon>>) {
|
||||
// val coupons = response.body()
|
||||
// for (coupon in coupons!!) {
|
||||
// tvText.append(coupon.description + "\n")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(call: Call<List<Coupon>>, t: Throwable) {
|
||||
//
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
}
|
||||
|
||||
26
app/src/main/java/me/gilo/wc/repo/OrderRepository.java
Normal file
@ -0,0 +1,26 @@
|
||||
package me.gilo.wc.repo;
|
||||
|
||||
|
||||
import me.gilo.wc.common.WooLiveData;
|
||||
import me.gilo.woodroid.models.Order;
|
||||
import me.gilo.woodroid.models.Product;
|
||||
import me.gilo.woodroid.models.filters.ProductFilter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
public class OrderRepository extends WoocommerceRepository {
|
||||
|
||||
@Inject
|
||||
public OrderRepository() {
|
||||
|
||||
}
|
||||
|
||||
public WooLiveData<Order> addToCart(int productId) {
|
||||
final WooLiveData<Order> callBack = new WooLiveData();
|
||||
|
||||
woocommerce.OrderRepository().addToCart(productId).enqueue(callBack);
|
||||
return callBack;
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package me.gilo.wc.repo;
|
||||
|
||||
import me.gilo.wc.common.WooLiveData;
|
||||
import me.gilo.woodroid.models.Product;
|
||||
import me.gilo.woodroid.models.filters.ProductFilter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
@ -21,6 +22,13 @@ public class ProductRepository extends WoocommerceRepository {
|
||||
return callBack;
|
||||
}
|
||||
|
||||
public WooLiveData<List<Product>> products(ProductFilter productFilter) {
|
||||
final WooLiveData<List<Product>> callBack = new WooLiveData();
|
||||
|
||||
woocommerce.ProductRepository().products(productFilter).enqueue(callBack);
|
||||
return callBack;
|
||||
}
|
||||
|
||||
|
||||
public WooLiveData<Product> product(int productId) {
|
||||
final WooLiveData<Product> callBack = new WooLiveData();
|
||||
|
||||
@ -41,6 +41,33 @@ class ProductActivity : BaseActivity() {
|
||||
product(productId)
|
||||
}
|
||||
|
||||
fab.setOnClickListener{addToCart(productId)}
|
||||
|
||||
}
|
||||
|
||||
private fun addToCart(productId: Int) {
|
||||
viewModel.addToCart(productId).observe(this, android.arch.lifecycle.Observer { response ->
|
||||
when (response!!.status()) {
|
||||
Status.LOADING -> {
|
||||
|
||||
}
|
||||
|
||||
Status.SUCCESS -> {
|
||||
val order = response.data()
|
||||
|
||||
|
||||
}
|
||||
|
||||
Status.ERROR -> {
|
||||
|
||||
}
|
||||
|
||||
Status.EMPTY -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
private fun product(productId : Int) {
|
||||
|
||||
@ -5,10 +5,13 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v4.view.GravityCompat
|
||||
import android.support.v7.app.ActionBarDrawerToggle
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.GridLayoutManager
|
||||
import android.support.v7.widget.SearchView
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper
|
||||
import me.gilo.wc.R
|
||||
@ -24,10 +27,14 @@ import me.gilo.woodroid.models.Product
|
||||
import org.json.JSONObject
|
||||
import java.util.ArrayList
|
||||
|
||||
|
||||
|
||||
|
||||
class ProductSearchActivity : BaseActivity() {
|
||||
|
||||
lateinit var adapter: ProductAdapter
|
||||
lateinit var products: ArrayList<Product>
|
||||
lateinit var toggle: ActionBarDrawerToggle
|
||||
|
||||
lateinit var viewModel: ProductViewModel
|
||||
val TAG = this::getLocalClassName
|
||||
@ -55,6 +62,7 @@ class ProductSearchActivity : BaseActivity() {
|
||||
rvShop.adapter = adapter
|
||||
|
||||
handleIntent(intent)
|
||||
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
@ -110,6 +118,8 @@ class ProductSearchActivity : BaseActivity() {
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private lateinit var progressDialog: ProgressDialogFragment
|
||||
|
||||
@ -2,13 +2,16 @@ package me.gilo.wc.ui.product
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.support.v4.view.GravityCompat
|
||||
import android.support.v7.widget.GridLayoutManager
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.Filter
|
||||
import android.widget.Toast
|
||||
import com.miguelcatalan.materialsearchview.MaterialSearchView
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper
|
||||
import kotlinx.android.synthetic.main.activity_shop.*
|
||||
import kotlinx.android.synthetic.main.content_shop.*
|
||||
import kotlinx.android.synthetic.main.drawer_filter.*
|
||||
import me.gilo.wc.R
|
||||
import me.gilo.wc.adapter.ProductAdapter
|
||||
import me.gilo.wc.common.BaseActivity
|
||||
@ -16,18 +19,16 @@ import me.gilo.wc.common.Status
|
||||
import me.gilo.wc.ui.state.ProgressDialogFragment
|
||||
import me.gilo.wc.viewmodels.ProductViewModel
|
||||
import me.gilo.woodroid.models.Product
|
||||
import org.json.JSONObject
|
||||
import me.gilo.woodroid.models.filters.ProductFilter
|
||||
import java.util.*
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
|
||||
|
||||
class ShopActivity : BaseActivity() {
|
||||
|
||||
lateinit var adapter: ProductAdapter
|
||||
lateinit var products: ArrayList<Product>
|
||||
private lateinit var products: ArrayList<Product>
|
||||
|
||||
lateinit var viewModel: ProductViewModel
|
||||
private lateinit var viewModel: ProductViewModel
|
||||
val TAG = this::getLocalClassName
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
@ -54,18 +55,65 @@ class ShopActivity : BaseActivity() {
|
||||
|
||||
products()
|
||||
|
||||
etSearch.addTextChangedListener(object : TextWatcher {
|
||||
bFilter.setOnClickListener{filter()}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable) {}
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||
private fun filter() {
|
||||
val filter = ProductFilter()
|
||||
|
||||
if (etSearch.text.toString().isNotEmpty()){
|
||||
filter.search = etSearch.text.toString()
|
||||
}
|
||||
|
||||
if (etMinPrice.text.toString().isNotEmpty()){
|
||||
filter.min_price = etMinPrice.text.toString()
|
||||
}
|
||||
|
||||
if (etMaxPrice.text.toString().isNotEmpty()){
|
||||
filter.max_price = etMaxPrice.text.toString()
|
||||
}
|
||||
|
||||
if (cbFeatured.isChecked){
|
||||
filter.isFeatured = true
|
||||
}
|
||||
|
||||
if (cbOnSale.isChecked){
|
||||
filter.isOn_sale = true
|
||||
}
|
||||
|
||||
toggleDrawer()
|
||||
|
||||
products(filter)
|
||||
}
|
||||
|
||||
private fun products(filter: ProductFilter) {
|
||||
viewModel.products(filter).observe(this, android.arch.lifecycle.Observer { response ->
|
||||
when (response!!.status()) {
|
||||
Status.LOADING -> {
|
||||
}
|
||||
|
||||
Status.SUCCESS -> {
|
||||
products.clear()
|
||||
|
||||
val productsResponse = response.data()
|
||||
for (product in productsResponse) {
|
||||
products.add(product)
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged()
|
||||
|
||||
}
|
||||
|
||||
Status.ERROR -> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
Status.EMPTY -> {
|
||||
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
if (s.isNotEmpty()) {
|
||||
search(s.toString())
|
||||
}else{
|
||||
products()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@ -138,6 +186,33 @@ class ShopActivity : BaseActivity() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_filter -> {
|
||||
toggleDrawer()
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_search -> {
|
||||
toggleDrawer()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toast(text: String) {
|
||||
Toast.makeText(baseContext, text, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
private fun toggleDrawer() {
|
||||
if (drawer_layout.isDrawerOpen(GravityCompat.END)) {
|
||||
drawer_layout.closeDrawer(GravityCompat.END)
|
||||
} else {
|
||||
drawer_layout.openDrawer(GravityCompat.END)
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var progressDialog: ProgressDialogFragment
|
||||
|
||||
fun showLoading(title: String, message: String) {
|
||||
|
||||
@ -2,8 +2,11 @@ package me.gilo.wc.viewmodels;
|
||||
|
||||
import android.arch.lifecycle.ViewModel;
|
||||
import me.gilo.wc.common.WooLiveData;
|
||||
import me.gilo.wc.repo.OrderRepository;
|
||||
import me.gilo.wc.repo.ProductRepository;
|
||||
import me.gilo.woodroid.models.Order;
|
||||
import me.gilo.woodroid.models.Product;
|
||||
import me.gilo.woodroid.models.filters.ProductFilter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
@ -11,16 +14,26 @@ import java.util.List;
|
||||
|
||||
public final class ProductViewModel extends ViewModel {
|
||||
private final ProductRepository productRepository;
|
||||
private final OrderRepository orderRepository;
|
||||
|
||||
@Inject
|
||||
ProductViewModel(ProductRepository productRepository) {
|
||||
ProductViewModel(ProductRepository productRepository, OrderRepository orderRepository) {
|
||||
this.productRepository = productRepository;
|
||||
this.orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
public WooLiveData<List<Product>> products() {
|
||||
return productRepository.products();
|
||||
}
|
||||
|
||||
public WooLiveData<Order> addToCart(int productId) {
|
||||
return orderRepository.addToCart(productId);
|
||||
}
|
||||
|
||||
public WooLiveData<List<Product>> products(ProductFilter filter) {
|
||||
return productRepository.products(filter);
|
||||
}
|
||||
|
||||
public WooLiveData<Product> product(int productId) {
|
||||
return productRepository.product(productId);
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 351 B |
|
After Width: | Height: | Size: 383 B |
|
After Width: | Height: | Size: 594 B |
|
After Width: | Height: | Size: 627 B |
BIN
app/src/main/res/drawable-hdpi/baseline_search_white_18.png
Normal file
|
After Width: | Height: | Size: 317 B |
BIN
app/src/main/res/drawable-hdpi/baseline_search_white_24.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
app/src/main/res/drawable-hdpi/baseline_search_white_36.png
Normal file
|
After Width: | Height: | Size: 553 B |
BIN
app/src/main/res/drawable-hdpi/baseline_search_white_48.png
Normal file
|
After Width: | Height: | Size: 624 B |
|
After Width: | Height: | Size: 345 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 573 B |
|
After Width: | Height: | Size: 767 B |
|
After Width: | Height: | Size: 262 B |
|
After Width: | Height: | Size: 258 B |
|
After Width: | Height: | Size: 383 B |
|
After Width: | Height: | Size: 453 B |
BIN
app/src/main/res/drawable-mdpi/baseline_search_white_18.png
Normal file
|
After Width: | Height: | Size: 229 B |
BIN
app/src/main/res/drawable-mdpi/baseline_search_white_24.png
Normal file
|
After Width: | Height: | Size: 244 B |
BIN
app/src/main/res/drawable-mdpi/baseline_search_white_36.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
app/src/main/res/drawable-mdpi/baseline_search_white_48.png
Normal file
|
After Width: | Height: | Size: 411 B |
|
After Width: | Height: | Size: 273 B |
|
After Width: | Height: | Size: 329 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 567 B |
12
app/src/main/res/drawable-v21/ic_menu_camera.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable-v21/ic_menu_gallery.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable-v21/ic_menu_send.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable-v21/ic_menu_share.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable-v21/ic_menu_slideshow.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z"/>
|
||||
</vector>
|
||||
|
After Width: | Height: | Size: 383 B |
|
After Width: | Height: | Size: 453 B |
|
After Width: | Height: | Size: 627 B |
|
After Width: | Height: | Size: 844 B |
BIN
app/src/main/res/drawable-xhdpi/baseline_search_white_18.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
app/src/main/res/drawable-xhdpi/baseline_search_white_24.png
Normal file
|
After Width: | Height: | Size: 411 B |
BIN
app/src/main/res/drawable-xhdpi/baseline_search_white_36.png
Normal file
|
After Width: | Height: | Size: 624 B |
BIN
app/src/main/res/drawable-xhdpi/baseline_search_white_48.png
Normal file
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 567 B |
|
After Width: | Height: | Size: 767 B |
|
After Width: | Height: | Size: 909 B |
|
After Width: | Height: | Size: 594 B |
|
After Width: | Height: | Size: 627 B |
|
After Width: | Height: | Size: 937 B |
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/baseline_search_white_18.png
Normal file
|
After Width: | Height: | Size: 553 B |
BIN
app/src/main/res/drawable-xxhdpi/baseline_search_white_24.png
Normal file
|
After Width: | Height: | Size: 624 B |
BIN
app/src/main/res/drawable-xxhdpi/baseline_search_white_36.png
Normal file
|
After Width: | Height: | Size: 968 B |
BIN
app/src/main/res/drawable-xxhdpi/baseline_search_white_48.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 573 B |
|
After Width: | Height: | Size: 767 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 627 B |
|
After Width: | Height: | Size: 844 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/baseline_search_white_18.png
Normal file
|
After Width: | Height: | Size: 624 B |
BIN
app/src/main/res/drawable-xxxhdpi/baseline_search_white_24.png
Normal file
|
After Width: | Height: | Size: 822 B |
BIN
app/src/main/res/drawable-xxxhdpi/baseline_search_white_36.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/baseline_search_white_48.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 767 B |
|
After Width: | Height: | Size: 909 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
10
app/src/main/res/drawable/baseline_add_shopping_cart_24.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M11,9h2L13,6h3L16,4h-3L13,1h-2v3L8,4v2h3v3zM7,18c-1.1,0 -1.99,0.9 -1.99,2S5.9,22 7,22s2,-0.9 2,-2 -0.9,-2 -2,-2zM17,18c-1.1,0 -1.99,0.9 -1.99,2s0.89,2 1.99,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM7.17,14.75l0.03,-0.12 0.9,-1.63h7.45c0.75,0 1.41,-0.41 1.75,-1.03l3.86,-7.01L19.42,4h-0.01l-1.1,2 -2.76,5L8.53,11l-0.13,-0.27L6.16,6l-0.95,-2 -0.94,-2L1,2v2h2l3.6,7.59 -1.35,2.45c-0.16,0.28 -0.25,0.61 -0.25,0.96 0,1.1 0.9,2 2,2h12v-2L7.42,15c-0.13,0 -0.25,-0.11 -0.25,-0.25z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/baseline_search_24.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
|
||||
</vector>
|
||||
21
app/src/main/res/drawable/rect_grey_stroke.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<padding
|
||||
android:bottom="8dp"
|
||||
android:top="8dp"
|
||||
/>
|
||||
|
||||
<corners
|
||||
android:radius="2dp"
|
||||
/>
|
||||
|
||||
<solid android:color="#fdfdfd"/>
|
||||
|
||||
<stroke android:color="@color/bg"
|
||||
android:width="1dp"
|
||||
/>
|
||||
|
||||
</shape>
|
||||
9
app/src/main/res/drawable/side_nav_bar.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="135"
|
||||
android:centerColor="#009688"
|
||||
android:endColor="#00695C"
|
||||
android:startColor="#4DB6AC"
|
||||
android:type="linear"/>
|
||||
</shape>
|
||||
@ -29,6 +29,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email"/>
|
||||
android:src="@drawable/baseline_add_shopping_cart_24"
|
||||
android:tint="#ffffff"
|
||||
|
||||
/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@ -1,66 +1,47 @@
|
||||
<?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.product.ShopActivity">
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
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:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.product.ShopActivity"
|
||||
tools:openDrawer="end">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<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
|
||||
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.v7.widget.Toolbar>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:elevation="2dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatEditText
|
||||
android:id="@+id/etSearch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:cursorVisible="true"
|
||||
android:textColorHint="@color/text_black_9"
|
||||
android:textColor="@color/text_black_2"
|
||||
android:hint="Seatch"
|
||||
android:background="@drawable/rect_white"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:textSize="16sp"
|
||||
app:backgroundTint="#ffffff"/>
|
||||
<include layout="@layout/content_shop"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:src="@drawable/baseline_search_white_18dp"
|
||||
android:tint="@color/text_black_9"
|
||||
android:layout_gravity="right|center"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
<include
|
||||
layout="@layout/drawer_filter"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
|
||||
<include layout="@layout/content_shop"/>
|
||||
/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rect_white"
|
||||
android:elevation="2dp"
|
||||
|
||||
174
app/src/main/res/layout/drawer_filter.xml
Normal file
@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bg"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bg"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Search product"
|
||||
android:layout_margin="16dp"
|
||||
android:elevation="1dp"
|
||||
android:id="@+id/etSearch"
|
||||
android:background="@drawable/rect_white"
|
||||
android:padding="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:background="@drawable/rect_white"
|
||||
android:elevation="1dp"
|
||||
android:padding="16dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<TextView
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sort"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginBottom="16dp"
|
||||
tools:ignore="MissingPrefix"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
|
||||
android:background="@drawable/rect_grey_stroke"
|
||||
>
|
||||
|
||||
<Spinner
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:entries="@array/sort"
|
||||
android:id="@+id/sSort"
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:background="@drawable/rect_white"
|
||||
android:elevation="1dp"
|
||||
android:padding="16dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<TextView
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Filter"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginBottom="16dp"
|
||||
tools:ignore="MissingPrefix"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginBottom="16dp"
|
||||
>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Min"
|
||||
android:id="@+id/etMinPrice"
|
||||
android:inputType="numberDecimal"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/rect_grey_stroke"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="-"
|
||||
android:textSize="24sp"
|
||||
android:layout_margin="8dp"
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Max"
|
||||
android:id="@+id/etMaxPrice"
|
||||
android:gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/rect_grey_stroke"
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatCheckBox
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="On Sale"
|
||||
android:id="@+id/cbOnSale"
|
||||
android:padding="4dp"
|
||||
fontPath="@string/font_regular"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/text_black_5"
|
||||
|
||||
/>
|
||||
|
||||
<android.support.v7.widget.AppCompatCheckBox
|
||||
android:id="@+id/cbFeatured"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Featured"
|
||||
android:padding="4dp"
|
||||
fontPath="@string/font_regular"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/text_black_5"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bFilter"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Filter"
|
||||
android:layout_margin="16dp"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:background="@color/colorAccent"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
@ -1,10 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_filter"
|
||||
android:icon="@drawable/baseline_filter_list_24"
|
||||
android:orderInCategory="100"
|
||||
android:title="Filter"
|
||||
android:iconTint="#ffffff"
|
||||
app:showAsAction="always"/>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_filter"
|
||||
android:icon="@drawable/baseline_filter_list_24"
|
||||
android:orderInCategory="100"
|
||||
android:title="Filter"
|
||||
android:iconTint="#ffffff"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_sort"
|
||||
android:icon="@drawable/baseline_sort_by_alpha_24"
|
||||
android:orderInCategory="100"
|
||||
android:title="Sort"
|
||||
android:iconTint="#ffffff"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search"
|
||||
android:icon="@drawable/baseline_search_white_24"
|
||||
android:orderInCategory="100"
|
||||
android:title="Search"
|
||||
android:iconTint="#ffffff"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
|
||||
|
||||
</menu>
|
||||
@ -1,3 +1,8 @@
|
||||
<resources>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="nav_header_vertical_spacing">8dp</dimen>
|
||||
<dimen name="nav_header_height">176dp</dimen>
|
||||
</resources>
|
||||
|
||||
8
app/src/main/res/values/drawables.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
|
||||
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
|
||||
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
|
||||
<item name="ic_menu_manage" type="drawable">@android:drawable/ic_menu_manage</item>
|
||||
<item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item>
|
||||
<item name="ic_menu_send" type="drawable">@android:drawable/ic_menu_send</item>
|
||||
</resources>
|
||||
@ -14,5 +14,19 @@
|
||||
<string name="search_hint">Search product</string>
|
||||
<string name="title_activity_product_search">ProductSearchActivity</string>
|
||||
<string name="title_activity_product">ProductActivity</string>
|
||||
<string name="title_activity_navigatio_drawer">NavigatioDrawerActivity</string>
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="nav_header_title">Android Studio</string>
|
||||
<string name="nav_header_subtitle">android.studio@android.com</string>
|
||||
<string name="nav_header_desc">Navigation header</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
|
||||
<string-array name="sort">
|
||||
<item>Popularity</item>
|
||||
<item>Date added</item>
|
||||
<item>Price lowest first</item>
|
||||
<item>Price highest first</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -6,6 +6,9 @@
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
<item name="android:spinnerDropDownItemStyle">@style/SpinnerItemStyle</item>
|
||||
<item name="android:spinnerItemStyle">@style/SpinnerItemStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
@ -17,4 +20,10 @@
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
|
||||
|
||||
<style name="SpinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
|
||||
<item name="android:textColor">@color/text_black_9</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -7,8 +7,7 @@ import java.util.List;
|
||||
|
||||
|
||||
public class LineItem {
|
||||
@SerializedName("product_id")
|
||||
public int id;
|
||||
|
||||
public String subtotal;
|
||||
@SerializedName("subtotal_tax")
|
||||
public String subtotalTax;
|
||||
@ -18,7 +17,10 @@ public class LineItem {
|
||||
public int quantity;
|
||||
public Object taxClass;
|
||||
public String name;
|
||||
|
||||
@SerializedName("product_id")
|
||||
public int productId;
|
||||
|
||||
public String sku;
|
||||
public String variations;
|
||||
public List<Metum> meta = new ArrayList<Metum>();
|
||||
@ -31,14 +33,6 @@ public class LineItem {
|
||||
this.variations = variations;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSubtotal() {
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
@ -261,6 +261,11 @@ public class Order {
|
||||
this.lineItems = lineItems;
|
||||
}
|
||||
|
||||
public void addLineItem(LineItem lineItem) {
|
||||
lineItems.add(lineItem);
|
||||
|
||||
}
|
||||
|
||||
public List<ShippingLine> getShippingLines() {
|
||||
return shippingLines;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package me.gilo.woodroid.repo;
|
||||
|
||||
import me.gilo.woodroid.data.api.OrderAPI;
|
||||
import me.gilo.woodroid.models.LineItem;
|
||||
import me.gilo.woodroid.models.Order;
|
||||
import me.gilo.woodroid.models.OrderNote;
|
||||
import me.gilo.woodroid.models.filters.OrderFilter;
|
||||
@ -8,6 +9,8 @@ import me.gilo.woodroid.repo.order.OrderNoteRepository;
|
||||
import me.gilo.woodroid.repo.order.RefundRepository;
|
||||
import retrofit2.Call;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OrderRepository extends WooRepository {
|
||||
@ -29,6 +32,18 @@ public class OrderRepository extends WooRepository {
|
||||
return apiService.create(order);
|
||||
}
|
||||
|
||||
public Call<Order> addToCart(int productId) {
|
||||
Order order = new Order();
|
||||
|
||||
LineItem lineItem = new LineItem();
|
||||
lineItem.setProductId(productId);
|
||||
lineItem.setQuantity(1);
|
||||
|
||||
order.addLineItem(lineItem);
|
||||
|
||||
return apiService.create(order);
|
||||
}
|
||||
|
||||
public Call<Order> order(int id) {
|
||||
return apiService.view(id);
|
||||
}
|
||||
|
||||