Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
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
abc3118f
Commit
abc3118f
authored
Aug 27, 2020
by
iman Fauzi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into cart
parents
0e31f524
a4b049bd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
304 additions
and
96 deletions
+304
-96
Project.xml
.idea/codeStyles/Project.xml
+24
-0
build.gradle
app/build.gradle
+1
-0
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+5
-2
FormProductActivity.java
...rc/main/java/com/yono/messeripos/FormProductActivity.java
+76
-11
HistoryActivity.java
app/src/main/java/com/yono/messeripos/HistoryActivity.java
+15
-0
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+63
-51
ProductAdapter.java
...main/java/com/yono/messeripos/adapter/ProductAdapter.java
+2
-0
ApiHelper.java
app/src/main/java/com/yono/messeripos/api/ApiHelper.java
+40
-1
ProductService.java
.../java/com/yono/messeripos/api/service/ProductService.java
+25
-7
CartDaos.java
app/src/main/java/com/yono/messeripos/daos/CartDaos.java
+2
-0
MainViewModels.java
.../main/java/com/yono/messeripos/models/MainViewModels.java
+15
-0
MainViewModelsCart.java
...n/java/com/yono/messeripos/models/MainViewModelsCart.java
+4
-0
CartRepositories.java
...va/com/yono/messeripos/repositories/CartRepositories.java
+4
-0
Utils.java
app/src/main/java/com/yono/messeripos/utils/Utils.java
+20
-1
activity_history.xml
app/src/main/res/layout/activity_history.xml
+0
-12
form_product.xml
app/src/main/res/layout/form_product.xml
+6
-10
ms__selector.xml
library/src/main/res/drawable-v21/ms__selector.xml
+1
-1
ms__list_item.xml
library/src/main/res/layout/ms__list_item.xml
+1
-0
No files found.
.idea/codeStyles/Project.xml
View file @
abc3118f
<component
name=
"ProjectCodeStyleConfiguration"
>
<component
name=
"ProjectCodeStyleConfiguration"
>
<code_scheme
name=
"Project"
version=
"173"
>
<code_scheme
name=
"Project"
version=
"173"
>
<DBN-PSQL>
<case-options
enabled=
"true"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
/>
</DBN-PSQL>
<DBN-SQL>
<case-options
enabled=
"true"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
>
<option
name=
"STATEMENT_SPACING"
value=
"one_line"
/>
<option
name=
"CLAUSE_CHOP_DOWN"
value=
"chop_down_if_statement_long"
/>
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<DBN-PSQL>
<case-options
enabled=
"true"
>
<case-options
enabled=
"true"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
...
...
app/build.gradle
View file @
abc3118f
...
@@ -45,6 +45,7 @@ dependencies {
...
@@ -45,6 +45,7 @@ dependencies {
implementation
'com.squareup.retrofit2:converter-gson:2.9.0'
implementation
'com.squareup.retrofit2:converter-gson:2.9.0'
implementation
'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation
'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation
'com.github.bumptech.glide:glide:4.3.1'
implementation
'com.github.bumptech.glide:glide:4.3.1'
implementation
'com.squareup.okhttp3:logging-interceptor:4.2.1'
implementation
project
(
':library'
)
implementation
project
(
':library'
)
def
room_version
=
"2.2.5"
def
room_version
=
"2.2.5"
...
...
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
abc3118f
...
@@ -29,6 +29,8 @@ import com.yono.messeripos.response.OrdersResponse;
...
@@ -29,6 +29,8 @@ import com.yono.messeripos.response.OrdersResponse;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
static
com
.
yono
.
messeripos
.
MainActivity
.
orderId
;
public
class
CartActivity
extends
AppCompatActivity
{
public
class
CartActivity
extends
AppCompatActivity
{
CartAdapter
cartAdapter
;
CartAdapter
cartAdapter
;
...
@@ -48,6 +50,7 @@ public class CartActivity extends AppCompatActivity {
...
@@ -48,6 +50,7 @@ public class CartActivity extends AppCompatActivity {
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
sharedPreferences
=
getSharedPreferences
(
SplashScreen
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
sharedPreferences
=
getSharedPreferences
(
SplashScreen
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
Log
.
i
(
"Id Order on acart"
,
"onCreate: "
+
orderId
);
// Toolbars
// Toolbars
MaterialToolbar
toolbars
=
findViewById
(
R
.
id
.
cAppBar
);
MaterialToolbar
toolbars
=
findViewById
(
R
.
id
.
cAppBar
);
setSupportActionBar
(
toolbars
);
setSupportActionBar
(
toolbars
);
...
@@ -68,10 +71,9 @@ public class CartActivity extends AppCompatActivity {
...
@@ -68,10 +71,9 @@ public class CartActivity extends AppCompatActivity {
modelsCart
=
new
ViewModelProvider
(
this
).
get
(
MainViewModelsCart
.
class
);
modelsCart
=
new
ViewModelProvider
(
this
).
get
(
MainViewModelsCart
.
class
);
modelsCart
.
getCart
Product
(
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
modelsCart
.
getCart
ByOrderId
(
orderId
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
@Override
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
if
(
productCartModels
!=
null
)
{
if
(
productCartModels
!=
null
)
{
dataCart
=
productCartModels
;
dataCart
=
productCartModels
;
cartAdapter
.
setCartAdapter
(
CartActivity
.
this
,
productCartModels
);
cartAdapter
.
setCartAdapter
(
CartActivity
.
this
,
productCartModels
);
...
@@ -80,6 +82,7 @@ public class CartActivity extends AppCompatActivity {
...
@@ -80,6 +82,7 @@ public class CartActivity extends AppCompatActivity {
}
}
});
});
cartAdapter
.
setListener
(
new
CartAdapter
.
CartListener
()
{
cartAdapter
.
setListener
(
new
CartAdapter
.
CartListener
()
{
@Override
@Override
public
void
onDelete
(
ProductCartModels
productCartModels
)
{
public
void
onDelete
(
ProductCartModels
productCartModels
)
{
...
...
app/src/main/java/com/yono/messeripos/FormProductActivity.java
View file @
abc3118f
package
com
.
yono
.
messeripos
;
package
com
.
yono
.
messeripos
;
import
android.Manifest
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.app.ProgressDialog
;
import
android.content.CursorLoader
;
import
android.content.CursorLoader
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.database.Cursor
;
...
@@ -13,9 +15,11 @@ import android.os.Environment;
...
@@ -13,9 +15,11 @@ import android.os.Environment;
import
android.os.PersistableBundle
;
import
android.os.PersistableBundle
;
import
android.provider.MediaStore
;
import
android.provider.MediaStore
;
import
android.provider.Settings
;
import
android.provider.Settings
;
import
android.util.Base64
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.Window
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.ArrayAdapter
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -26,25 +30,50 @@ import androidx.appcompat.app.AppCompatActivity;
...
@@ -26,25 +30,50 @@ import androidx.appcompat.app.AppCompatActivity;
import
androidx.core.content.ContextCompat
;
import
androidx.core.content.ContextCompat
;
import
androidx.core.content.FileProvider
;
import
androidx.core.content.FileProvider
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProviders
;
import
com.google.android.material.appbar.MaterialToolbar
;
import
com.google.android.material.appbar.MaterialToolbar
;
import
com.jaredrummler.materialspinner.MaterialSpinner
;
import
com.jaredrummler.materialspinner.MaterialSpinner
;
import
com.yono.messeripos.api.client.Client
;
import
com.yono.messeripos.api.service.ProductService
;
import
com.yono.messeripos.databinding.FormProductBinding
;
import
com.yono.messeripos.databinding.FormProductBinding
;
import
com.yono.messeripos.models.CategoryModels
;
import
com.yono.messeripos.models.MainViewModels
;
import
com.yono.messeripos.models.ProductModels
;
import
com.yono.messeripos.models.ProductModels
;
import
com.yono.messeripos.response.DataResponse
;
import
com.yono.messeripos.utils.Utils
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.nio.ByteBuffer
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
okhttp3.MediaType
;
import
okhttp3.MultipartBody
;
import
okhttp3.RequestBody
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
import
retrofit2.http.Multipart
;
public
class
FormProductActivity
extends
AppCompatActivity
{
public
class
FormProductActivity
extends
AppCompatActivity
{
FormProductBinding
binding
;
FormProductBinding
binding
;
ProductModels
productModels
;
ProductModels
productModels
;
File
file
;
File
file
;
MainViewModels
mainViewModels
;
MaterialSpinner
spinner
;
List
<
String
>
categoryModels
;
private
static
final
int
REQUEST_IMAGE_CAPTURE
=
1
;
private
static
final
int
REQUEST_IMAGE_CAPTURE
=
1
;
private
static
final
int
REQUEST_PERMISSIONS
=
448
;
private
static
final
int
REQUEST_PERMISSIONS
=
448
;
private
boolean
isUpdate
=
false
;
private
boolean
isUpdate
=
false
;
String
kondisi_spin
;
String
kondisi_spin
;
String
locationPath
=
null
;
private
static
final
String
[]
ANDROID_VERSIONS
=
{
private
static
final
String
[]
ANDROID_VERSIONS
=
{
"Cupcake"
,
"Cupcake"
,
...
@@ -64,6 +93,9 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -64,6 +93,9 @@ public class FormProductActivity extends AppCompatActivity {
private
String
[]
permissions
=
new
String
[]{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
private
String
[]
permissions
=
new
String
[]{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
};
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
};
private
Utils
utils
=
new
Utils
();
ProgressDialog
progressDialog
;
Client
client
=
new
Client
();
@Override
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
@@ -73,6 +105,10 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -73,6 +105,10 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
btnAdd
.
setText
(
"Add New Prooduct"
);
binding
.
btnAdd
.
setText
(
"Add New Prooduct"
);
productModels
=
new
ProductModels
();
productModels
=
new
ProductModels
();
requestPermissions
(
permissions
,
REQUEST_PERMISSIONS
);
requestPermissions
(
permissions
,
REQUEST_PERMISSIONS
);
mainViewModels
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModels
.
class
);
progressDialog
=
new
ProgressDialog
(
FormProductActivity
.
this
);
progressDialog
.
setMessage
(
"Loading..."
);
progressDialog
.
show
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
Window
w
=
getWindow
();
Window
w
=
getWindow
();
...
@@ -90,18 +126,45 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -90,18 +126,45 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
btnAdd
.
setOnClickListener
(
view
->
saveProduct
());
binding
.
btnAdd
.
setOnClickListener
(
view
->
saveProduct
());
//spinner
//spinner
MaterialSpinner
spinner
=
findViewById
(
R
.
id
.
listCategory
);
categoryModels
=
new
ArrayList
<>();
spinner
.
setItems
(
ANDROID_VERSIONS
);
categoryModels
.
add
(
"SELECT CATEGORY"
);
setSpinner
();
}
private
void
setSpinner
()
{
mainViewModels
.
getCategory
().
observe
(
this
,
listDataResponse
->
{
List
<
CategoryModels
>
cate
=
listDataResponse
.
getData
();
for
(
CategoryModels
cd:
cate
){
categoryModels
.
add
(
cd
.
getNameCategory
());
}
// Log.i("Spinner data", "onCreate: "+utils.convertGson(categoryModels));
@SuppressLint
(
"ResourceType"
)
ArrayAdapter
<
String
>
dataAdapter
=
new
ArrayAdapter
<
String
>(
FormProductActivity
.
this
,
R
.
id
.
listCategory
,
categoryModels
);
binding
.
listCategory
.
setAdapter
(
dataAdapter
);
progressDialog
.
dismiss
();
});
}
}
private
void
saveProduct
(){
private
void
saveProduct
(){
productModels
.
setProductName
(
binding
.
etName
.
getText
().
toString
());
productModels
.
setProductName
(
binding
.
etName
.
getText
().
toString
());
// productModels.setPriceProduct(Integer.parseInt(binding.etPrice.getText().toString()));
productModels
.
setPriceProduct
(
Integer
.
parseInt
(
binding
.
etPrice
.
getText
().
toString
()));
// productModels.setStockProduct(Integer.parseInt(binding.etStock.getText().toString()));
productModels
.
setStockProduct
(
Integer
.
parseInt
(
binding
.
etStock
.
getText
().
toString
()));
productModels
.
setCategoryProduct
(
binding
.
listCategory
.
getSelectedIndex
());
Log
.
i
(
"save_path"
,
"saveProduct: "
+
locationPath
);
if
(
locationPath
!=
null
){
File
fileImage
=
new
File
(
locationPath
);
Log
.
i
(
"save"
,
"saveProduct: "
+
locationPath
);
if
(
fileImage
.
exists
()){
progressDialog
.
show
();
// Toast.makeText(this, productModels.getImageProduct()+" "+productModels.getProductName(), Toast.LENGTH_LONG).show();
utils
.
toastMessage
(
FormProductActivity
.
this
,
utils
.
convertGson
(
productModels
));
Toast
.
makeText
(
this
,
productModels
.
getImageProduct
()+
" "
+
productModels
.
getProductName
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
}
}
private
void
openFile
(){
private
void
openFile
(){
...
@@ -148,14 +211,16 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -148,14 +211,16 @@ public class FormProductActivity extends AppCompatActivity {
if
(
requestCode
==
100
&&
resultCode
==
RESULT_OK
&&
data
!=
null
)
{
if
(
requestCode
==
100
&&
resultCode
==
RESULT_OK
&&
data
!=
null
)
{
Uri
selectedImage
=
data
.
getData
();
Uri
selectedImage
=
data
.
getData
();
Log
.
d
(
"Get filepath photo"
,
""
+
getRealPathFromURI
(
selectedImage
));
binding
.
setPhoto
(
getRealPathFromURI
(
selectedImage
));
binding
.
setPhoto
(
getRealPathFromURI
(
selectedImage
));
// }
// if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
locationPath
=
getRealPathFromURI
(
selectedImage
);
// Log.d("Get filepath photo", "" + file.getAbsolutePath());
// binding.setPhoto(file.getAbsolutePath());
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
// productModels.setImageProduct(file.getName());
byte
[]
imageBytes
=
baos
.
toByteArray
();
imageBytes
=
Base64
.
decode
(
utils
.
convertImageBase64File
(
getRealPathFromURI
(
selectedImage
)),
Base64
.
DEFAULT
);
Bitmap
decodeImages
=
BitmapFactory
.
decodeByteArray
(
imageBytes
,
0
,
imageBytes
.
length
);
binding
.
ivProduct
.
setImageBitmap
(
decodeImages
);
productModels
.
setImageProduct
(
utils
.
convertImageBase64File
(
getRealPathFromURI
(
selectedImage
)));
}
}
}
}
...
...
app/src/main/java/com/yono/messeripos/HistoryActivity.java
View file @
abc3118f
...
@@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModelProvider;
...
@@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModelProvider;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.util.Log
;
...
@@ -73,7 +74,21 @@ public class HistoryActivity extends AppCompatActivity {
...
@@ -73,7 +74,21 @@ public class HistoryActivity extends AppCompatActivity {
* PANGGIL ADAPTERNYA KEMUDIAN .setList.....
* PANGGIL ADAPTERNYA KEMUDIAN .setList.....
* SILAHKAN PINDAH KE ACTIVITY SELANJUTNYA PADA ON.....
* SILAHKAN PINDAH KE ACTIVITY SELANJUTNYA PADA ON.....
* */
* */
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
HistoryActivity
.
this
,
RecyclerView
.
VERTICAL
,
false
));
recyclerView
.
setAdapter
(
transactionAdapter
);
}
}
});
});
transactionAdapter
.
setListener
(
new
TransactionAdapter
.
TransactionListener
()
{
@Override
public
void
onShowDetail
(
PaymentsModels
paymentsModels
)
{
//set detail on click card
Intent
intent
=
new
Intent
(
HistoryActivity
.
this
,
PaymentActivity
.
class
);
startActivity
(
intent
);
}
});
}
}
}
}
\ No newline at end of file
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
abc3118f
This diff is collapsed.
Click to expand it.
app/src/main/java/com/yono/messeripos/adapter/ProductAdapter.java
View file @
abc3118f
...
@@ -148,6 +148,8 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
...
@@ -148,6 +148,8 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
MainActivity
.
cartIsEmpty
=
true
;
MainActivity
.
cartIsEmpty
=
true
;
}
}
});
});
binding
.
btnDelete
.
setOnClickListener
(
view
->
listener
.
onDelete
(
products
));
}
}
}
}
}
}
app/src/main/java/com/yono/messeripos/api/ApiHelper.java
View file @
abc3118f
package
com
.
yono
.
messeripos
.
api
;
package
com
.
yono
.
messeripos
.
api
;
import
android.util.Log
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.yono.messeripos.BuildConfig
;
import
java.util.concurrent.TimeUnit
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.logging.HttpLoggingInterceptor
;
import
retrofit2.Retrofit
;
import
retrofit2.Retrofit
;
import
retrofit2.converter.gson.GsonConverterFactory
;
import
retrofit2.converter.gson.GsonConverterFactory
;
...
@@ -9,9 +20,37 @@ public class ApiHelper {
...
@@ -9,9 +20,37 @@ public class ApiHelper {
public
static
final
String
BASE_URL_IMAGE
=
"https://storage.googleapis.com/rest-api-meser.appspot.com/images/"
;
public
static
final
String
BASE_URL_IMAGE
=
"https://storage.googleapis.com/rest-api-meser.appspot.com/images/"
;
public
static
Retrofit
request
(
String
baseUrl
){
public
static
Retrofit
request
(
String
baseUrl
){
OkHttpClient
.
Builder
okHttp
=
new
OkHttpClient
().
newBuilder
();
okHttp
.
retryOnConnectionFailure
(
true
);
okHttp
.
connectTimeout
(
60
,
TimeUnit
.
SECONDS
);
okHttp
.
writeTimeout
(
60
,
TimeUnit
.
SECONDS
);
okHttp
.
readTimeout
(
60
,
TimeUnit
.
SECONDS
);
HttpLoggingInterceptor
interceptor
=
new
HttpLoggingInterceptor
(
s
->
Log
.
e
(
"API-LOG"
,
s
));
interceptor
.
level
(
HttpLoggingInterceptor
.
Level
.
BODY
);
if
(
BuildConfig
.
DEBUG
)
okHttp
.
addInterceptor
(
interceptor
);
okHttp
.
addInterceptor
(
chain
->
{
Request
request
=
chain
.
request
();
Request
newReq
=
request
.
newBuilder
()
.
addHeader
(
"Content-Type"
,
"application/json"
)
.
addHeader
(
"Accept"
,
"application/json"
)
.
addHeader
(
"Accept-Encoding"
,
"identity"
)
.
addHeader
(
"Connection"
,
"close"
)
.
addHeader
(
"Transfer-Encoding"
,
"chunked"
)
.
build
();
return
chain
.
proceed
(
newReq
);
});
OkHttpClient
client
=
okHttp
.
build
();
Retrofit
retrofit
=
new
Retrofit
.
Builder
()
Retrofit
retrofit
=
new
Retrofit
.
Builder
()
.
baseUrl
(
baseUrl
)
.
baseUrl
(
baseUrl
)
.
addConverterFactory
(
GsonConverterFactory
.
create
())
// .client(client)
.
addConverterFactory
(
GsonConverterFactory
.
create
(
new
GsonBuilder
().
setLenient
().
create
()
))
.
build
();
.
build
();
return
retrofit
;
return
retrofit
;
...
...
app/src/main/java/com/yono/messeripos/api/service/ProductService.java
View file @
abc3118f
...
@@ -5,25 +5,43 @@ import com.yono.messeripos.models.CategoryModels;
...
@@ -5,25 +5,43 @@ import com.yono.messeripos.models.CategoryModels;
import
com.yono.messeripos.models.ProductModels
;
import
com.yono.messeripos.models.ProductModels
;
import
com.yono.messeripos.response.DataResponse
;
import
com.yono.messeripos.response.DataResponse
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
okhttp3.MultipartBody
;
import
okhttp3.RequestBody
;
import
okhttp3.RequestBody
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.http.DELETE
;
import
retrofit2.http.GET
;
import
retrofit2.http.GET
;
import
retrofit2.http.Multipart
;
import
retrofit2.http.Multipart
;
import
retrofit2.http.POST
;
import
retrofit2.http.Part
;
import
retrofit2.http.Part
;
import
retrofit2.http.Path
;
public
interface
ProductService
{
public
interface
ProductService
{
@GET
(
ApiHelper
.
VERSI_API_1
+
"product-categories"
)
@GET
(
ApiHelper
.
VERSI_API_1
+
"product-categories"
)
Call
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
getProducts
();
Call
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
getProducts
();
@DELETE
(
ApiHelper
.
VERSI_API_1
+
"product/{id}"
)
Call
<
DataResponse
<
ProductModels
>>
deleteProducts
(
@Path
(
"id"
)
int
id
);
@Multipart
@Multipart
@
GE
T
(
ApiHelper
.
VERSI_API_1
+
"product"
)
@
POS
T
(
ApiHelper
.
VERSI_API_1
+
"product"
)
Call
<
DataResponse
<
ProductModels
>>
postProduct
(
Call
<
HashMap
<
String
,
Object
>>
postProduct
(
@Part
(
"image\"; filename=\"messer_file.jpg\""
)
RequestBody
image
,
@Part
MultipartBody
.
Part
image
,
@Part
RequestBody
name
,
@Part
(
"name"
)
RequestBody
name
,
@Part
RequestBody
price
,
@Part
(
"price"
)
RequestBody
price
,
@Part
RequestBody
stock
,
@Part
(
"stock"
)
RequestBody
stock
,
@Part
RequestBody
category_id
@Part
(
"category_id"
)
RequestBody
category_id
);
);
@Multipart
@POST
(
ApiHelper
.
VERSI_API_1
+
"product"
)
Call
<
DataResponse
<
ProductModels
>>
postProducts
(
@Part
MultipartBody
.
Part
image
,
@Part
(
"name"
)
RequestBody
name
,
@Part
(
"price"
)
Integer
price
,
@Part
(
"stock"
)
Integer
stock
,
@Part
(
"category_id"
)
int
category_id
);
}
}
app/src/main/java/com/yono/messeripos/daos/CartDaos.java
View file @
abc3118f
...
@@ -21,6 +21,8 @@ public interface CartDaos {
...
@@ -21,6 +21,8 @@ public interface CartDaos {
@Query
(
"SELECT * FROM carts WHERE id_product_orders = :idCart"
)
@Query
(
"SELECT * FROM carts WHERE id_product_orders = :idCart"
)
public
LiveData
<
List
<
ProductCartModels
>>
getCartById
(
long
idCart
);
public
LiveData
<
List
<
ProductCartModels
>>
getCartById
(
long
idCart
);
@Query
(
"SELECT * FROM carts WHERE id_orders = :orderId"
)
public
LiveData
<
List
<
ProductCartModels
>>
getCartByOrderId
(
String
orderId
);
@Insert
(
onConflict
=
OnConflictStrategy
.
IGNORE
)
@Insert
(
onConflict
=
OnConflictStrategy
.
IGNORE
)
public
void
insertProduct
(
ProductCartModels
product
);
public
void
insertProduct
(
ProductCartModels
product
);
...
...
app/src/main/java/com/yono/messeripos/models/MainViewModels.java
View file @
abc3118f
...
@@ -64,6 +64,21 @@ public class MainViewModels extends ViewModel {
...
@@ -64,6 +64,21 @@ public class MainViewModels extends ViewModel {
return
transactions
;
return
transactions
;
}
}
public
void
deleteProducts
(
int
id
){
ProductService
productService
=
client
.
Client
(
ProductService
.
class
);
productService
.
deleteProducts
(
id
).
enqueue
(
new
Callback
<
DataResponse
<
ProductModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
ProductModels
>>
call
,
Response
<
DataResponse
<
ProductModels
>>
response
)
{
Log
.
i
(
"Delete"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
ProductModels
>>
call
,
Throwable
t
)
{
Log
.
e
(
"error delete"
,
"onFailure: "
,
t
);
}
});
}
private
void
getDataTransaction
()
{
private
void
getDataTransaction
()
{
TransactionService
transactionService
=
client
.
Client
(
TransactionService
.
class
);
TransactionService
transactionService
=
client
.
Client
(
TransactionService
.
class
);
...
...
app/src/main/java/com/yono/messeripos/models/MainViewModelsCart.java
View file @
abc3118f
...
@@ -86,6 +86,10 @@ public class MainViewModelsCart extends AndroidViewModel {
...
@@ -86,6 +86,10 @@ public class MainViewModelsCart extends AndroidViewModel {
return
cartRepositories
.
getDataById
(
id
);
return
cartRepositories
.
getDataById
(
id
);
}
}
public
LiveData
<
List
<
ProductCartModels
>>
getCartByOrderId
(
String
id
){
return
cartRepositories
.
getCartByOrderId
(
id
);
}
public
MutableLiveData
<
ProductCartModels
>
getCart
(){
public
MutableLiveData
<
ProductCartModels
>
getCart
(){
// String js = new Gson().toJson(cartRepositories.getDataCart());
// String js = new Gson().toJson(cartRepositories.getDataCart());
// Log.d("Get data cart", "Response "+js);
// Log.d("Get data cart", "Response "+js);
...
...
app/src/main/java/com/yono/messeripos/repositories/CartRepositories.java
View file @
abc3118f
...
@@ -43,6 +43,10 @@ public class CartRepositories {
...
@@ -43,6 +43,10 @@ public class CartRepositories {
return
cartDaos
.
getCartById
(
id
);
return
cartDaos
.
getCartById
(
id
);
}
}
public
LiveData
<
List
<
ProductCartModels
>>
getCartByOrderId
(
String
id
){
return
cartDaos
.
getCartByOrderId
(
id
);
}
public
LiveData
<
List
<
ProductCartModels
>>
getDataCart
(){
public
LiveData
<
List
<
ProductCartModels
>>
getDataCart
(){
return
products
;
return
products
;
}
}
...
...
app/src/main/java/com/yono/messeripos/utils/Utils.java
View file @
abc3118f
package
com
.
yono
.
messeripos
.
utils
;
package
com
.
yono
.
messeripos
.
utils
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.os.Build
;
import
android.os.Build
;
import
android.util.Base64
;
import
android.widget.Toast
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
androidx.recyclerview.widget.DividerItemDecoration
;
import
androidx.recyclerview.widget.DividerItemDecoration
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
java.io.ByteArrayOutputStream
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormatSymbols
;
import
java.text.DecimalFormatSymbols
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -62,7 +67,7 @@ public class Utils {
...
@@ -62,7 +67,7 @@ public class Utils {
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
O
)
public
String
convertDate
(
String
date
){
public
String
convertDate
(
String
date
){
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
)
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd'T'HH:mm:ss.SSS
SSS
'Z'"
)
.
withZone
(
ZoneId
.
of
(
"UTC"
));
.
withZone
(
ZoneId
.
of
(
"UTC"
));
LocalDateTime
localDateTime
=
LocalDateTime
LocalDateTime
localDateTime
=
LocalDateTime
...
@@ -73,4 +78,18 @@ public class Utils {
...
@@ -73,4 +78,18 @@ public class Utils {
String
localDate
=
localDateTime
.
format
(
localFormatter
);
String
localDate
=
localDateTime
.
format
(
localFormatter
);
return
localDate
;
return
localDate
;
}
}
public
String
convertImageBase64File
(
String
pathname
){
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
Bitmap
bitmap
=
BitmapFactory
.
decodeFile
(
pathname
);
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
baos
);
byte
[]
b
=
baos
.
toByteArray
();
String
encodeImage
=
Base64
.
encodeToString
(
b
,
Base64
.
DEFAULT
);
return
encodeImage
;
}
public
void
toastMessage
(
Context
context
,
String
message
){
Toast
.
makeText
(
context
,
message
,
Toast
.
LENGTH_LONG
).
show
();
}
}
}
app/src/main/res/layout/activity_history.xml
View file @
abc3118f
...
@@ -23,16 +23,4 @@
...
@@ -23,16 +23,4 @@
tools:listitem=
"@layout/item_history"
/>
tools:listitem=
"@layout/item_history"
/>
</ScrollView>
</ScrollView>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btShow"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/title_next"
android:padding=
"15dp"
android:textSize=
"16sp"
android:layout_alignParentBottom=
"true"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/form_product.xml
View file @
abc3118f
...
@@ -69,6 +69,8 @@
...
@@ -69,6 +69,8 @@
android:id=
"@+id/etName"
android:id=
"@+id/etName"
android:text=
"@{productForm.productName}"
android:text=
"@{productForm.productName}"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:inputType=
"text"
android:imeOptions=
"actionNext"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
...
@@ -88,6 +90,8 @@
...
@@ -88,6 +90,8 @@
android:id=
"@+id/etPrice"
android:id=
"@+id/etPrice"
android:text=
"@{productForm.priceProduct+``}"
android:text=
"@{productForm.priceProduct+``}"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:inputType=
"number"
android:imeOptions=
"actionNext"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
...
@@ -108,7 +112,8 @@
...
@@ -108,7 +112,8 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@{productForm.stockProduct+``}"
android:text=
"@{productForm.stockProduct+``}"
android:textColor=
"#fff"
/>
android:inputType=
"number"
android:imeOptions=
"actionNext"
/>
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
...
@@ -123,18 +128,9 @@
...
@@ -123,18 +128,9 @@
app:layout_constraintVertical_bias=
"0.0"
app:layout_constraintVertical_bias=
"0.0"
app:ms_dropdown_height=
"wrap_content"
app:ms_dropdown_height=
"wrap_content"
app:ms_dropdown_max_height=
"350dp"
app:ms_dropdown_max_height=
"350dp"
app:ms_background_color=
"#8888"
app:ms_background_selector=
"0xFFFFFF"
app:ms_background_selector=
"0xFFFFFF"
tools:layout_editor_absoluteX=
"0dp"
/>
tools:layout_editor_absoluteX=
"0dp"
/>
=======
<Spinner
android:id=
"@+id/planets_spinner"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toBottomOf=
"@id/tfName"
app:layout_constraintStart_toStartOf=
"parent"
/>
>>>>>>> cart
<com.google.android.material.button.MaterialButton
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btnAdd"
android:id=
"@+id/btnAdd"
...
...
library/src/main/res/drawable-v21/ms__selector.xml
View file @
abc3118f
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
android:drawable=
"@android:color/white"
/>
android:drawable=
"@android:color/white"
/>
<item
android:bottom=
"1dp"
>
<item
android:bottom=
"1dp"
>
<shape>
<shape>
<solid
android:color=
"@android:color/
white
"
/>
<solid
android:color=
"@android:color/
darker_gray
"
/>
</shape>
</shape>
</item>
</item>
</ripple>
</ripple>
\ No newline at end of file
library/src/main/res/layout/ms__list_item.xml
View file @
abc3118f
...
@@ -31,5 +31,6 @@
...
@@ -31,5 +31,6 @@
android:paddingStart=
"@dimen/ms__popup_padding_left"
android:paddingStart=
"@dimen/ms__popup_padding_left"
android:paddingTop=
"@dimen/ms__popup_padding_top"
android:paddingTop=
"@dimen/ms__popup_padding_top"
android:singleLine=
"true"
android:singleLine=
"true"
android:background=
"@drawable/ms__drop_down_shadow"
/>
/>
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