package data.jnidemo1;


import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.app.Activity;
import android.text.TextUtils;

public class MainActivity extends Activity 
{

    private EditText n;
	private TextView sum;
	private Button getsum;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		n = (EditText) findViewById(R.id.n); 
		getsum = (Button) findViewById(R.id.getsum);
		sum = (TextView) findViewById(R.id.sum);
		TextView info = (TextView) findViewById(R.id.info);
	}
	 
	// @Override
	public void onClick(View view) {
	    // check if the fields are empty
	   if (TextUtils.isEmpty(n.getText().toString()) )
	      return;

	    // read numbers from EditText               
	   String str = n.getText().toString();
	   
	   int n1 = Integer.parseInt( str );
	   int s = SumWrapper.getSum( n1 );
	   
	   // display result
	   str = "Sum of 1 to " + str + " is ";
	   str += Integer.toString ( s );;
	   sum.setText ( str );
	}
}
