Commit b0435b7d authored by Muhammad Suryono's avatar Muhammad Suryono

Merge branch 'dev'

parents 8d183400 041fcb0e
...@@ -181,37 +181,32 @@ public class FormProductActivity extends AppCompatActivity { ...@@ -181,37 +181,32 @@ public class FormProductActivity extends AppCompatActivity {
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
private void setSpinner(String s) { private void setSpinner(String s) {
progressDialog.show();
HashSet<String> set = new HashSet<>(); HashSet<String> set = new HashSet<>();
List<String> str = new ArrayList<>();
categoryModels = new ArrayList<>(); categoryModels = new ArrayList<>();
categoryModels.add("SELECT CATEGORY"); str.add("SELECT CATEGORY");
mainViewModels.getCategory().observe(this, listDataResponse -> { mainViewModels.getCategory().observe(this, listDataResponse -> {
progressDialog.dismiss();
List<CategoryModels> cate = listDataResponse.getData(); for (CategoryModels cd: listDataResponse.getData()){
for (CategoryModels cd: cate){
Log.i("SPINNER", "setSpinner: "+utils.convertGson(cd.getNameCategory()));
categoryModels.add(cd.getNameCategory()); categoryModels.add(cd.getNameCategory());
} }
List<String> collect = categoryModels.stream().map(v -> {
if (set.add(v) == true) {
str.add(v);
}
return v;
}).collect(Collectors.toList());
// Log.i("Spinner data", "onCreate: "+utils.convertGson(categoryModels)); Log.i("SPINNER", "setSpinner: "+utils.convertGson(str));
@SuppressLint("ResourceType")
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(FormProductActivity.this,
R.id.listCategory, str);
binding.listCategory.setAdapter(dataAdapter);
}); });
List<HashSet<String>> collect = categoryModels.stream().map(v -> {
if (set.add(v) == true) {
set.add(v);
}
return set;
}).collect(Collectors.toList());
Log.i("SPINNER", "setSpinner: "+utils.convertGson(collect));
@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(){
......
...@@ -390,7 +390,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -390,7 +390,6 @@ public class MainActivity extends AppCompatActivity {
categoryAdapter.setListener(new CategoryAdapter.CategoryListener() { categoryAdapter.setListener(new CategoryAdapter.CategoryListener() {
@Override @Override
public void onGetProduct(CategoryModels categoryModels) { public void onGetProduct(CategoryModels categoryModels) {
progressDialog.show();
Log.i("diluar if", "onGetProduct: "+selectCategory); Log.i("diluar if", "onGetProduct: "+selectCategory);
if (!selectCategory){ if (!selectCategory){
binding.rvProduct.setVisibility(View.GONE); binding.rvProduct.setVisibility(View.GONE);
...@@ -400,14 +399,16 @@ public class MainActivity extends AppCompatActivity { ...@@ -400,14 +399,16 @@ public class MainActivity extends AppCompatActivity {
Log.i("setelah if", "onGetProduct: "+selectCategory); Log.i("setelah if", "onGetProduct: "+selectCategory);
if (categoryModels.getIdCategory() == 0){ if (categoryModels.getIdCategory() == 0){
progressDialog.show();
if (mainViewModels.getProduct().getValue().getData().size() != 0){ if (mainViewModels.getProduct().getValue().getData().size() != 0){
selectCategory = false; selectCategory = false;
mainViewModels.getProduct().observe(MainActivity.this, new Observer<DataResponse<List<ProductModels<CategoryModels>>>>() { mainViewModels.getProduct().observe(MainActivity.this, new Observer<DataResponse<List<ProductModels<CategoryModels>>>>() {
@Override @Override
public void onChanged(DataResponse<List<ProductModels<CategoryModels>>> listDataResponse) { public void onChanged(DataResponse<List<ProductModels<CategoryModels>>> listDataResponse) {
progressDialog.dismiss();
productModelsArrayList.clear(); productModelsArrayList.clear();
productModelsArrayList.addAll(listDataResponse.getData()); productModelsArrayList.addAll(listDataResponse.getData());
progressDialog.dismiss();
binding.rvProduct.setVisibility(View.VISIBLE); binding.rvProduct.setVisibility(View.VISIBLE);
binding.imgEmpty.setVisibility(View.GONE); binding.imgEmpty.setVisibility(View.GONE);
productAdapter.setProduct(MainActivity.this, productModelsArrayList); productAdapter.setProduct(MainActivity.this, productModelsArrayList);
...@@ -422,14 +423,16 @@ public class MainActivity extends AppCompatActivity { ...@@ -422,14 +423,16 @@ public class MainActivity extends AppCompatActivity {
// binding.imgEmpty.bringToFront(); // binding.imgEmpty.bringToFront();
} }
}else{ }else{
progressDialog.show();
selectCategory = false; selectCategory = false;
mainViewModels.getProductByCategory(categoryModels.getIdCategory()).observe(MainActivity.this, new Observer<DataResponse<List<ProductModels>>>() { mainViewModels.getProductByCategory(categoryModels.getIdCategory()).observe(MainActivity.this, new Observer<DataResponse<List<ProductModels>>>() {
@Override @Override
public void onChanged(DataResponse<List<ProductModels>> listDataResponse) { public void onChanged(DataResponse<List<ProductModels>> listDataResponse) {
progressDialog.dismiss();
if (listDataResponse != null) { if (listDataResponse != null) {
productModelsArrayList.clear(); productModelsArrayList.clear();
productModelsArrayList.addAll(listDataResponse.getData()); productModelsArrayList.addAll(listDataResponse.getData());
progressDialog.dismiss();
showLoading(false); showLoading(false);
if (productModelsArrayList.isEmpty()) { if (productModelsArrayList.isEmpty()) {
binding.rvProduct.setVisibility(View.GONE); binding.rvProduct.setVisibility(View.GONE);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape> <shape>
<gradient android:startColor="@color/colorPrimary" android:endColor="@color/colorPrimaryDark" android:angle="90"/> <gradient android:startColor="@color/colorPrimary" android:centerColor="@color/colorPrimaryCenter" android:endColor="@color/colorPrimaryDark" android:angle="-90" android:centerY="0.7"/>
</shape> </shape>
</item> </item>
</selector> </selector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="43dp"
android:viewportWidth="64"
android:viewportHeight="43">
<path
android:pathData="M8.5,36.682C13.1944,36.682 17,32.8764 17,28.182C17,23.4876 13.1944,19.682 8.5,19.682C3.8056,19.682 0,23.4876 0,28.182C0,32.8764 3.8056,36.682 8.5,36.682Z"
android:fillColor="@color/colorPrimary"
android:fillAlpha="0.87"/>
<path
android:pathData="M59.6642,27.3332L40.9464,5.0349C38.6122,2.2542 34.4658,1.8922 31.6851,4.2264C28.9044,6.5606 28.5424,10.7071 30.8766,13.4878L49.5943,35.7861C51.9285,38.5668 56.075,38.9287 58.8557,36.5945C61.6364,34.2603 61.9984,30.1139 59.6642,27.3332Z"
android:fillColor="@color/colorPrimary"
android:fillAlpha="0.87"/>
<path
android:pathData="M40.2832,29.2722L21.5654,6.9739C19.2312,4.1932 15.0848,3.8312 12.3041,6.1654C9.5234,8.4996 9.1614,12.6461 11.4956,15.4268L30.2133,37.7251C32.5475,40.5058 36.694,40.8677 39.4747,38.5335C42.2554,36.1993 42.6174,32.0529 40.2832,29.2722Z"
android:fillColor="@color/colorPrimary"
android:fillAlpha="0.87"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="43dp"
android:viewportWidth="64"
android:viewportHeight="43">
<path
android:pathData="M8.5,36.682C13.1944,36.682 17,32.8764 17,28.182C17,23.4876 13.1944,19.682 8.5,19.682C3.8056,19.682 0,23.4876 0,28.182C0,32.8764 3.8056,36.682 8.5,36.682Z"
android:fillColor="#fff"
android:fillAlpha="0.87"/>
<path
android:pathData="M59.6642,27.3332L40.9464,5.0349C38.6122,2.2542 34.4658,1.8922 31.6851,4.2264C28.9044,6.5606 28.5424,10.7071 30.8766,13.4878L49.5943,35.7861C51.9285,38.5668 56.075,38.9287 58.8557,36.5945C61.6364,34.2603 61.9984,30.1139 59.6642,27.3332Z"
android:fillColor="#fff"
android:fillAlpha="0.87"/>
<path
android:pathData="M40.2832,29.2722L21.5654,6.9739C19.2312,4.1932 15.0848,3.8312 12.3041,6.1654C9.5234,8.4996 9.1614,12.6461 11.4956,15.4268L30.2133,37.7251C32.5475,40.5058 36.694,40.8677 39.4747,38.5335C42.2554,36.1993 42.6174,32.0529 40.2832,29.2722Z"
android:fillColor="#fff"
android:fillAlpha="0.87"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/gradient"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context=".LoginActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="20dp"
android:paddingVertical="25dp">
<ImageView
android:id="@+id/messerLogoDashboardLogin"
android:layout_width="215dp"
android:layout_height="215dp"
android:src="@drawable/ic_messer_white"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="messer"
android:textSize="30dp"
android:fontFamily="@font/poppins_bold"
android:textStyle="bold"
android:textColor="@color/colorWhite"
android:layout_below="@id/messerLogoDashboardLogin"
android:layout_centerHorizontal="true"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/signUpButtonDashboardLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/materialButtonOutlinedStyle"
app:strokeColor="#fff"
android:text="sign up"
android:textStyle="bold"
android:textColor="#fff"
app:strokeWidth="2dp"
app:rippleColor="@color/colorWhite"
android:padding="20dp"
app:cornerRadius="5dp"
android:layout_above="@id/signInButtonDashboardLogin"
android:layout_marginBottom="10dp"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/signInButtonDashboardLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorWhite"
android:layout_alignParentBottom="true"
android:padding="20dp"
android:text="sign in"
android:textStyle="bold"
app:rippleColor="#A8A8A8"
app:cornerRadius="5dp"
android:textColor="@color/colorPrimary"/>
</RelativeLayout>
<include
layout="@layout/login_form"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ConstraintLoginLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_gravity="bottom"
app:behavior_hideable="false"
android:padding="20dp"
style="@style/Widget.Rounded.BottomSheet"
app:behavior_peekHeight="0dp"
android:background="@color/colorWhite"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/closeBtnLogin"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_baseline_plus_24"
android:scaleType="centerInside"
android:adjustViewBounds="true"
android:padding="50dp"
android:backgroundTint="@android:color/transparent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
<ImageView
android:id="@+id/messerLogoInLogin"
android:layout_width="215dp"
android:layout_height="215dp"
android:src="@drawable/ic_messer_primary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/closeBtnLogin"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/formUsernameLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
app:layout_constraintTop_toBottomOf="@id/messerLogoInLogin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/FormPasswordLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
app:layout_constraintTop_toBottomOf="@id/formUsernameLogin"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/CBRememberMe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:textColor="@color/colorPrimary"
app:layout_constraintTop_toBottomOf="@id/FormPasswordLogin"
app:layout_constraintStart_toStartOf="parent"
app:useMaterialThemeColors="true"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/SignInButtonInLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/CBRememberMe"
android:text="Sign In"
android:padding="20dp"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
app:layout_constraintTop_toBottomOf="@id/SignInButtonInLogin"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="10dp"
android:textColor="@color/colorPrimary"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#4d089a</color> <color name="colorPrimary">#4d089a</color>
<color name="colorPrimaryCenter">#4021B9</color>
<color name="colorPrimaryDark">#323edd</color> <color name="colorPrimaryDark">#323edd</color>
<color name="colorAccent">#dc2ade</color> <color name="colorAccent">#dc2ade</color>
<color name="colorAccentDark">#e8f044</color> <color name="colorAccentDark">#e8f044</color>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment