Beispiel #1
0
  /** 得到影片历史列表 */
  public synchronized List<DownLoadInfo> getSmovieHistroy() {

    List<DownLoadInfo> resultsInfos = new ArrayList<DownLoadInfo>();
    String sql =
        "select  *  from "
            + PipiDBHelp.HISTROY_TABLENAME
            + " order by "
            + TableName.Movie_ID
            + " desc";
    try {
      database = pipiDBHelp.getWritableDatabase();
      cursor = database.rawQuery(sql, null);
      if (cursor != null && cursor.getCount() != 0) {
        while (cursor.moveToNext()) {
          DownLoadInfo downInfo = new DownLoadInfo();
          downInfo.setDownID(cursor.getString(cursor.getColumnIndex("sMovieID")));
          downInfo.setDownName(cursor.getString(cursor.getColumnIndex("sMovieName")));
          downInfo.setDownImg(cursor.getString(cursor.getColumnIndex("sMovieImgUrl")));
          downInfo.setDownUrl(cursor.getString(cursor.getColumnIndex("sMovieUrl")));
          downInfo.setDownTotalSize(cursor.getInt(cursor.getColumnIndex("sMovieSize")));
          downInfo.setDownProgress(cursor.getInt(cursor.getColumnIndex("sMoviePlayProgress")));
          downInfo.setDownState(cursor.getInt(cursor.getColumnIndex("sMovieLoadState")));
          downInfo.setDownTag(cursor.getString(cursor.getColumnIndex(TableName.MoviePlaySourKey)));
          downInfo.setDownPath(cursor.getString(cursor.getColumnIndex("sMovieLocalUrl")));
          downInfo.setDownPosition(
              cursor.getInt(cursor.getColumnIndex(TableName.MoviePlayPosition)));
          resultsInfos.add(downInfo);
        }
      }

    } catch (Exception e) {
      // TODO: handle exception
    } finally {
      closeCursor();
    }
    return resultsInfos;
  }
Beispiel #2
0
  /** 得到影片下载列表 */
  public synchronized List<DownLoadInfo> getSmovieStores() {

    List<DownLoadInfo> resultsInfos = new ArrayList<DownLoadInfo>();
    String sql =
        "select  *  from "
            + PipiDBHelp.STORE_TABLENAME
            + " order by "
            + TableName.Movie_ID
            + " desc ";
    try {
      database = pipiDBHelp.getWritableDatabase();
      cursor = database.rawQuery(sql, null);
      if (cursor != null && cursor.getCount() != 0) {
        while (cursor.moveToNext()) {
          DownLoadInfo downInfo = new DownLoadInfo();
          downInfo.setDownID(cursor.getString(cursor.getColumnIndex("sMovieID")));
          downInfo.setDownName(cursor.getString(cursor.getColumnIndex("sMovieName")));
          downInfo.setDownImg(cursor.getString(cursor.getColumnIndex("sMovieImgUrl")));
          downInfo.setDownUrl(cursor.getString(cursor.getColumnIndex("sMovieUrl")));
          downInfo.setDownTotalSize(cursor.getLong(cursor.getColumnIndex("sMovieSize")));
          downInfo.setDownProgress(cursor.getLong(cursor.getColumnIndex("sMoviePlayProgress")));
          downInfo.setDownState(cursor.getInt(cursor.getColumnIndex("sMovieLoadState")));
          downInfo.setDownPosition(
              cursor.getInt(cursor.getColumnIndex(TableName.MoviePlayPosition)));
          downInfo.setDownTag(cursor.getString(cursor.getColumnIndex(TableName.MoviePlaySourKey)));
          String path = cursor.getString(cursor.getColumnIndex("sMovieLocalUrl"));
          downInfo.setDownPath(path);
          JSONArray array;
          try {
            array = new JSONArray(cursor.getString(cursor.getColumnIndex("sMoviePlayList")));
            ArrayList<String> list = new ArrayList<String>();
            for (int i = 0; i < array.length(); i++) list.add(array.getString(i));

            downInfo.setPlayList(list);
          } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          // 下载片段索引
          if (!TextUtils.isEmpty(path)) {
            try {
              File file = new File(path);
              if (file != null && file.isDirectory()) {
                downInfo.setDownIndex(
                    file.listFiles().length - 1 > 0 ? file.listFiles().length - 1 : 0);
              }
            } catch (Exception e) {
              // TODO: handle exception
            }
          }

          resultsInfos.add(downInfo);
        }
      }
    } catch (Exception e) {
      // TODO: handle exception
    } finally {
      closeCursor();
    }
    return resultsInfos;
  }
Beispiel #3
0
  public synchronized List<DownTask> getActiveDownLoad() {
    List<DownTask> mDownLoadTaskList = new ArrayList<DownTask>();
    SQLiteDatabase database = null;
    Cursor cursor = null;
    String sql = "select  *  from " + PipiDBHelp.STORE_TABLENAME;

    try {
      database = pipiDBHelp.getReadableDatabase();
      cursor = database.rawQuery(sql, null);
      while (cursor.moveToNext()) {

        DownLoadInfo downInfo = new DownLoadInfo();
        downInfo.setDownID(cursor.getString(cursor.getColumnIndex("sMovieID")));
        downInfo.setDownName(cursor.getString(cursor.getColumnIndex("sMovieName")));
        downInfo.setDownImg(cursor.getString(cursor.getColumnIndex("sMovieImgUrl")));
        downInfo.setDownUrl(cursor.getString(cursor.getColumnIndex("sMovieUrl")));
        downInfo.setDownTotalSize(cursor.getLong(cursor.getColumnIndex("sMovieSize")));
        downInfo.setDownProgress(cursor.getLong(cursor.getColumnIndex("sMoviePlayProgress")));
        downInfo.setDownState(cursor.getInt(cursor.getColumnIndex("sMovieLoadState")));
        downInfo.setDownPosition(cursor.getInt(cursor.getColumnIndex(TableName.MoviePlayPosition)));
        downInfo.setDownTag(cursor.getString(cursor.getColumnIndex(TableName.MoviePlaySourKey)));
        String path = cursor.getString(cursor.getColumnIndex("sMovieLocalUrl"));
        downInfo.setDownPath(path);
        JSONArray array;
        try {
          array = new JSONArray(cursor.getString(cursor.getColumnIndex("sMoviePlayList")));
          ArrayList<String> list = new ArrayList<String>();
          for (int i = 0; i < array.length(); i++) list.add(array.getString(i));

          downInfo.setPlayList(list);
          // 下载片段索引
          if (!TextUtils.isEmpty(path)) {
            try {
              File file = new File(path);
              if (file != null && file.isDirectory()) {
                downInfo.setDownIndex(
                    file.listFiles().length - 1 > 0 ? file.listFiles().length - 1 : 0);
              }
            } catch (Exception e) {
              // TODO: handle exception
            }
          }
        } catch (JSONException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

        DownTask task = new DownTask(downInfo);
        if (downInfo.getDownState() == DownTask.TASK_FileMerge) {
          // task.finish();//上次未合并完的再次进行合并
        } else if (downInfo.getDownState() != DownTask.TASK_FINISHED) // 已经下载完的
        downInfo.setDownState(DownTask.TASK_PAUSE_DOWNLOAD); // 未下载完的标示为暂停,让用户主动去下�?
        mDownLoadTaskList.add(task);
      }
    } finally {
      if (cursor != null) {
        cursor.close();
      }
      database.close();
    }
    return mDownLoadTaskList;
  }