@@ -245,10 +245,10 @@ private void addVendorDialog(){
245245 LayoutInflater inflater = this .getLayoutInflater ();
246246 View dialogView = inflater .inflate (R .layout .add_vendor_layout , null );
247247 dialogBuilder .setView (dialogView );
248- final EditText vendorReferenceET = ( EditText ) dialogView .findViewById (R .id .vendorReferecnceET );
249- final EditText vendorRatioET = ( EditText ) dialogView .findViewById (R .id .vendorRatioET );
250- Button addVendorBtn = ( Button ) dialogView .findViewById (R .id .doneDialogBtn );
251- Button cancelDialogBtn = ( Button ) dialogView .findViewById (R .id .cancelDialogBtn );
248+ final EditText vendorReferenceET = dialogView .findViewById (R .id .vendorReferecnceET );
249+ final EditText vendorRatioET = dialogView .findViewById (R .id .vendorRatioET );
250+ Button addVendorBtn = dialogView .findViewById (R .id .doneDialogBtn );
251+ Button cancelDialogBtn = dialogView .findViewById (R .id .cancelDialogBtn );
252252 final AlertDialog alertDialog = dialogBuilder .create ();
253253 cancelDialogBtn .setOnClickListener (new View .OnClickListener () {
254254 @ Override
@@ -260,23 +260,26 @@ public void onClick(View view) {
260260 @ Override
261261 public void onClick (View view ) {
262262 Boolean valid = true ;
263- if (vendorReferenceET .getText ().toString ().length ()<1 ){
263+ String vendorRef = vendorReferenceET .getText ().toString ().trim ();
264+ String vendorRatio = vendorRatioET .getText ().toString ().trim ();
265+
266+ if (vendorRef .length ()<1 ){
264267 vendorReferenceET .setError ("Vendor reference is required" );
265268 valid = false ;
266269 }
267- if (vendorRatioET .getText (). toString (). length ()<1 ){
270+ if (vendorRatioET .length ()<1 ){
268271 vendorRatioET .setError ("Vendor ratio is required" );
269272 valid = false ;
270273 }
271274 if (!valid ){
272275 return ;
273276 }
274277 if (subAccounts .size ()!=0 ){
275- vendorListTXT .setText (vendorListTXT .getText ().toString ()+", " +vendorReferenceET . getText (). toString () +"(" +vendorRatioET . getText (). toString () +")" );
278+ vendorListTXT .setText (vendorListTXT .getText ().toString ()+", " + vendorRef +"(" + vendorRatio +")" );
276279 }else {
277- vendorListTXT .setText (vendorListTXT .getText ().toString ()+vendorReferenceET . getText (). toString () +"(" +vendorRatioET . getText (). toString () +")" );
280+ vendorListTXT .setText (vendorListTXT .getText ().toString ()+ vendorRef +"(" +vendorRatio +")" );
278281 }
279- subAccounts .add (new SubAccount (vendorReferenceET . getText (). toString (). trim (), vendorRatioET . getText (). toString (). trim () ));
282+ subAccounts .add (new SubAccount (vendorRef , vendorRatio ));
280283 alertDialog .dismiss ();
281284 }
282285 });
0 commit comments