Skip to content
Snippets Groups Projects
Commit 357ca511 authored by fheyming's avatar fheyming
Browse files

removed bug

parent f1f8fa99
No related branches found
No related tags found
1 merge request!1Mal aufn Master megren
...@@ -2,6 +2,7 @@ package com.example.mampfmobil; ...@@ -2,6 +2,7 @@ package com.example.mampfmobil;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
...@@ -39,4 +40,24 @@ public class MainActivity extends AppCompatActivity { ...@@ -39,4 +40,24 @@ public class MainActivity extends AppCompatActivity {
return true; // true zurückgeben, um anzugeben, dass die Aktion behandelt wurde return true; // true zurückgeben, um anzugeben, dass die Aktion behandelt wurde
} }
@Override
protected void onPause() {
Log.d("myTag", "This ONPAUSE");
super.onPause();
}
@Override
protected void onStop() {
Log.d("myTag", "This ONSTOP");
super.onStop();
}
@Override
protected void onDestroy() {
Log.d("myTag", "This ONDESTROY");
super.onDestroy();
}
} }
\ No newline at end of file
...@@ -48,16 +48,6 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc ...@@ -48,16 +48,6 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc
holder.tvPrice.setText(String.valueOf(shoppingCart.get(position).item.price)); holder.tvPrice.setText(String.valueOf(shoppingCart.get(position).item.price));
holder.tvSum.setText(String.valueOf(shoppingCart.get(position).item.price * shoppingCart.get(position).quantity)); holder.tvSum.setText(String.valueOf(shoppingCart.get(position).item.price * shoppingCart.get(position).quantity));
holder.deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int adapterPosition = holder.getAdapterPosition();
if (adapterPosition != RecyclerView.NO_POSITION) {
removeItem(adapterPosition);
}
}
});
holder.inputAmount.addTextChangedListener(new TextWatcher() { holder.inputAmount.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
...@@ -72,7 +62,7 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc ...@@ -72,7 +62,7 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if(!holder.inputAmount.getText().toString().equals("")){ if(!holder.inputAmount.getText().toString().equals("")){
Log.d("myTag", "Habe bn bei"+ position);
shoppingCart.get(position).quantity = Integer.parseInt(holder.inputAmount.getText().toString()); shoppingCart.get(position).quantity = Integer.parseInt(holder.inputAmount.getText().toString());
holder.tvSum.setText(String.valueOf(shoppingCart.get(position).item.price * shoppingCart.get(position).quantity)); holder.tvSum.setText(String.valueOf(shoppingCart.get(position).item.price * shoppingCart.get(position).quantity));
CustomerShoppingCartFragment.setSum(); CustomerShoppingCartFragment.setSum();
...@@ -80,6 +70,16 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc ...@@ -80,6 +70,16 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc
//shoppingCart.get(position).quantity = Integer.parseInt(holder.inputAmount.getText().toString()); //shoppingCart.get(position).quantity = Integer.parseInt(holder.inputAmount.getText().toString());
} }
}); });
holder.deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int adapterPosition = holder.getAdapterPosition();
if (adapterPosition != RecyclerView.NO_POSITION) {
removeItem(adapterPosition);
}
}
});
} }
@Override @Override
...@@ -91,7 +91,8 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc ...@@ -91,7 +91,8 @@ public class Recyclerviewadapter_ShoppingCart extends RecyclerView.Adapter<Recyc
shoppingCart.remove(position); shoppingCart.remove(position);
CustomerShoppingCartFragment.setSum(); CustomerShoppingCartFragment.setSum();
notifyItemRemoved(position); notifyItemRemoved(position);
notifyItemRangeChanged(position, getItemCount()); Log.d("myTag", "Habe soooo viel"+ getItemCount());
notifyDataSetChanged();
} }
public static class MyViewHolder extends RecyclerView.ViewHolder { public static class MyViewHolder extends RecyclerView.ViewHolder {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment