Ejemplo n.º 1
0
  private void deleteDialog(final VideoModel model) {
    new AlertDialog.Builder(context)
        .setTitle(context.getString(R.string.wifi_tip))
        .setMessage(context.getString(R.string.study_record_delete_tip))
        .setPositiveButton(
            context.getString(R.string.sure),
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                DownloadTaskManager.getInstance(context).deleteTask(model);
                VideoDAO videoDAO = new VideoDAO(context);
                videoDAO.remove(model.getId());
                if (model.getVideoPath() != null) {
                  File file = new File(model.getVideoPath());
                  if (file != null && file.exists()) {
                    file.delete();
                  }
                }
                context.initDBData();
                if (deleteListener != null) {
                  deleteListener.doDelete();
                }
              }
            })
        .setNegativeButton(
            context.getString(R.string.cancel),
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {}
            })
        .create()
        .show();
  }
Ejemplo n.º 2
0
  private void startTask(final VideoModel model) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    if (wifiManager.isWifiEnabled()) {
      DownloadTaskManager.getInstance(context).startOneTask(model);
    } else {
      if (SettingUtil.getWifiDoSomeThing(context)) {
        new AlertDialog.Builder(context)
            .setTitle(context.getString(R.string.wifi_tip))
            .setMessage(context.getResources().getString(R.string.study_record_3G_tip))
            .setPositiveButton(
                context.getResources().getString(R.string.downlaod),
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    DownloadTaskManager.getInstance(context).startOneTask(model);
                  }
                })
            .setNegativeButton(
                context.getString(R.string.cancel),
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {}
                })
            .create()
            .show();
      } else {
        new AlertDialog.Builder(context)
            .setTitle(context.getString(R.string.wifi_tip))
            .setMessage(context.getResources().getString(R.string.this_video_not_to_download))
            .setPositiveButton(
                context.getResources().getString(R.string.sure),
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    //										DownloadTaskManager.getInstance(context).startOneTask(model);
                  }
                })
            .create()
            .show();
      }
    }
  }