コード例 #1
0
ファイル: studyWord.java プロジェクト: zinsser/KingSpace
  public void onClick(View v) {
    Log.i("3", "3");
    this.UpdateView();
    Log.i("3", "3");
    if (v == nextone) {
      if (currentnum < numoflist) {
        currentnum++;
        this.UpdateView();
      }

    } else if (v == add) {
      DataAccess data = new DataAccess(studyWord.this);
      ArrayList<Word> attention = new ArrayList<Word>();
      attention =
          data.QueryAttention("SPELLING ='" + list.get(currentnum).getSpelling() + "'", null);
      if (attention.size() == 0) {
        data.InsertIntoAttention(list.get(currentnum));
        Toast.makeText(studyWord.this, "已加入生词本", Toast.LENGTH_SHORT).show();
      } else Toast.makeText(studyWord.this, "生词本中已包含这个单词!", Toast.LENGTH_SHORT).show();

    } else if (v == beforeone) {
      currentnum--;
      this.UpdateView();
    }
    Log.i("3", "3");
    if (v == speak) {
      tts.speak(list.get(currentnum).getSpelling(), TextToSpeech.QUEUE_ADD, null);
    }
    Log.i("3", "3");
  }
コード例 #2
0
ファイル: studyWord.java プロジェクト: zinsser/KingSpace
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.studyword);
    currentnum = 0;
    Intent intent = getIntent();

    Bundle b = intent.getExtras();
    String name = b.getString("list");
    listnum = name;
    this.setTitle("学习LIST-" + name);
    DataAccess data = new DataAccess(this);
    list = data.QueryWord("LIST = '" + name + "'", null);
    numoflist = list.size();
    initWidgets();
    UpdateView();
  }
コード例 #3
0
ファイル: studyWord.java プロジェクト: zinsser/KingSpace
  private void UpdateView() {
    if (currentnum == 0) {
      beforeone.setEnabled(false);
    } else if (currentnum > 0) {
      beforeone.setEnabled(true);
    }
    SharedPreferences setting = getSharedPreferences("wordroid.model_preferences", MODE_PRIVATE);
    if (setting.getBoolean("iftts", false)) {
      Thread thread =
          new Thread(
              new Runnable() {
                public void run() {
                  try {
                    Thread.sleep(500);
                    tts.speak(list.get(currentnum).getSpelling(), TextToSpeech.QUEUE_FLUSH, null);
                  } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
                }
              });
      thread.start();
    }

    // TODO Auto-generated method stub
    if (currentnum < numoflist) {
      spelling.setText(list.get(currentnum).getID() + "." + list.get(currentnum).getSpelling());
      info.setText(
          list.get(currentnum).getPhonetic_alphabet() + "\n" + list.get(currentnum).getMeanning());
    } else if (currentnum >= numoflist) {
      DataAccess data = new DataAccess(this);
      WordList wordlist =
          data.QueryList("BOOKID ='" + DataAccess.bookID + "'AND LIST = '" + listnum + "'", null)
              .get(0);
      wordlist.setLearned("1");
      wordlist.setReview_times("0");
      wordlist.setReviewTime("");
      Calendar cal = Calendar.getInstance();
      SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
      String date = f.format(cal.getTime());
      wordlist.setLearnedTime(date);
      data.UpdateList(wordlist);

      currentnum--;

      Dialog dialog =
          new AlertDialog.Builder(this)
              .setIcon(R.drawable.dialog_icon)
              .setTitle("学习已完成")
              .setMessage("您可以依照复习计划进行本单元的复习")
              .setPositiveButton(
                  "确定",
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                      /* User clicked OK so do some stuff */
                      tts.shutdown();
                      finish();
                      Intent intent = new Intent();
                      intent.setClass(studyWord.this, study.class);
                      startActivity(intent);
                    }
                  })
              .create();
      dialog.show();
    }
  }