OSDN Git Service

Format & Organize imports
authoreagletmt <eagletmt@gmail.com>
Wed, 10 Oct 2012 12:11:59 +0000 (21:11 +0900)
committereagletmt <eagletmt@gmail.com>
Wed, 10 Oct 2012 12:11:59 +0000 (21:11 +0900)
QA/src/jp/ac/titech/sharp4k/cuten/QAActivity.java
QA/src/jp/ac/titech/sharp4k/cuten/sampletask/QATask.java

index c41c935..237de91 100644 (file)
@@ -1,19 +1,16 @@
 package jp.ac.titech.sharp4k.cuten;
 
-import javax.xml.datatype.Duration;
-
-import jp.ac.titech.sharp4k.cuten.sampletask.*;
-import android.R;
+import jp.ac.titech.sharp4k.cuten.sampletask.QATask;
 import android.app.Activity;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.Toast;
 
-public class QAActivity extends Activity implements ResultSender,OnClickListener {
+public class QAActivity extends Activity implements ResultSender,
+               OnClickListener {
        private static String TAG = "QA";
        private BaseApp taskApp;
 
@@ -37,10 +34,12 @@ public class QAActivity extends Activity implements ResultSender,OnClickListener
                layout.addView(taskApp.createView(this, this.getResources()));
                setContentView(layout);
        }
+
        @Override
        public void onClick(View v) {
                taskApp.onClose();
        }
+
        @Override
        public void send(int[] results) {
                String str = "";
index 65d7f10..0fd9eda 100644 (file)
@@ -19,17 +19,18 @@ public class QATask extends BaseApp {
        private RadioGroup[] choices;
        private int num;
        private Resources res;
+
        @Override
        protected View createView(Context ctx, Resources res) {
                this.ctx = ctx;
                this.res = res;
-               ScrollView root=new ScrollView(ctx);
-               HorizontalScrollView rootChild=new HorizontalScrollView(ctx);
+               ScrollView root = new ScrollView(ctx);
+               HorizontalScrollView rootChild = new HorizontalScrollView(ctx);
                root.addView(rootChild);
                LinearLayout body = new LinearLayout(ctx);
                body.setOrientation(LinearLayout.VERTICAL);
                rootChild.addView(body);
-               
+
                TextView tv = new TextView(ctx);
                String message = res.getString(R.string.first);
                tv.setText(message);
@@ -37,13 +38,14 @@ public class QATask extends BaseApp {
                //
                String[] questions = res.getStringArray(R.array.questions);
                TypedArray typedArray = res.obtainTypedArray(R.array.choices);
-               num=(questions.length<typedArray.length())?questions.length:typedArray.length();
-               choices=new RadioGroup[num];
-               for (int n = 0; n <num ; n++) {
+               num = (questions.length < typedArray.length()) ? questions.length
+                               : typedArray.length();
+               choices = new RadioGroup[num];
+               for (int n = 0; n < num; n++) {
                        TextView text = new TextView(ctx);
                        text.setText(questions[n]);
                        RadioGroup radioGroup = new RadioGroup(ctx);
-                       choices[n]=radioGroup;
+                       choices[n] = radioGroup;
                        radioGroup.setOrientation(LinearLayout.HORIZONTAL);
                        int id = typedArray.getResourceId(n, 0);
                        String[] names = res.getStringArray(id);
@@ -57,25 +59,26 @@ public class QATask extends BaseApp {
                        body.addView(radioGroup);
                }
                //
-               
+
                return root;
        }
+
        @Override
        protected void onClose() {
-               int[] choicesId =new int [num];
-               for(int i=0;i<num;i++){
-                       choicesId[i]=choices[i].getCheckedRadioButtonId();
+               int[] choicesId = new int[num];
+               for (int i = 0; i < num; i++) {
+                       choicesId[i] = choices[i].getCheckedRadioButtonId();
                }
                int[] answers = res.getIntArray(R.array.answers);
-               num=(answers.length < num)?answers.length:num;
-               int correctCount=0;
-               for(int i=0;i<num;i++){
-                       if(answers[i]==choicesId[i]){
+               num = (answers.length < num) ? answers.length : num;
+               int correctCount = 0;
+               for (int i = 0; i < num; i++) {
+                       if (answers[i] == choicesId[i]) {
                                correctCount++;
                        }
                }
-               int res=correctCount*100/num;
-               int[] result={res};
+               int res = correctCount * 100 / num;
+               int[] result = { res };
                sendResult(result);
                super.onClose();
        }