Search in sources :

Example 1 with Animation

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();
            }
        });
    }
}
Also used : Message(android.os.Message) JSONArray(org.json.JSONArray) Intent(android.content.Intent) Uri(android.net.Uri) JSONObject(org.json.JSONObject) Animation(com.zhan_dui.model.Animation) JsonHttpResponseHandler(com.loopj.android.http.JsonHttpResponseHandler)

Example 2 with Animation

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;
    }
}
Also used : Animation(com.zhan_dui.model.Animation) Intent(android.content.Intent)

Example 3 with Animation

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);
}
Also used : Category(com.zhan_dui.model.Category) Animation(com.zhan_dui.model.Animation) RecommendAdapter(com.zhan_dui.adapters.RecommendAdapter)

Example 4 with Animation

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");
}
Also used : Animation(com.zhan_dui.model.Animation) NotificationCompat(android.support.v4.app.NotificationCompat)

Example 5 with Animation

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;
}
Also used : OnLongClickListener(android.view.View.OnLongClickListener) Animation(com.zhan_dui.model.Animation) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Animation (com.zhan_dui.model.Animation)12 Intent (android.content.Intent)4 Message (android.os.Message)2 NotificationCompat (android.support.v4.app.NotificationCompat)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 View (android.view.View)1 OnLongClickListener (android.view.View.OnLongClickListener)1 JsonHttpResponseHandler (com.loopj.android.http.JsonHttpResponseHandler)1 DownloadAdapter (com.zhan_dui.adapters.DownloadAdapter)1 RecommendAdapter (com.zhan_dui.adapters.RecommendAdapter)1 AnimeTasteDB (com.zhan_dui.data.AnimeTasteDB)1 M3U8Mission (com.zhan_dui.download.alfred.missions.M3U8Mission)1 Mission (com.zhan_dui.download.alfred.missions.Mission)1