Commit 7c0c8a0b authored by Muhammad Suryono's avatar Muhammad Suryono

Merge branch 'dev' into form

parents 81bb2a1f 66d84a8e
<component name="ProjectCodeStyleConfiguration">
<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>
<case-options enabled="true">
<option name="KEYWORD_CASE" value="lower" />
......
......@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yono.messeripos">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
......@@ -11,7 +11,10 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme.appbar">
<activity android:name=".PaymentActivity" android:theme="@style/AppTheme.appbar"></activity>
<activity android:name=".ProductActivity"></activity>
<activity
android:name=".PaymentActivity"
android:theme="@style/AppTheme.appbar" />
<activity android:name=".CartActivity" />
<activity android:name=".SplashScreen">
<intent-filter>
......@@ -20,9 +23,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" android:theme="@style/AppTheme.appbar">
</activity>
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.appbar"></activity>
<meta-data
android:name="preloaded_fonts"
......
......@@ -15,11 +15,17 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.google.android.material.appbar.MaterialToolbar;
import com.yono.messeripos.adapter.ProductAdapter;
import com.yono.messeripos.databinding.ActivityMainBinding;
import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.models.ProductModels;
import com.google.gson.Gson;
import com.yono.messeripos.adapter.CategoryAdapter;
import com.yono.messeripos.databinding.ActivityMainBinding;
......@@ -29,20 +35,27 @@ import com.yono.messeripos.response.DataResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {
MaterialToolbar toolbar;
MainViewModels mainViewModels;
ActivityMainBinding binding;
CategoryAdapter categoryAdapter;
ProductAdapter productAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ProductAdapter adapter = new ProductAdapter();
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.rvProduct.setAdapter(adapter);
// setContentView(R.layout.activity_main);
categoryAdapter = new CategoryAdapter();
productAdapter = new ProductAdapter();
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
......@@ -59,18 +72,19 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onMenuItemClick(MenuItem item) {
int id = item.getItemId();
if (id == R.id.menu_cart){
if (id == R.id.menu_cart) {
startActivity(new Intent(getApplicationContext(), CartActivity.class));
}
return true;
}
});
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
mainViewModels.getCategory().observe(this, new Observer<DataResponse<List<CategoryModels>>>() {
@Override
public void onChanged(DataResponse<List<CategoryModels>> listDataResponse) {
if (listDataResponse != null){
if (listDataResponse != null) {
List<CategoryModels> categoryModels = listDataResponse.getData();
ArrayList<CategoryModels> categoryModelsArrayList = new ArrayList<>();
......@@ -82,10 +96,31 @@ public class MainActivity extends AppCompatActivity {
}
String js = new Gson().toJson(listDataResponse);
Log.d("Get data from category", "Response "+js);
Log.d("Get data from category", "Response " + js);
}
});
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
mainViewModels.getProduct().observe(this, new Observer<DataResponse<List<ProductModels<CategoryModels>>>>() {
@Override
public void onChanged(DataResponse<List<ProductModels<CategoryModels>>> listDataResponse) {
if (listDataResponse != null) {
List<ProductModels<CategoryModels>> productModels = listDataResponse.getData();
ArrayList<ProductModels> productModelsArrayList = new ArrayList<>();
productModelsArrayList.addAll(productModels);
productAdapter.setProduct(MainActivity.this,productModelsArrayList );
binding.rvCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
binding.rvCategory.setAdapter(categoryAdapter);
}
String js = new Gson().toJson(listDataResponse);
Log.d("Get data from products", "Response " + js);
}
});
}
......
package com.yono.messeripos;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class ProductActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product);
}
}
\ No newline at end of file
package com.yono.messeripos.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.yono.messeripos.R;
import com.yono.messeripos.databinding.ItemCategoryBinding;
import com.yono.messeripos.databinding.ItemListBinding;
import com.yono.messeripos.models.CategoryModels;
import com.yono.messeripos.models.ProductModels;
import java.util.ArrayList;
import java.util.List;
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHolder> {
private ArrayList<ProductModels> productModels;
Context context;
public void setProduct(Context context, ArrayList<ProductModels> productModels){
this.productModels = productModels;
this.context = context;
notifyDataSetChanged();
}
@NonNull
@Override
public ProductAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
ItemListBinding itemListBinding = DataBindingUtil.inflate(
LayoutInflater.from(parent.getContext()),
R.layout.item_list,
parent,
false
);
return new MyViewHolder(itemListBinding);
}
@Override
public void onBindViewHolder(@NonNull ProductAdapter.MyViewHolder holder, int position) {
holder.bindData(productModels.get(position));
}
@Override
public int getItemCount() {
return 0;
return productModels.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
public MyViewHolder(@NonNull View itemView) {
super(itemView);
private ItemListBinding binding;
public MyViewHolder(@NonNull ItemListBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
public void bindData(ProductModels products) {
binding.setProducts(products);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".ProductActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingStart="15dp"
xmlns:android="http://schemas.android.com/apk/res/android">
android:paddingStart="15dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:elevation="0dp"
app:menu="@menu/home"
app:navigationIcon="@drawable/ic_meser">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/home"
android:elevation="0dp"
app:navigationIcon="@drawable/ic_meser"
android:layout_marginTop="30dp"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#fff"
android:hint="Search"
android:paddingStart="10dp"
android:textColorHint="#fff"
android:outlineSpotShadowColor="#fff"
android:textColorHighlight="#fff"
android:drawableStart="@drawable/ic_baseline_search_24"/>
</com.google.android.material.appbar.MaterialToolbar>
android:drawableStart="@drawable/ic_baseline_search_24"
android:hint="Search"
android:outlineSpotShadowColor="#fff"
android:paddingStart="10dp"
android:textColor="#fff"
android:textColorHighlight="#fff"
android:textColorHint="#fff" />
</com.google.android.material.appbar.AppBarLayout>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
......@@ -21,6 +21,7 @@
android:backgroundTint="@color/ic_launcher_background"
app:cardCornerRadius="40dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
......@@ -29,8 +30,8 @@
android:id="@+id/image_cat"
android:layout_width="30dp"
android:layout_height="50dp"
android:src="@drawable/ic_meser"
android:layout_marginStart="10dp"
android:src="@drawable/ic_meser"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.06"
......@@ -42,18 +43,19 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="40dp"
android:fontFamily="@font/roboto"
android:text="@{category.nameCategory}"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#fff"
tools:text="@tools:sample/full_names"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/image_cat"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="10dp"
android:layout_marginEnd="40dp"
tools:ignore="MissingConstraints" />
......@@ -61,4 +63,5 @@
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
</layout>
......@@ -5,7 +5,7 @@
<data>
<variable
name="product"
name="products"
type="com.yono.messeripos.models.ProductModels" />
</data>
......
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