I have an activity which looks somewhat like: Please dont copy it, It takes three variables from another class and calculates gcd of (a,b) , (b,c) , (c,d) , (a,b,c) and then factorizes the equation and gives five different textViews the string. also if you can help to improve x.square to x2, please help me, all suggestions welcome.
package com.aditya.blabla;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AlternateForms extends Activity {
AnotherClass ec = new AnotherClass ();
int aa = ec.geta();
int bb = ec.getb();
int cc = ec.getc();
int abhcf = HCF(aa, cc), bchcf = HCF(cc, cc), achcf = HCF(aa, cc),
abchcf = HCF(abhcf, cc);
String altform1,altform2,altform3,altform4,altform5;
TextView t1, t2, t3, t4, t5;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.alternate);
t1 = (TextView) findViewById(R.id.textView1);
t2 = (TextView) findViewById(R.id.textView2);
t3 = (TextView) findViewById(R.id.textView3);
t4 = (TextView) findViewById(R.id.textView4);
t5 = (TextView) findViewById(R.id.textView5);
altform1 = abhcf + "x(" + aa / abhcf + "x+" + bb / abhcf + ")+"
+ cc;
setProgress(20);
altform2 = aa + "x.square" + bchcf + "(" + bb / bchcf + "x" + cc
/ bchcf + ")" + cc;
setProgress(30);
altform3 = achcf + "(" + aa / achcf + "x.square" + bb / achcf
+ ")" + cc + "x";
setProgress(40);
altform4 = abchcf + "(" + aa / abchcf + "x.square" + bb / abchcf
+ "x" + cc / abchcf + ")";
setProgress(50);
altform5 = abchcf + "(" + "x" + "(" + aa / abchcf + "x" + bb
/ abchcf + ")" + cc / abchcf + ")";
if (abhcf != 1) {
t1.setText(altform1);
}
if (bchcf != 1) {
t2.setText(altform2);
}
if (achcf != 1) {
t3.setText(altform3);
}
if (abchcf != 1) {
t4.setText(altform4);
t5.setText(altform5);
}
}
private int HCF(int m, int n) {
// TODO Auto-generated method stub
int hcf = 0;
while (n != 0) {
hcf = n;
n = m % n;
n = hcf;
}
return hcf;
}
}
it has no errors but it takes much process and looks like hung and gives force close dialog any suggestion to process this?