Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
meser
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Suryono
meser
Commits
07483e25
Commit
07483e25
authored
Aug 28, 2020
by
iman Fauzi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new
parent
d720eb45
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
45 deletions
+33
-45
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+4
-6
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+8
-4
CartAdapter.java
...rc/main/java/com/yono/messeripos/adapter/CartAdapter.java
+2
-1
fade_out.xml
app/src/main/res/anim/fade_out.xml
+7
-0
activity_cart.xml
app/src/main/res/layout/activity_cart.xml
+0
-25
activity_main.xml
app/src/main/res/layout/activity_main.xml
+5
-5
item_cart.xml
app/src/main/res/layout/item_cart.xml
+1
-0
item_list.xml
app/src/main/res/layout/item_list.xml
+4
-1
update.xml
app/src/main/res/menu/update.xml
+2
-3
No files found.
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
07483e25
...
...
@@ -12,6 +12,8 @@ import android.util.Log;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
...
...
@@ -142,10 +144,6 @@ public class CartActivity extends AppCompatActivity {
});
// grandToral.setText(utils.convertPrice("Rp. ", utils.grandTotal));
cartAdapter
.
setListener
(
new
CartAdapter
.
CartListener
()
{
@Override
public
void
onDelete
(
ProductCartModels
productCartModels
)
{
...
...
@@ -233,7 +231,7 @@ public class CartActivity extends AppCompatActivity {
}
else
{
new
AlertDialog
.
Builder
(
CartActivity
.
this
)
.
setCancelable
(
false
)
.
setTitle
(
"Save n
we
Order"
)
.
setTitle
(
"Save n
ew
Order"
)
.
setMessage
(
"Erorr save!"
).
show
();
}
}
...
...
@@ -242,7 +240,7 @@ public class CartActivity extends AppCompatActivity {
public
void
onFailure
(
Call
<
DataResponse
<
PaymentsModels
>>
call
,
Throwable
t
)
{
new
AlertDialog
.
Builder
(
CartActivity
.
this
)
.
setCancelable
(
false
)
.
setTitle
(
"Save n
we
Order"
)
.
setTitle
(
"Save n
ew
Order"
)
.
setMessage
(
"Add new order failed, try again!"
).
show
();
}
});
...
...
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
07483e25
...
...
@@ -31,6 +31,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
com.google.android.material.appbar.MaterialToolbar
;
import
com.google.android.material.button.MaterialButton
;
import
com.google.android.material.snackbar.Snackbar
;
import
com.google.gson.Gson
;
import
com.yono.messeripos.adapter.CategoryAdapter
;
...
...
@@ -73,7 +74,7 @@ public class MainActivity extends AppCompatActivity {
public
static
ArrayList
<
ProductModels
>
productModelsArrayList
=
new
ArrayList
<>();
public
static
final
String
DATA_PRODUCT
=
"DATA_PRODUCT"
;
ProgressDialog
progressDialog
;
public
static
Boolean
cartOpen
;
MaterialButton
btnAddCart
;
@SuppressLint
(
"LongLogTag"
)
@Override
...
...
@@ -87,6 +88,8 @@ public class MainActivity extends AppCompatActivity {
// binding.appBarUpdate.setVisibility(View.GONE);
showLoading
(
true
);
btnAddCart
=
findViewById
(
R
.
id
.
materialBtnAddCart
);
categoryAdapter
=
new
CategoryAdapter
();
productAdapter
=
new
ProductAdapter
();
mainViewModelsCart
=
new
ViewModelProvider
(
MainActivity
.
this
).
get
(
MainViewModelsCart
.
class
);
...
...
@@ -223,11 +226,9 @@ public class MainActivity extends AppCompatActivity {
}
private
void
mainViewModelsGetProduct
()
{
progressDialog
.
show
();
mainViewModels
.
getProduct
().
observe
(
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>()
{
@Override
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>
listDataResponse
)
{
progressDialog
.
dismiss
();
if
(
listDataResponse
.
getData
().
size
()
!=
0
)
{
List
<
ProductModels
<
CategoryModels
>>
productModels
=
listDataResponse
.
getData
();
productModelsArrayList
.
clear
();
...
...
@@ -262,10 +263,12 @@ public class MainActivity extends AppCompatActivity {
@Override
public
void
onDelete
(
ProductModels
product
,
int
position
)
{
progressDialog
.
show
();
ProductService
productService
=
client
.
Client
(
ProductService
.
class
);
productService
.
deleteProducts
(
product
.
getIdProduct
()).
enqueue
(
new
Callback
<
DataResponse
<
ProductModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
ProductModels
>>
call
,
Response
<
DataResponse
<
ProductModels
>>
response
)
{
progressDialog
.
dismiss
();
productModelsArrayList
.
remove
(
position
);
binding
.
rvProduct
.
removeViewAt
(
position
);
productAdapter
.
notifyItemRemoved
(
position
);
...
...
@@ -413,13 +416,14 @@ public class MainActivity extends AppCompatActivity {
@Override
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
getMenuInflater
().
inflate
(
R
.
menu
.
update
,
menu
);
return
true
;
}
@Override
public
boolean
onOptionsItemSelected
(
@NonNull
MenuItem
item
)
{
int
id
=
item
.
getItemId
();
if
(
id
==
R
.
id
.
menu_
cart
){
if
(
id
==
R
.
id
.
menu_
update
){
startActivity
(
new
Intent
(
MainActivity
.
this
,
MainActivity
.
class
));
finish
();
}
...
...
app/src/main/java/com/yono/messeripos/adapter/CartAdapter.java
View file @
07483e25
...
...
@@ -98,7 +98,8 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
* */
subtotal
=
cartModels
.
getPrice_orders
()
*
cartModels
.
getQuantity_orders
();
utils
.
grandTotal
=
utils
.
grandTotal
+
(
cartModels
.
getPrice_orders
()
*
cartModels
.
getQuantity_orders
());
Log
.
d
(
"TAG"
,
"bindData: "
+
binding
.
getSubTotal
());
utils
.
grandTotal
=
(
cartModels
.
getPrice_orders
()
*
cartModels
.
getQuantity_orders
());
Log
.
i
(
"Grand Total"
,
"bindData: "
+
utils
.
grandTotal
);
CartActivity
.
grandToral
.
setText
(
utils
.
convertPrice
(
"Rp. "
,
utils
.
grandTotal
));
...
...
app/src/main/res/anim/fade_out.xml
0 → 100644
View file @
07483e25
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<translate
android:fromYDelta=
"0%"
android:toYDelta=
"100%"
android:duration=
"@android:integer/config_mediumAnimTime"
/>
</set>
\ No newline at end of file
app/src/main/res/layout/activity_cart.xml
View file @
07483e25
...
...
@@ -54,31 +54,6 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvCheckout"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"15dp"
android:fontFamily=
"@font/roboto"
android:text=
"Total"
android:textColor=
"#000"
android:textFontWeight=
"600"
android:textSize=
"24sp"
app:layout_constraintBottom_toTopOf=
"@+id/btSave"
app:layout_constraintStart_toStartOf=
"parent"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvHarga"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Rp. 600"
android:textSize=
"24sp"
android:textColor=
"#000"
android:textFontWeight=
"600"
android:layout_marginEnd=
"15dp"
app:layout_constraintBottom_toTopOf=
"@id/btCheckout"
app:layout_constraintEnd_toEndOf=
"parent"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btSave"
android:layout_width=
"0dp"
...
...
app/src/main/res/layout/activity_main.xml
View file @
07483e25
...
...
@@ -55,17 +55,17 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
tools:listitem=
"@layout/item_category"
android:layout_below=
"@id/topBar"
android:layout_above=
"@id/imgEmpty"
/>
android:layout_below=
"@id/topBar"
/>
<ImageView
android:id=
"@+id/imgEmpty"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_content
"
android:layout_height=
"
0dp
"
android:visibility=
"gone"
android:src=
"@drawable/no"
android:layout_below=
"@id/topBar"
android:foregroundGravity=
"center"
/>
android:layout_alignParentBottom=
"true"
android:layout_below=
"@id/rvCategory"
/>
<ProgressBar
android:id=
"@+id/pbLoading"
...
...
app/src/main/res/layout/item_cart.xml
View file @
07483e25
...
...
@@ -29,6 +29,7 @@
android:layout_margin=
"12dp"
>
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/cvCart"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
tools:ignore=
"MissingConstraints"
>
...
...
app/src/main/res/layout/item_list.xml
View file @
07483e25
...
...
@@ -23,7 +23,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"
300dp
"
android:layout_height=
"
wrap_content
"
android:layout_marginHorizontal=
"5dp"
android:layout_marginVertical=
"10dp"
>
...
...
@@ -52,6 +52,7 @@
android:id=
"@+id/btnDelete"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_margin=
"10dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
android:src=
"@drawable/ic_baseline_delete_24"
/>
...
...
@@ -60,6 +61,7 @@
android:id=
"@+id/btnEdit"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_margin=
"10dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
android:src=
"@drawable/ic_baseline_edit_24"
/>
...
...
@@ -121,6 +123,7 @@
android:layout_marginStart=
"10dp"
android:layout_marginEnd=
"10dp"
android:text=
"Add To Cart"
app:layout_constraintTop_toBottomOf=
"@id/price"
app:layout_constraintBottom_toBottomOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
...
...
app/src/main/res/menu/update.xml
View file @
07483e25
...
...
@@ -2,9 +2,8 @@
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/menu_
cart
"
android:id=
"@+id/menu_
update
"
app:showAsAction=
"always"
android:icon=
"@drawable/ic_baseline_shopping_cart_24"
android:actionLayout=
"@layout/custome_action_badge"
android:icon=
"@drawable/ic_baseline_done_24"
android:title=
"Cart"
/>
</menu>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment