コード例 #1
0
  /** 插入影片下载数据 */
  public synchronized long insertMovieStore(DownLoadInfo downLoadInfo) {
    if (isStoreByUrl(downLoadInfo.getDownUrl())) return PipiPlayerConstant.ISEXIT_NORMOL;
    long sec = -1;
    try {
      ContentValues values = new ContentValues();
      values.put(TableName.MovieID, downLoadInfo.getDownID());
      values.put(TableName.MovieName, downLoadInfo.getDownName());
      values.put(TableName.MovieImgUrl, downLoadInfo.getDownImg());
      values.put(TableName.MovieUrl, downLoadInfo.getDownUrl());
      values.put(TableName.MoviePlaySourKey, downLoadInfo.getDownTag());

      ArrayList<String> list = downLoadInfo.getPlayList();
      JSONArray array = new JSONArray();
      for (String string : list) array.put(string);

      values.put(TableName.MoviePlayList, array.toString());
      values.put(TableName.MoviePlayPosition, downLoadInfo.getDownPosition());
      Log.i("TAG999", "insertMovieStore MoviePlayPosition===" + downLoadInfo.getDownPosition());
      database = pipiDBHelp.getWritableDatabase();
      sec = database.insert(PipiDBHelp.STORE_TABLENAME, null, values);
    } catch (Exception e) {
      // TODO: handle exception
    }
    return sec;
  }
コード例 #2
0
 /** sMovieUrl 插入影片历史数据 */
 public synchronized long insertMovieHistroy(DownLoadInfo downInfo) {
   long sec = -1;
   try {
     ContentValues values = new ContentValues();
     values.put(TableName.MovieID, downInfo.getDownID());
     values.put(TableName.MovieName, downInfo.getDownName());
     values.put(TableName.MovieImgUrl, downInfo.getDownImg());
     values.put(TableName.MovieUrl, StringUtils.getDate()); // MovieUrl 在此处替代插入时间
     values.put(TableName.MoviePlaySourKey, downInfo.getDownTag());
     values.put(TableName.MoviePlayProgress, downInfo.getDownProgress());
     values.put(TableName.MovieSize, downInfo.getDownTotalSize());
     values.put(TableName.MoviePlayPosition, downInfo.getDownPosition());
     values.put(TableName.MovieLocalUrl, downInfo.getDownPath());
     database = pipiDBHelp.getWritableDatabase();
     Log.i(
         "TAG999",
         "insertMovieHistroy  = "
             + downInfo.getDownPosition()
             + "*******"
             + downInfo.getDownProgress());
     if (isMovieHistroyByID(downInfo.getDownID())) { // 存在记录,删除记录
       //	sec = database.update(PipiDBHelp.HISTROY_TABLENAME, values, "sMovieID=?",
       //			new String[]{downInfo.getDownID()});
       sec =
           database.delete(
               PipiDBHelp.HISTROY_TABLENAME, "sMovieID=?", new String[] {downInfo.getDownID()});
     }
     sec = database.insert(PipiDBHelp.HISTROY_TABLENAME, null, values);
   } catch (Exception e) {
     // TODO: handle exception
   }
   return sec;
 }
コード例 #3
0
 /** 影片收藏 */
 public synchronized long insertMovieSave(DownLoadInfo info) {
   if (isMovieSaveByID(info.getDownID())) return PipiPlayerConstant.ISEXIT_NORMOL;
   long sec = -1;
   try {
     ContentValues values = new ContentValues();
     values.put(TableName.MovieID, info.getDownID());
     values.put(TableName.MovieName, info.getDownName());
     values.put(TableName.MovieImgUrl, info.getDownImg());
     database = pipiDBHelp.getWritableDatabase();
     sec = database.insert(PipiDBHelp.SAVE_TABLENAME, null, values);
   } catch (Exception e) {
     // TODO: handle exception
   }
   return sec;
 }
コード例 #4
0
  public View getView(final int position, View convertView, ViewGroup vg) {
    // TODO Auto-generated method stub
    ViewHolder holder;

    if (convertView != null) {
      holder = (ViewHolder) convertView.getTag();
      holder.moive_img.setImageResource(R.drawable.item_moive_list); // 设置默认图片,避免�?成图片看起来混乱
    } else {
      holder = new ViewHolder();
      convertView = inflate.inflate(R.layout.item_play_history, null);
      holder.title = (TextView) convertView.findViewById(R.id.moive_title);
      holder.moive_img = (ImageView) convertView.findViewById(R.id.moive_img);
      holder.delete = (CheckBox) convertView.findViewById(R.id.delete);
      convertView.setTag(holder);
    }
    holder.moive_img.setImageResource(R.drawable.item_moive_list); // 设置默认图片,避免造成图片看起来混乱
    if (list == null || list.size() == 0 || position < 0 || position >= list.size())
      return convertView;
    final DownLoadInfo downInfo = list.get(position);
    holder.title.setText(downInfo.getDownName());

    bmpManager.loadBitmap(downInfo.getDownImg(), holder.moive_img);

    // 删除按钮
    if (!deleteVisible) holder.delete.setVisibility(8);
    else {
      holder.delete.setVisibility(0);
      holder.delete.setChecked(downInfo.isDelete()); //
      holder.delete.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              // TODO Auto-generated method stub
              downInfo.setDelete(!downInfo.isDelete());

              Message message = new Message();
              message.what = DELETElAYOUT;
              message.obj = getSeleteCount();
              handler.sendMessage(message);
            }
          });
    }

    return convertView;
  }
コード例 #5
0
ファイル: DownCenter.java プロジェクト: weimingtom/pipiplayer
 // 文件合并
 @SuppressWarnings("resource")
 public synchronized boolean GetFileMerge(final DownLoadInfo downInfo) {
   String parent = HtmlUtils.getFileDir(downInfo);
   final List<String> list = new ArrayList<String>();
   File file = new File(parent);
   if (!file.exists()) return true;
   // 检索要合并的文件名,不合格的剔除
   File[] childFiles =
       file.listFiles(
           new FileFilter() {
             public boolean accept(File pathname) {
               return pathname.getName().startsWith(downInfo.getDownName())
                   && !pathname.getName().endsWith(".ts");
             }
           });
   if (childFiles != null) {
     // 文件片段多于一个才需要合并
     String filePath = null;
     for (File file1 : childFiles) {
       filePath = file1.getAbsolutePath();
       list.add(filePath);
     }
     if (list.size() == 1) {
       DBHelperDao.getDBHelperDaoInstace().updataMovieStoreLocal(downInfo.getDownUrl(), filePath);
     } else {
       DBHelperDao.getDBHelperDaoInstace()
           .updataMovieStoreState(downInfo.getDownUrl(), DownTask.TASK_FileMerge);
       downInfo.setDownState(DownTask.TASK_FileMerge);
       String mp4filepath = null;
       if (filePath.endsWith(".flv")) {
         mp4filepath =
             parent
                 + "/"
                 + downInfo.getDownName()
                 + String.format("%03d", downInfo.getDownPosition())
                 + ".flv";
       } else {
         mp4filepath =
             parent
                 + "/"
                 + downInfo.getDownName()
                 + String.format("%03d", downInfo.getDownPosition())
                 + ".mp4";
       }
       final String[] filearray = list.toArray(new String[list.size()]);
       Arrays.sort(filearray); // 排序
       try {
         mlibvlc.nativeFileMerge(mp4filepath, filearray, false);
         // GetFileMergeStart(list, mp4filepath);
         // 合并完文件在更新数据库信息
         FileInputStream stream = new FileInputStream(mp4filepath);
         if (stream != null) {
           long size = stream.available();
           downInfo.setDownTotalSize(size);
           downInfo.setDownLocal(downInfo.getDownUrl());
           DBHelperDao.getDBHelperDaoInstace().updataMovieStoreSize(downInfo.getDownUrl(), size);
           DBHelperDao.getDBHelperDaoInstace()
               .updataMovieStoreLocal(downInfo.getDownUrl(), mp4filepath);
           downInfo.setDownState(DownTask.TASK_FINISHED);
           DBHelperDao.getDBHelperDaoInstace()
               .updataMovieStoreState(downInfo.getDownUrl(), DownTask.TASK_FINISHED);
           // 合并完成 删除源文件
           new Thread(
                   new Runnable() {
                     @Override
                     public void run() {
                       // TODO Auto-generated method stub
                       for (String fileName : list) {
                         FileUtils.deleteFile(fileName);
                       }
                     }
                   })
               .start();
         }
       } catch (Exception e) {
         // TODO: handle exception
         e.printStackTrace();
         return false;
       }
     }
   }
   return true;
 }