Commit 9d892f4e authored by iman Fauzi's avatar iman Fauzi

update

parent abd5c081
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
...@@ -2,6 +2,7 @@ package com.yono.messeripos; ...@@ -2,6 +2,7 @@ package com.yono.messeripos;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
...@@ -18,7 +19,7 @@ public class CartActivity extends AppCompatActivity { ...@@ -18,7 +19,7 @@ public class CartActivity extends AppCompatActivity {
TextInputEditText tiQty; TextInputEditText tiQty;
TextView tvQtyView, tvPrice, tvTotal; TextView tvQtyView, tvPrice, tvTotal;
private int counter; public int counter, prices;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -35,8 +36,12 @@ public class CartActivity extends AppCompatActivity { ...@@ -35,8 +36,12 @@ public class CartActivity extends AppCompatActivity {
tvTotal = findViewById(R.id.tvTotal); tvTotal = findViewById(R.id.tvTotal);
counter = Integer.parseInt(tvQtyView.getText().toString()); counter = Integer.parseInt(tvQtyView.getText().toString());
prices = Integer.parseInt(tvPrice.getText().toString());
tvTotal.setText(setToRp().format((double) Integer.parseInt(tvTotal.getText().toString())));
btMinus.setOnClickListener(new View.OnClickListener() { btMinus.setOnClickListener(new View.OnClickListener() {
@SuppressLint("SetTextI18n")
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (counter > 1){ if (counter > 1){
...@@ -46,11 +51,11 @@ public class CartActivity extends AppCompatActivity { ...@@ -46,11 +51,11 @@ public class CartActivity extends AppCompatActivity {
countTotal(); countTotal();
} }
} }
}); });
btPlus.setOnClickListener(new View.OnClickListener() { btPlus.setOnClickListener(new View.OnClickListener() {
@SuppressLint("SetTextI18n")
@Override @Override
public void onClick(View view) { public void onClick(View view) {
counter++; counter++;
...@@ -63,19 +68,22 @@ public class CartActivity extends AppCompatActivity { ...@@ -63,19 +68,22 @@ public class CartActivity extends AppCompatActivity {
} }
private void countTotal() { private void countTotal() {
int price = Integer.parseInt(tvPrice.getText().toString()); int price = prices;
int qtyView = Integer.parseInt(tvQtyView.getText().toString()); int qtyView = Integer.parseInt(tvQtyView.getText().toString());
int count = price*qtyView; int count = price*qtyView;
String result = Integer.toString(price*qtyView); // String result = Integer.toString(price*qtyView);
// set to view // set to view
tvTotal.setText(setToRp().format((double) count)); tvTotal.setText(setToRp().format((double) count));
} }
public void setRp() {
}
private NumberFormat setToRp() { private NumberFormat setToRp() {
Locale ID = new Locale("in", "ID"); Locale ID = new Locale("in", "ID");
NumberFormat formatRp = NumberFormat.getCurrencyInstance(ID); return NumberFormat.getCurrencyInstance(ID);
return formatRp;
} }
} }
\ No newline at end of file
...@@ -25,7 +25,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -25,7 +25,7 @@ public class MainActivity 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);
} }
Toolbar toolbar = findViewById(R.id.app_bar); // Toolbar toolbar = findViewById(R.id.app_bar);
} }
@Override @Override
......
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