Search in sources :

Example 6 with OnLongClickListener

use of android.view.View.OnLongClickListener in project android_frameworks_base by ParanoidAndroid.

the class DisabledLongpressTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final Longpress a = getActivity();
    mSimpleView = a.findViewById(R.id.simple_view);
    mSimpleView.setOnLongClickListener(new OnLongClickListener() {

        public boolean onLongClick(View v) {
            mLongClicked = true;
            return true;
        }
    });
    // The View#setOnLongClickListener will ensure the View is long
    // clickable, we reverse that here
    mSimpleView.setLongClickable(false);
}
Also used : Longpress(android.view.Longpress) OnLongClickListener(android.view.View.OnLongClickListener) View(android.view.View)

Example 7 with OnLongClickListener

use of android.view.View.OnLongClickListener 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)

Example 8 with OnLongClickListener

use of android.view.View.OnLongClickListener in project Rashr by DsLNeXuS.

the class CardStack method getOnLongClickListener.

private OnLongClickListener getOnLongClickListener(final CardStack cardStack, final RelativeLayout container, final int index) {
    return new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // init views array
            View[] views = new View[container.getChildCount()];
            for (int i = 0; i < views.length; i++) {
                views[i] = container.getChildAt(i);
            }
            int last = views.length - 1;
            if (index != last) {
                if (index == 0) {
                    onClickFirstCard(cardStack, container, index, views);
                } else if (index < last) {
                    onClickOtherCard(cardStack, container, index, views, last);
                }
            }
            return false;
        }

        public void onClickFirstCard(final CardStack cardStack, final RelativeLayout frameLayout, final int index, View[] views) {
            // run through all the cards
            for (int i = 0; i < views.length; i++) {
                ObjectAnimator anim = null;
                if (i == 0) {
                    // the first goes all the way down
                    float downFactor = 0;
                    if (views.length > 2) {
                        downFactor = convertDpToPixel((_45F) * (views.length - 1) - 1);
                    } else {
                        downFactor = convertDpToPixel(_45F);
                    }
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, downFactor);
                    anim.addListener(getAnimationListener(cardStack, frameLayout, index, views[index]));
                } else if (i == 1) {
                    // the second goes up just a bit
                    float upFactor = convertDpToPixel(-17f);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                } else {
                    // the rest go up by one card
                    float upFactor = convertDpToPixel(-1 * _45F);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                }
                if (anim != null)
                    anim.start();
            }
        }

        public void onClickOtherCard(final CardStack cardStack, final RelativeLayout frameLayout, final int index, View[] views, int last) {
            // if clicked card is in middle
            for (int i = index; i <= last; i++) {
                // run through the cards from the clicked position
                // and on until the end
                ObjectAnimator anim = null;
                if (i == index) {
                    // the selected card goes all the way down
                    float downFactor = convertDpToPixel(_45F * (last - i) + _12F);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, downFactor);
                    anim.addListener(getAnimationListener(cardStack, frameLayout, index, views[index]));
                } else {
                    // the rest go up by one
                    float upFactor = convertDpToPixel(_45F * -1);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                }
                if (anim != null)
                    anim.start();
            }
        }
    };
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) OnLongClickListener(android.view.View.OnLongClickListener) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) View(android.view.View)

Example 9 with OnLongClickListener

use of android.view.View.OnLongClickListener in project android_frameworks_base by ResurrectionRemix.

the class DisabledLongpressTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final Longpress a = getActivity();
    mSimpleView = a.findViewById(R.id.simple_view);
    mSimpleView.setOnLongClickListener(new OnLongClickListener() {

        public boolean onLongClick(View v) {
            mLongClicked = true;
            return true;
        }
    });
    // The View#setOnLongClickListener will ensure the View is long
    // clickable, we reverse that here
    mSimpleView.setLongClickable(false);
}
Also used : Longpress(android.view.Longpress) OnLongClickListener(android.view.View.OnLongClickListener) View(android.view.View)

Example 10 with OnLongClickListener

use of android.view.View.OnLongClickListener in project android_frameworks_base by ResurrectionRemix.

the class InputItemHandler method registerClickListener.

private void registerClickListener(final View view, final InputHandleListener handler) {
    view.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            handler.handleOnClickEvent(v);
        }
    });
    view.setOnLongClickListener(new OnLongClickListener() {

        public boolean onLongClick(View v) {
            handler.handleOnLongClickEvent(v);
            return true;
        }
    });
}
Also used : OnLongClickListener(android.view.View.OnLongClickListener) OnClickListener(android.view.View.OnClickListener) View(android.view.View)

Aggregations

OnLongClickListener (android.view.View.OnLongClickListener)34 View (android.view.View)33 TextView (android.widget.TextView)17 Longpress (android.view.Longpress)12 ImageView (android.widget.ImageView)12 OnClickListener (android.view.View.OnClickListener)10 Intent (android.content.Intent)9 ContextMenu (com.juns.wechat.chat.ContextMenu)4 RecyclerView (android.support.v7.widget.RecyclerView)3 LinearLayout (android.widget.LinearLayout)3 File (java.io.File)3 SuppressLint (android.annotation.SuppressLint)2 ViewGroup (android.view.ViewGroup)2 ListView (android.widget.ListView)2 RelativeLayout (android.widget.RelativeLayout)2 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 LayoutTransition (android.animation.LayoutTransition)1 AlertDialog (android.app.AlertDialog)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1