Results 1 to 1 of 1
  1. #1
    dmagician is offline Member
    Join Date
    Jun 2012
    Posts
    1
    Rep Power
    0

    Question Android Java NewB Question...

    First, Hello everyone.

    Second,
    I am a .Net developer, but I am new to Java in general and to Java programming on Android in particular...

    I'm trying to create a simple app meant to get a summery for billing a client (which would, later on, send me and the client an EMail with details on what I've done over his/her computer and to total to be paid).

    My question is:

    Is there any simple way to execute something like:

    Java Code:
    private boolean IsEmpty(String sTestStr)
    {
    	boolean bRes = false;
    
    	if (sTestStr.length() == 0)
    	{
    		bRes = (true);
    		return (bRes);
    	}
    
    	if (sTestStr.isEmpty())
    	{
    		bRes = (true);
    		return (bRes);
    	}
    
    	return (bRes);
    }
    	
    protected void DoCalc()
    {
    	if (bFirstCall)
    	{
    		bFirstCall = false;
    
    		iSum = 0;
    		.
    		.
    		try
    		{
    			String sCurrentValue = tbTravelExpenses_Amount.getText().toString();
    			String sCurrentPrice = tbTravelExpenses_Price.getText().toString();
    
    			if (IsEmpty(sCurrentValue))
    			{
    				// tbTravelExpenses_Amount.setText("0");
    				iTravelExpenses = 0;
    			}
    			else
    			{
    				Integer iCurrentValue = Integer.parseInt(sCurrentValue);
    				Integer iCurrentPrice = Integer.parseInt(sCurrentPrice);
    
    				iTravelExpenses = iCurrentValue * iCurrentPrice;
    
    				if (iTravelExpenses < 0)
    				{
    					tbTravelExpenses_Amount.setText("0");
    					iTravelExpenses = 0;
    				}
    				else
    				{
    					try
    					{
    						tbTravelExpenses_Amount.setText(Integer.toString(iCurrentValue));
    					}
    					catch (Exception e)
    					{
    						tbTravelExpenses_Amount.setText("0");
    					}
    				}
    			}
    		}
    		catch (Exception e)
    		{
    			iTravelExpenses = 0;
    		}
    		.
    		.
    		iSum = iFirstHour + iOSFormatAndInstalation + iOSUpdateAndRepair + iVirusesAndJunk + iJunkAndApplicationRemoval + iSoftwareInstallation + iSoftwareTroubleshooting + iHardwareTroubleshooting + iBackups + iTravelExpenses;
    
    		tbSummarySum_Price.setText(Integer.toString(iSum));
    		bFirstCall = false;
    	}
    }
    
    private TextWatcher twTextWatchers = new TextWatcher() {
    
    	@Override
    	public void onTextChanged(CharSequence s, int start, int before, int count) { /* N.OP */ };
    
    	@Override
    	public void beforeTextChanged(CharSequence s, int start, int count, int after) { /* N.OP */ };
    
    	@Override
    	public void afterTextChanged(Editable s)
    	{
    		DoCalc();
    	};
    
    };;
    to prevent the afterTextChanged(Editable s) event to be fired again while proccessing DoCalc() ?
    Last edited by dmagician; 06-25-2012 at 11:39 AM.

Similar Threads

  1. A newb question
    By JavaJunkie2341 in forum New To Java
    Replies: 2
    Last Post: 03-30-2012, 07:00 PM
  2. Replies: 4
    Last Post: 09-20-2011, 03:33 AM
  3. Help for a total Java Newb
    By rsjac in forum New To Java
    Replies: 3
    Last Post: 02-21-2011, 04:30 AM
  4. [SOLVED] Probably a tooootal newb question... but
    By proeliumfessus in forum New To Java
    Replies: 6
    Last Post: 04-05-2009, 07:07 PM
  5. Java newb Q: 8-digit id
    By 1111FM in forum New To Java
    Replies: 2
    Last Post: 09-29-2008, 02:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •