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
3e0b4323
Commit
3e0b4323
authored
Aug 26, 2020
by
Muhammad Suryono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
928de6d8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
60 deletions
+37
-60
LoginActivity.java
app/src/main/java/com/yono/messeripos/LoginActivity.java
+1
-0
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+26
-50
CartAdapter.java
...rc/main/java/com/yono/messeripos/adapter/CartAdapter.java
+1
-0
CategoryServise.java
...java/com/yono/messeripos/api/service/CategoryServise.java
+2
-2
MainViewModels.java
.../main/java/com/yono/messeripos/models/MainViewModels.java
+7
-7
item_cart.xml
app/src/main/res/layout/item_cart.xml
+0
-1
No files found.
app/src/main/java/com/yono/messeripos/LoginActivity.java
View file @
3e0b4323
...
...
@@ -82,6 +82,7 @@ public class LoginActivity extends AppCompatActivity {
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putBoolean
(
SplashScreen
.
SESSION
,
true
);
editor
.
commit
();
startActivity
(
new
Intent
(
LoginActivity
.
this
,
MainActivity
.
class
));
progressBar
.
setVisibility
(
View
.
GONE
);
...
...
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
3e0b4323
...
...
@@ -6,19 +6,16 @@ import android.content.Intent;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.RequiresApi
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.databinding.DataBindingUtil
;
...
...
@@ -29,30 +26,20 @@ 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.yono.messeripos.adapter.CartAdapter
;
import
com.yono.messeripos.adapter.ProductAdapter
;
import
com.yono.messeripos.databinding.ActivityMainBinding
;
import
com.yono.messeripos.models.MainViewModels
;
import
com.yono.messeripos.models.MainViewModelsCart
;
import
com.yono.messeripos.models.ProductCartModels
;
import
com.yono.messeripos.models.ProductModels
;
import
com.google.gson.Gson
;
import
com.yono.messeripos.adapter.CartAdapter
;
import
com.yono.messeripos.adapter.CategoryAdapter
;
import
com.yono.messeripos.adapter.ProductAdapter
;
import
com.yono.messeripos.databinding.ActivityMainBinding
;
import
com.yono.messeripos.databinding.ItemListBinding
;
import
com.yono.messeripos.models.CategoryModels
;
import
com.yono.messeripos.models.MainViewModels
;
import
com.yono.messeripos.models.MainViewModelsCart
;
import
com.yono.messeripos.models.ProductCartModels
;
import
com.yono.messeripos.models.ProductModels
;
import
com.yono.messeripos.response.DataResponse
;
import
java.lang.reflect.Array
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
public
class
MainActivity
extends
AppCompatActivity
{
MaterialToolbar
toolbar
;
...
...
@@ -238,44 +225,33 @@ public class MainActivity extends AppCompatActivity {
ProgressDialog
progressDialog
=
new
ProgressDialog
(
MainActivity
.
this
);
progressDialog
.
setMessage
(
"Loading..."
);
progressDialog
.
show
();
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
mainViewModels
.
getProductByCategory
(
categoryModels
.
getIdCategory
()).
observe
(
MainActivity
.
this
,
new
Observer
<
List
<
CategoryModels
<
List
<
ProductModels
>>>>()
{
mainViewModels
.
getProductByCategory
(
categoryModels
.
getIdCategory
()).
observe
(
MainActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
>>>()
{
@Override
public
void
onChanged
(
List
<
CategoryModels
<
List
<
ProductModels
>>>
categoryModels
)
{
ProductModels
productModels
=
new
ProductModels
();
for
(
CategoryModels
<
List
<
ProductModels
>>
pd
:
categoryModels
){
for
(
ProductModels
ps
:
pd
.
getProductCategory
()){
Log
.
i
(
"eeee"
,
"onChanged: "
+
ps
.
getProductName
());
productModels
.
setIdProduct
(
ps
.
getIdProduct
());
productModels
.
setProductName
(
ps
.
getProductName
());
productModels
.
setStockProduct
(
ps
.
getStockProduct
());
productModels
.
setPriceProduct
(
ps
.
getPriceProduct
());
productModels
.
setImageProduct
(
ps
.
getImageProduct
());
}
Log
.
i
(
"ddddd"
,
"onChanged: "
+
pd
.
getProductCategory
());
}
// List<ProductModels> pdf = (List<ProductModels>) productModels;
ArrayList
<
ProductModels
>
pdModel
=
new
ArrayList
<>();
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
>>
listDataResponse
)
{
if
(
listDataResponse
!=
null
)
{
List
<
ProductModels
>
productModels
=
listDataResponse
.
getData
();
ArrayList
<
ProductModels
>
productModelsArrayList
=
new
ArrayList
<>();
productAdapter
.
setProduct
(
MainActivity
.
this
,
pdModel
);
productAdapter
.
notifyDataSetChanged
();
showLoading
(
false
);
productModelsArrayList
.
addAll
(
productModels
);
progressDialog
.
dismiss
();
if
(
pdModel
.
isEmpty
()){
showLoading
(
false
);
if
(
productModelsArrayList
.
isEmpty
())
{
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
binding
.
imgEmpty
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
binding
.
imgEmpty
.
bringToFront
();
}
else
{
binding
.
rvProduct
.
setVisibility
(
View
.
VISIBLE
);
binding
.
imgEmpty
.
setVisibility
(
View
.
GONE
);
productAdapter
.
setProduct
(
MainActivity
.
this
,
productModelsArrayList
);
binding
.
rvProduct
.
setLayoutManager
(
new
GridLayoutManager
(
MainActivity
.
this
,
2
));
binding
.
rvProduct
.
setAdapter
(
productAdapter
);
productAdapter
.
notifyDataSetChanged
();
}
// binding.rvProduct.setLayoutManager(new GridLayoutManager(MainActivity.this, 2));
// binding.rvProduct.setAdapter(productAdapter);
}
}
);
}
);
}
});
}
...
...
app/src/main/java/com/yono/messeripos/adapter/CartAdapter.java
View file @
3e0b4323
...
...
@@ -93,6 +93,7 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
subtotal
=
cartModels
.
getPrice_orders
()
*
cartModels
.
getQuantity_orders
();
binding
.
setSubTotal
(
utils
.
convertPrice
(
"Rp. "
,
subtotal
));
binding
.
etQty
.
setText
(
Long
.
toString
(
cartModels
.
getQuantity_orders
()));
}
}
...
...
app/src/main/java/com/yono/messeripos/api/service/CategoryServise.java
View file @
3e0b4323
...
...
@@ -16,6 +16,6 @@ public interface CategoryServise {
@GET
(
ApiHelper
.
VERSI_API_1
+
"categories"
)
Call
<
DataResponse
<
List
<
CategoryModels
>>>
getCategory
();
@GET
(
ApiHelper
.
VERSI_API_1
+
"
categories-join
/{id}"
)
Call
<
DataResponse
<
List
<
CategoryModels
<
List
<
ProductModels
>>
>>>
getCategoryById
(
@Path
(
"id"
)
int
id
);
@GET
(
ApiHelper
.
VERSI_API_1
+
"
products-category
/{id}"
)
Call
<
DataResponse
<
List
<
ProductModels
>>>
getCategoryById
(
@Path
(
"id"
)
int
id
);
}
app/src/main/java/com/yono/messeripos/models/MainViewModels.java
View file @
3e0b4323
...
...
@@ -22,7 +22,7 @@ import retrofit2.Response;
public
class
MainViewModels
extends
ViewModel
{
MutableLiveData
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
productList
;
MutableLiveData
<
List
<
CategoryModels
<
List
<
ProductModels
>
>>>
productByCategory
;
MutableLiveData
<
DataResponse
<
List
<
ProductModels
>>>
productByCategory
;
MutableLiveData
<
DataResponse
<
List
<
CategoryModels
>>>
categoryList
;
MutableLiveData
<
DataResponse
<
UsersModels
>>
usersLogin
;
...
...
@@ -44,7 +44,7 @@ public class MainViewModels extends ViewModel {
return
categoryList
;
}
public
LiveData
<
List
<
CategoryModels
<
List
<
ProductModels
>
>>>
getProductByCategory
(
int
id
){
public
LiveData
<
DataResponse
<
List
<
ProductModels
>>>
getProductByCategory
(
int
id
){
getDataProductByCategory
(
id
);
return
productByCategory
;
}
...
...
@@ -52,19 +52,19 @@ public class MainViewModels extends ViewModel {
private
void
getDataProductByCategory
(
int
id
)
{
CategoryServise
categoryServise
=
client
.
Client
(
CategoryServise
.
class
);
categoryServise
.
getCategoryById
(
id
).
enqueue
(
new
Callback
<
DataResponse
<
List
<
CategoryModels
<
List
<
ProductModels
>>
>>>()
{
categoryServise
.
getCategoryById
(
id
).
enqueue
(
new
Callback
<
DataResponse
<
List
<
ProductModels
>>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
List
<
CategoryModels
<
List
<
ProductModels
>>
>>>
call
,
Response
<
DataResponse
<
List
<
CategoryModels
<
List
<
ProductModels
>>
>>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
List
<
ProductModels
>>>
call
,
Response
<
DataResponse
<
List
<
ProductModels
>>>
response
)
{
String
js
=
new
Gson
().
toJson
(
response
.
body
());
Log
.
i
(
"Get data by category"
,
"onResponse: "
+
js
);
if
(
response
!=
null
){
productByCategory
.
setValue
(
response
.
body
()
.
getData
()
);
productByCategory
.
setValue
(
response
.
body
());
}
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
List
<
CategoryModels
<
List
<
ProductModels
>>
>>>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
DataResponse
<
List
<
ProductModels
>>>
call
,
Throwable
t
)
{
Log
.
e
(
"Error!"
,
"onFailure: "
,
t
);
}
});
...
...
app/src/main/res/layout/item_cart.xml
View file @
3e0b4323
...
...
@@ -119,7 +119,6 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:enabled=
"false"
android:text=
"1"
android:textColor=
"#333"
/>
</com.google.android.material.textfield.TextInputLayout>
...
...
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