use of com.zhan_dui.model.Animation in project AnimeTaste by daimajia.
the class LoadActivity method init.
private void init() {
if (getIntent().getAction().equals(Intent.ACTION_VIEW)) {
Uri uri = getIntent().getData();
if (uri == null) {
error();
}
String vid = uri.getQueryParameter("vid");
int animationId = Integer.valueOf(vid);
ApiConnector.instance().getDetail(animationId, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, final JSONObject response) {
super.onSuccess(statusCode, response);
try {
if (statusCode == 200 && response.has("data") && response.getJSONObject("data").has("result") && response.getJSONObject("data").getBoolean("result")) {
final JSONObject anime = response.getJSONObject("data").getJSONObject("anime");
new Thread() {
@Override
public void run() {
super.run();
MobclickAgent.onEvent(mContext, "yell");
final Intent intent = new Intent(mContext, PlayActivity.class);
Animation animation = Animation.build(anime);
intent.putExtra("Animation", animation);
runOnUiThread(new Runnable() {
@Override
public void run() {
startActivity(intent);
finish();
}
});
}
}.start();
} else {
error();
}
} catch (Exception e) {
e.printStackTrace();
error();
}
}
@Override
public void onFailure(Throwable throwable, JSONArray jsonArray) {
super.onFailure(throwable, jsonArray);
error();
}
@Override
public void onFinish() {
super.onFinish();
}
});
} else {
ApiConnector.instance().getInitData(20, 5, 2, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, final JSONObject response) {
super.onSuccess(response);
if (statusCode == 200 && response.has("data")) {
Message msg = Message.obtain();
msg.obj = response;
executeHandler.sendMessage(msg);
} else {
error();
}
}
@Override
public void onFailure(Throwable error) {
super.onFailure(error);
error();
}
});
}
}
use of com.zhan_dui.model.Animation in project AnimeTaste by daimajia.
the class PlayActivity method onClick.
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.pre_play_button:
startPlayAnimation(mLastPos, mAnimation);
break;
case R.id.play_btn:
if (mVV.isPlaying()) {
mPlayBtn.setBackgroundResource(R.drawable.play_btn_style);
pausePlay();
} else {
mPlayBtn.setBackgroundResource(R.drawable.pause_btn_style);
restorePlay();
}
mController.setVisibility(View.INVISIBLE);
break;
case R.id.comment_edit_text:
comment();
break;
case R.id.recommend_item:
stopPlay();
Animation animation = (Animation) v.getTag();
Intent intent = new Intent(mContext, PlayActivity.class);
intent.putExtra("Animation", animation);
mContext.startActivity(intent);
MobclickAgent.onEvent(mContext, "recommend");
finish();
break;
case R.id.zoom_btn:
if (mCurrentScape == OrientationHelper.LANDSCAPE) {
setMinSize();
} else {
setMaxSize();
}
break;
default:
break;
}
}
use of com.zhan_dui.model.Animation in project AnimeTaste by daimajia.
the class StartActivity method init.
public void init(Intent intent) {
ArrayList<Animation> Animations = intent.getParcelableArrayListExtra("Animations");
ArrayList<Category> Categories = intent.getParcelableArrayListExtra("Categories");
mAdvertises = intent.getParcelableArrayListExtra("Advertises");
ArrayList<Animation> Recommends = intent.getParcelableArrayListExtra("Recommends");
mRecommendAdapter = new RecommendAdapter(mContext, mAdvertises, Recommends);
mRecommendPager.setAdapter(mRecommendAdapter);
mRecommendIndicator.setViewPager(mRecommendPager);
mVideoAdapter = AnimationListAdapter.build(mContext, Animations);
mVideoList.setAdapter(mVideoAdapter);
CategoryListAdapter categoryListAdapter = new CategoryListAdapter(mContext, Categories);
mCategoryList.setAdapter(categoryListAdapter);
ViewUtils.setListViewHeightBasedOnChildren(mCategoryList);
}
use of com.zhan_dui.model.Animation in project AnimeTaste by daimajia.
the class MissionListenerForNotification method onError.
@Override
public void onError(M3U8Mission mission, Exception e) {
e.printStackTrace();
Animation animation = (Animation) mission.getExtraInformation(mission.getUri());
notifyBuilder = new NotificationCompat.Builder(context).setSmallIcon(android.R.drawable.stat_sys_download).setContentTitle(mission.getShowName()).setContentText(context.getString(R.string.download_error)).setContentInfo(mission.getPercentage() + "%").setContentIntent(contentPendingIntent).setOngoing(false);
notificationManager.notify(mission.getMissionID(), notifyBuilder.build());
MobclickAgent.onEvent(context, "download_failed");
}
use of com.zhan_dui.model.Animation in project AnimeTaste by daimajia.
the class AnimationListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView titleTextView;
TextView contentTextView;
ImageView thumbImageView;
ViewHolder holder;
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.video_item, parent, false);
titleTextView = (TextView) convertView.findViewById(R.id.title);
contentTextView = (TextView) convertView.findViewById(R.id.content);
thumbImageView = (ImageView) convertView.findViewById(R.id.thumb);
titleTextView.setTypeface(mRobotoTitle);
holder = new ViewHolder(titleTextView, contentTextView, thumbImageView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
titleTextView = holder.titleText;
contentTextView = holder.contentText;
thumbImageView = holder.thumbImageView;
}
Animation animation = (Animation) getItem(position);
Picasso.with(mContext).load(animation.HomePic).placeholder(R.drawable.placeholder_thumb).error(R.drawable.placeholder_fail).into(thumbImageView);
titleTextView.setText(animation.Name);
contentTextView.setText(animation.Brief);
convertView.setOnClickListener(new AnimationItemOnClickListener(animation));
convertView.setOnLongClickListener(new OnLongClickListener() {
// 保证长按事件传递
@Override
public boolean onLongClick(View v) {
return false;
}
});
titleTextView.setTextColor(animation.isWatched() ? mWatchedTitleColor : mUnWatchedTitleColor);
return convertView;
}
Aggregations