use of com.zhan_dui.model.DownloadRecord in project AnimeTaste by daimajia.
the class PlayActivity method startPlayAnimation.
private void startPlayAnimation(final int start, Animation animation) {
final String playUrl = mSharedPreferences.getBoolean("use_hd", true) ? mAnimation.HDVideoUrl : mAnimation.CommonVideoUrl;
DownloadRecord record = DownloadRecord.getFromAnimation(mAnimation, true);
if (record != null) {
String path = record.SaveDir + record.SaveFileName;
File f = new File(path);
if (f.isFile() && f.exists()) {
mPrePlayButton.setVisibility(View.INVISIBLE);
mVideoAction.setVisibility(View.INVISIBLE);
mVV.setVideoPath(path);
mVV.seekTo(start);
mPlayBtn.setBackgroundResource(R.drawable.pause_btn_style);
mVV.start();
hideControls();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
return;
} else {
Toast.makeText(mContext, R.string.offline_file_missing, Toast.LENGTH_LONG).show();
}
}
startPlayAnimationFromNet(playUrl, mLastPos, animation);
}
use of com.zhan_dui.model.DownloadRecord in project AnimeTaste by daimajia.
the class DownloadAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView thumb;
TextView title, content, progress;
ViewHolder holder;
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.download_item, null);
thumb = (ImageView) convertView.findViewById(R.id.thumbImage);
title = (TextView) convertView.findViewById(R.id.title);
content = (TextView) convertView.findViewById(R.id.content);
progress = (TextView) convertView.findViewById(R.id.progress);
holder = new ViewHolder(title, progress, content, thumb);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
title = holder.title;
content = holder.content;
progress = holder.progress;
thumb = holder.thumb;
}
if (position > getCount() - 1) {
return null;
}
Object mission = getItem(position);
Animation animation = null;
if (mission instanceof DownloadRecord) {
animation = DownloadRecord.getAnimation((DownloadRecord) mission);
progress.setVisibility(View.INVISIBLE);
} else if (mission instanceof M3U8Mission) {
Mission m = (M3U8Mission) mission;
Object extra = m.getExtraInformation(m.getUri());
animation = (Animation) extra;
if (m.isDone()) {
progress.setVisibility(View.INVISIBLE);
} else {
progress.setVisibility(View.VISIBLE);
progress.setText(m.getReadablePercentage());
}
}
holder.animation = animation;
Picasso.with(mContext).load(animation.HomePic).placeholder(R.drawable.placeholder_thumb).error(R.drawable.placeholder_fail).into(thumb);
title.setText(animation.Name);
content.setText(animation.Brief);
return convertView;
}
use of com.zhan_dui.model.DownloadRecord in project AnimeTaste by daimajia.
the class DownloadActivity method onItemLongClick.
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Object obj = mDownloadList.getAdapter().getItem(position);
if (obj instanceof Mission) {
final Mission m = (Mission) obj;
show(R.string.tip, getString(R.string.stop_mission, m.getSaveName()), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mBinder.stopMission(m.getMissionID());
}
});
} else if (obj instanceof DownloadRecord) {
final DownloadRecord r = (DownloadRecord) obj;
String msg = getString(R.string.surely_delete, r.Name);
show(R.string.tip, msg, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String path = r.SaveDir + r.SaveFileName;
File f = new File(path);
if (f.exists() && f.isFile()) {
f.delete();
}
new Delete().from(DownloadRecord.class).where("AnimationId = ?", r.AnimationId).executeSingle();
DownloadAdapter adapter = (DownloadAdapter) mDownloadList.getAdapter();
adapter.reloadData();
}
});
}
return true;
}
use of com.zhan_dui.model.DownloadRecord in project AnimeTaste by daimajia.
the class PlayActivity method initContent.
private void initContent() {
mTitleTextView.setTypeface(mRobotoBold);
mAuthorTextView.setTypeface(mRobotoThin);
mTitleTextView.setText(mAnimation.Name);
mContentTextView.setText(mAnimation.Brief);
mAuthorTextView.setText(mAnimation.Author + " ยท " + mAnimation.Year);
mPrePlayButton.setOnClickListener(this);
mViewHolder.setOnTouchListener(this);
mCommentEditText.setOnClickListener(this);
if (getShareFile() != null) {
getShareFile().delete();
}
Picasso.with(mContext).load(mAnimation.DetailPic).placeholder(R.drawable.big_bg).into(this);
new Thread() {
@Override
public void run() {
super.run();
DownloadRecord record = DownloadRecord.getFromAnimation(mAnimation, true);
if (record != null) {
File file = new File(record.SaveDir + record.SaveFileName);
if (file.exists() && file.isFile()) {
toastHandler.sendEmptyMessage(0);
}
}
}
}.start();
}
Aggregations