Commit 75eb9e48 authored by Ahmad Abi Mulya's avatar Ahmad Abi Mulya

fix view model in product layout

parent e1e63f58
......@@ -3,6 +3,7 @@
package="com.example.yourcashiertest">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
......@@ -21,7 +22,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme2">
<activity android:name=".activities.OrderDetailActivity"></activity>
<service
android:name=".services.BackgroundService"
android:enabled="true"
android:exported="true" />
<receiver android:name=".activities.InetChecker">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
......
......@@ -31,6 +31,7 @@ import com.example.yourcashiertest.databinding.ActivityMainBinding;
import com.example.yourcashiertest.entities.Cart;
import com.example.yourcashiertest.entities.Product;
import com.example.yourcashiertest.entities.Transaksi;
import com.example.yourcashiertest.services.BackgroundService;
import com.example.yourcashiertest.viewmodels.CartViewModel;
import com.example.yourcashiertest.viewmodels.ProductViewModel;
......@@ -107,6 +108,9 @@ public class MainActivity extends AppCompatActivity {
startActivity(new Intent(MainActivity.this, OrderActivity.class));
break;
case R.id.item_four:
BackgroundService.startActionPushProduct(MainActivity.this);
break;
case R.id.item_five:
prefManager.removeLoginSession();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
finish();
......
......@@ -11,6 +11,7 @@ import com.example.yourcashiertest.daos.ProductDao;
import com.example.yourcashiertest.databases.LocalDatabase;
import com.example.yourcashiertest.entities.Product;
import com.example.yourcashiertest.models.PushProduct;
import com.example.yourcashiertest.models.PushProductResponse;
import com.example.yourcashiertest.models.User;
import java.util.List;
......@@ -46,13 +47,13 @@ public class BackgroundService extends JobIntentService {
PushProduct pushProduct = PushProduct.from(product);
ApiClient.client(ProductService.class, BASE_URL).createProduct(pushProduct)
.enqueue(new Callback<User>() {
.enqueue(new Callback<PushProductResponse>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
public void onResponse(Call<PushProductResponse> call, Response<PushProductResponse> response) {
}
@Override
public void onFailure(Call<User> call, Throwable t) {
public void onFailure(Call<PushProductResponse> call, Throwable t) {
}
});
......
......@@ -65,7 +65,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Product Name"
android:text="@{viewModel.pushProduct.name}"
android:text="@{viewModel.Product.name}"
android:inputType="textCapWords"
android:textSize="@dimen/text_default" />
......@@ -86,7 +86,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Price"
android:text="@{viewModel.pushProduct.price == 0 ? `` : viewModel.pushProduct.price + ``}"
android:text="@{viewModel.Product.price == 0 ? `` : viewModel.Product.price + ``}"
android:inputType="number"
android:textSize="@dimen/text_default" />
......@@ -108,7 +108,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Qty"
android:text="@{viewModel.pushProduct.quantity == 0 ? `` : viewModel.pushProduct.quantity + ``}"
android:text="@{viewModel.Product.quantity == 0 ? `` : viewModel.Product.quantity + ``}"
android:inputType="number"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
......@@ -125,7 +125,7 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etCategory"
android:hint="Category"
android:text="@{viewModel.pushProduct.category}"
android:text="@{viewModel.Product.category}"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
......@@ -148,7 +148,7 @@
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="3"
android:text="@{viewModel.pushProduct.description}"
android:text="@{viewModel.Product.description}"
android:textSize="@dimen/text_default" />
</com.google.android.material.textfield.TextInputLayout>
......
......@@ -73,7 +73,7 @@
android:layout_height="wrap_content"
android:text="Coba Lagi"
android:textSize="18sp"
android:textColor="#3949AB"
android:textColor="@color/blue"
android:textFontWeight="600"
android:paddingVertical="15dp"
android:gravity="center"/>
......
......@@ -6,7 +6,7 @@
<data>
<import type="android.view.View"/>
<variable
name="pushProduct"
name="Product"
type="com.example.yourcashiertest.entities.Product" />
<variable
......@@ -42,7 +42,7 @@
android:layout_height="130dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
app:file="@{pushProduct.photo}"
app:file="@{Product.photo}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.8"
app:layout_constraintStart_toStartOf="parent"
......@@ -78,7 +78,7 @@
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{pushProduct.name}"
android:text="@{Product.name}"
android:textStyle="bold"
android:layout_marginTop="8dp"
android:maxLength="20"
......@@ -94,7 +94,7 @@
android:id="@+id/tv_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{pushProduct.description}"
android:text="@{Product.description}"
android:layout_marginTop="8dp"
android:layout_marginBottom="@dimen/space_default"
android:maxLength="40"
......@@ -148,7 +148,7 @@
android:layout_height="20sp"
android:textColor="@color/white"
android:textAlignment="center"
android:text="@{pushProduct.quantity + ``}"
android:text="@{Product.quantity + ``}"
android:background="@drawable/ic_stok"
app:layout_constraintBottom_toBottomOf="@+id/tvStock"
app:layout_constraintTop_toTopOf="@+id/tvStock"
......
......@@ -11,5 +11,9 @@
android:title="Transaction List"/>
<item
android:id="@+id/item_four"
android:title="Sync Data"/>
<item
android:id="@+id/item_five"
android:title="Log Out"/>
</menu>
\ No newline at end of file
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