11package org .openimis .imisclaims ;
2+ import static org .openimis .imisclaims .util .AndroidUtils .showDialog ;
3+
24import android .content .Context ;
35import android .text .Editable ;
46import android .text .TextWatcher ;
810import android .widget .BaseAdapter ;
911import android .widget .EditText ;
1012import android .widget .TextView ;
11- import android .widget .Toast ;
12-
13- import org .json .JSONException ;
14- import org .json .JSONObject ;
1513
1614import java .util .ArrayList ;
1715public class CustomAdapter extends BaseAdapter {
@@ -71,7 +69,7 @@ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
7169 @ Override
7270 public void onTextChanged (CharSequence charSequence , int i , int i1 , int i2 ) {
7371 // faire les controle en fonction du package type
74- if (!holder .editQty .getText ().toString ().equals ( "" )){
72+ if (!holder .editQty .getText ().toString ().isEmpty ( )){
7573 editModelArrayList .get (position ).setQty (holder .editQty .getText ().toString ());
7674 }else {
7775 editModelArrayList .get (position ).setQty ("0" );
@@ -80,31 +78,30 @@ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
8078 @ Override
8179 public void afterTextChanged (Editable editable ) {
8280 float amount = 0 ;
83- int qtyMax = Integer .valueOf (editModelArrayList .get (position ).getQtyMax ());
81+ int qtyMax = Integer .parseInt (editModelArrayList .get (position ).getQtyMax ());
8482 if (!holder .editQty .getText ().toString ().isEmpty ()){
83+ float qty = Float .parseFloat (holder .editQty .getText ().toString ());
8584 if (AddServices .packageType .equals ("F" )){
86- if (Float .valueOf (holder .editQty .getText ().toString ()) > qtyMax ){
87- Toast .makeText (context , context .getResources ().getString (R .string .qtyAlert ) + " " + qtyMax , Toast .LENGTH_LONG ).show ();
88- holder .editQty .setText (String .valueOf (qtyMax ));
85+ if ( qty > qtyMax ){
86+ holder .editQty .setError (context .getResources ().getString (R .string .qtyAlert ) + " " + qtyMax );
8987 }
9088 }else if (AddServices .packageType .equals ("P" )){
91- if (Float .valueOf (holder .editQty .getText ().toString ()) != qtyMax && Float .valueOf (holder .editQty .getText ().toString ()) != 0 ){
92- Toast .makeText (context , context .getResources ().getString (R .string .qtyAlertAsk ) + " " + qtyMax , Toast .LENGTH_LONG ).show ();
93- holder .editQty .setText (String .valueOf (qtyMax ));
89+ if (qty != qtyMax && qty != 0 ){
90+ holder .editQty .setError (context .getResources ().getString (R .string .qtyAlertAsk ) + " " + qtyMax );
9491 }
9592 }
9693 }
9794 if (AddServices .manualPrice .equals ("0" )){
9895 for (int i = 0 ; i < editModelArrayList .size (); i ++){
99- amount = amount + (Float .valueOf (editModelArrayList .get (i ).getQty ()) * Float .valueOf (editModelArrayList .get (i ).getPrice ()));
96+ amount = amount + (Float .parseFloat (editModelArrayList .get (i ).getQty ()) * Float .parseFloat (editModelArrayList .get (i ).getPrice ()));
10097 }
10198 AddServices .etSAmount .setText (String .valueOf (amount ));
10299 }
103100 }
104101 });
105102 return convertView ;
106103 }
107- private class ViewHolder {
104+ private static class ViewHolder {
108105 protected EditText editQty ;
109106 protected EditText editName ;
110107 protected EditText editPrice ;
0 commit comments