Exemple #1
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_opic);
    Log.d("testing2", "wow1");
    initBluetoothConnection();
    bindAccessoryService();
    settingButton = (ImageButton) findViewById(R.id.opic_setting);
    // BluetoothButton= (ImageButton)findViewById(R.id.bluetooth_opic);
    // backButton=(Button)findViewById(R.id.back_opic);
    // opic_text = (EditText)findViewById(R.id.op);
    opic_time_display = (TextView) findViewById(R.id.opic_time_display);
    opic_prepare_display = (TextView) findViewById(R.id.opic_prepare_display);
    opic_num_display = (EditText) findViewById(R.id.practice_num_opic);
    startButton = (ImageButton) findViewById(R.id.opic_start_please);
    bluetooth_switch = (Switch) findViewById(R.id.bluetooth_opic);
    opic_num_display.setText((String.valueOf(Global_Variable.get_gloval_opic_num())));
    settingButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            Intent intent = new Intent(opicActivity.this, opic_settingActivity.class);
            startActivityForResult(intent, 1);

            JSONObject obj[];

            JSONObject obj1 = new JSONObject();
            JSONObject obj2 = new JSONObject();
            JSONObject obj3 = new JSONObject();
            JSONObject obj4 = new JSONObject();
            JSONObject obj5 = new JSONObject();
            JSONObject obj6 = new JSONObject();
            JSONObject obj7 = new JSONObject();
            JSONObject obj8 = new JSONObject();
            JSONObject obj9 = new JSONObject();
            JSONObject obj10 = new JSONObject();
            JSONObject obj11 = new JSONObject();
            JSONObject obj12 = new JSONObject();
            JSONObject obj13 = new JSONObject();
            JSONObject obj14 = new JSONObject();
            JSONObject obj15 = new JSONObject();

            try {
              obj1.put("title", "Problem 1");
              obj1.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj1);
              obj2.put("title", "Problem 2");
              obj2.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj2);
              obj3.put("title", "Problem 3");
              obj3.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj3);
              obj4.put("title", "Problem 4");
              obj4.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj4);
              obj5.put("title", "Problem 5");
              obj5.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj5);
              obj6.put("title", "Problem 6");
              obj6.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj6);
              obj7.put("title", "Problem 7");
              obj7.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj7);
              obj8.put("title", "Problem 8");
              obj8.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj8);
              obj9.put("title", "Problem 9");
              obj9.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj9);
              obj10.put("title", "Problem 10");
              obj10.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj10);
              obj11.put("title", "Problem 11");
              obj11.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj11);
              obj12.put("title", "Problem 12");
              obj12.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj12);
              obj13.put("title", "Problem 13");
              obj13.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj13);
              obj14.put("title", "Problem 14");
              obj14.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj14);
              obj15.put("title", "Problem 15");
              obj15.put(
                  "time",
                  String.valueOf(
                      (Global_Variable.get_gloval_opic_speaking_prepare()
                              + Global_Variable.get_gloval_opic_speaking_min() * 60
                              + Global_Variable.get_gloval_opic_speaking_sec())
                          * 1000));
              jsonArray.put(obj15);
            } catch (JSONException e) {
              e.printStackTrace();
            }

            Log.d("testing2", "wow");
            opic_prepare_display.setText(
                (String.valueOf(Global_Variable.get_gloval_opic_speaking_prepare() + "sec")));
            opic_time_display.setText(
                (String.valueOf(
                    Global_Variable.get_gloval_opic_speaking_min()
                        + "min"
                        + Global_Variable.get_gloval_opic_speaking_sec()
                        + "sec")));
          }
        });

    bluetooth_switch.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if (isChecked) {
              initBluetoothConnection();
              bindAccessoryService();
              // isconnect = true;
              startConnection();
            } else {
              // isconnect = false;
              // unbindAccessoryService();
            }
          }
        });
    startButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            sendDataToService(jsonArray.toString());

            Intent intent = new Intent(opicActivity.this, opic_display_activity.class);
            startActivity(intent);
          }
        });
  }
Exemple #2
0
  protected void onCreate(Bundle savedInstanceState) {
    Log.d("tag", "yoyo5");
    super.onCreate(savedInstanceState);
    Log.d("tag", "yoyo6");
    setContentView(R.layout.layout_toeic_setting);
    Log.d("tag", "yoyo7");

    toeic_setting_button = (ImageButton) findViewById(R.id.toeic_setting_save);
    toeic_reset_button = (ImageButton) findViewById(R.id.toeic_setting_reset);
    part5_min_toeic = (EditText) findViewById(R.id.part5_min_toeic);
    part5_sec_toeic = (EditText) findViewById(R.id.part5_sec_toeic);
    part6_min_toeic = (EditText) findViewById(R.id.part6_min_toeic);
    part6_sec_toeic = (EditText) findViewById(R.id.part6_sec_toeic);
    part7_min_toeic = (EditText) findViewById(R.id.part7_min_toeic);
    part7_sec_toeic = (EditText) findViewById(R.id.part7_sec_toeic);

    part5_min_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part5())));
    part6_min_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part6())));
    part7_min_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part7())));
    part5_sec_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part5_sec())));
    part6_sec_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part6_sec())));
    part7_sec_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part7_sec())));

    Log.d("testing", part5_min_toeic.getText().toString());
    toeic_setting_button.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            Global_Variable.set_gloval_toeic_part5(
                Integer.parseInt(part5_min_toeic.getText().toString()),
                Integer.parseInt(part5_sec_toeic.getText().toString()));
            Global_Variable.set_gloval_toeic_part6(
                Integer.parseInt(part6_min_toeic.getText().toString()),
                Integer.parseInt(part6_sec_toeic.getText().toString()));
            Global_Variable.set_gloval_toeic_part7(
                Integer.parseInt(part7_min_toeic.getText().toString()),
                Integer.parseInt(part7_sec_toeic.getText().toString()));
            Log.d("testing3", "int" + Global_Variable.get_global_toeic_part5() + "value");
            setResult(RESULT_OK, null);
            finish();
          }
        });

    toeic_reset_button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Log.d("tag", "yoyo3");
            Global_Variable.reset_gloval_toeic_part5();
            Global_Variable.reset_gloval_toeic_part6();
            Global_Variable.reset_gloval_toeic_part7();
            part5_min_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part5())));
            part6_min_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part6())));
            part7_min_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part7())));
            part5_sec_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part5_sec())));
            part6_sec_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part6_sec())));
            part7_sec_toeic.setText((String.valueOf(Global_Variable.get_gloval_toeic_part7_sec())));
          }
        });
  }