Ejemplo n.º 1
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
      {
        if (State == 1) {
          // 创建退出对话框
          AlertDialog isExit = new AlertDialog.Builder(this).create();
          // 设置对话框标题
          isExit.setTitle("系统提示");
          // 设置对话框消息
          isExit.setMessage("确定要退出吗");
          // 添加选择按钮并注册监听
          isExit.setButton("确定", listener);
          isExit.setButton2("取消", listener);
          // 显示对话框
          isExit.show();
        } else if (State == 0) {
          State = 1;
          deleteAlarm.setVisibility(View.GONE);
          adapter.TYPE = 1;
          adapter.notifyDataSetChanged();
        }
      }

      return false;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 2
0
  // TODO
  // int[] channels = {58437, 77937, 110500, 112937, 58437, 77937, 110500, 58437, 77937, 110500};
  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    if (parent == mListView) {
      //            Log.d("shine", "list onItemSelected pos=" + position);
      Appreciatetv tv = (Appreciatetv) mListViewAdapter.getItem(position);
      if (tv != null) {
        mGallery.removeAllViewsInLayout();
        mGalleryAdapter.updateData(tv.getData());
        mGalleySelectedPosition = Integer.MAX_VALUE / 2 - 1;
        mGallery.setSelection(mGalleySelectedPosition);

        mListSelected = position;
        mListViewAdapter.notifyDataSetChanged();
      }

    } else {
      CategoryData data = mGalleryAdapter.getItem(position);
      mGalleySelectedPosition = position;
      mGalleryAdapter.notifyDataSetChanged();
    }
  }
Ejemplo n.º 3
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1 && resultCode == RESULT_OK) {
      long TimeInMillis = (long) data.getBundleExtra("data").getSerializable("time");
      Time atime = new Time(TimeInMillis);
      long realTimeInMillis = TimeUtils.changeTime(atime);
      Repeat RepeatDetail = (Repeat) data.getBundleExtra("data").getSerializable("repeat");
      Intent intent = new Intent(MainActivity.this, AlarmReceiver.class);
      intent.putExtras(data.getBundleExtra("data"));
      if (clockManage == null) {
        clockManage = new ClockManage(MainActivity.this);
      }
      Log.d("build", clockManage.getClocks().size() + "");
      PendingIntent pi =
          PendingIntent.getBroadcast(
              MainActivity.this,
              clockManage.getClocks().size(),
              intent,
              PendingIntent.FLAG_UPDATE_CURRENT); // 创建PendingIntent
      if (RepeatDetail == Repeat.ONLY_ONE) {
        alarmManager.set(AlarmManager.RTC_WAKEUP, realTimeInMillis, pi); // 设置闹钟
      } else if (RepeatDetail == Repeat.EVERY_DAY) {
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi);
      } else if (RepeatDetail == Repeat.MON2FIR) {
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi);
      }
      // 刷新界面
      adapter.TYPE = 1;
      adapter.refleshData();
      adapter.notifyDataSetChanged();
    }
    if (requestCode == 2 && resultCode == RESULT_OK) {
      boolean isopen = (boolean) data.getBundleExtra("data").getSerializable("isopen");
      if (isopen) { // 是否开启
        long TimeInMillis = (long) data.getBundleExtra("data").getSerializable("time");
        Time atime = new Time(TimeInMillis);
        long realTimeInMillis = TimeUtils.changeTime(atime);
        Repeat RepeatDetail = (Repeat) data.getBundleExtra("data").getSerializable("repeat");

        Intent intent = new Intent(MainActivity.this, AlarmReceiver.class);
        intent.putExtras(data.getBundleExtra("data"));
        if (clockManage == null) {
          clockManage = new ClockManage(MainActivity.this);
        }
        PendingIntent pi =
            PendingIntent.getBroadcast(
                MainActivity.this,
                clockManage.getClocks().size(),
                intent,
                PendingIntent.FLAG_UPDATE_CURRENT); // 创建PendingIntent
        if (RepeatDetail == Repeat.ONLY_ONE) {
          alarmManager.set(AlarmManager.RTC_WAKEUP, realTimeInMillis, pi); // 设置闹钟
        } else if (RepeatDetail == Repeat.EVERY_DAY) {
          alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi);
        } else if (RepeatDetail == Repeat.MON2FIR) {
          alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, realTimeInMillis, 10 * 1000, pi);
        }
      }
      // 刷新界面
      adapter.TYPE = 1;
      adapter.refleshData();
      adapter.notifyDataSetChanged();
    }
  }