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);
}
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;
}
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();
}
}
};
}
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);
}
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;
}
});
}
Aggregations