use of android.view.View.OnTouchListener in project android_packages_apps_DSPManager by CyanogenMod.
the class EqualizerPreference method onBindDialogView.
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
mDialogEqualizer = (EqualizerSurface) view.findViewById(R.id.FrequencyResponse);
mDialogEqualizer.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
float x = event.getX();
float y = event.getY();
/* Which band is closest to the position user pressed? */
int band = mDialogEqualizer.findClosest(x);
int wy = v.getHeight();
float level = (y / wy) * (EqualizerSurface.MIN_DB - EqualizerSurface.MAX_DB) - EqualizerSurface.MIN_DB;
if (level < EqualizerSurface.MIN_DB) {
level = EqualizerSurface.MIN_DB;
} else if (level > EqualizerSurface.MAX_DB) {
level = EqualizerSurface.MAX_DB;
}
mDialogEqualizer.setBand(band, level);
updateDspFromDialogEqualizer();
return true;
}
});
if (mListEqualizer != null) {
for (int i = 0; i < 6; i++) {
mDialogEqualizer.setBand(i, mListEqualizer.getBand(i));
}
}
Intent serviceIntent = new Intent(getContext(), HeadsetService.class);
getContext().bindService(serviceIntent, mConnectionForDialog, 0);
}
use of android.view.View.OnTouchListener in project UltimateAndroid by cymcsg.
the class ImageProcessingVideotoImageActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
view = new FastImageProcessingView(this);
pipeline = new FastImageProcessingPipeline();
video = new VideoResourceInput(view, this, R.raw.image_processing_birds);
edgeDetect = new SobelEdgeDetectionFilter();
image = new JPGFileEndpoint(this, false, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/outputImage", false);
screen = new ScreenEndpoint(pipeline);
video.addTarget(edgeDetect);
edgeDetect.addTarget(image);
edgeDetect.addTarget(screen);
pipeline.addRootRenderer(video);
view.setPipeline(pipeline);
setContentView(view);
pipeline.startRendering();
video.startWhenReady();
view.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent me) {
if (System.currentTimeMillis() - 100 > touchTime) {
touchTime = System.currentTimeMillis();
if (video.isPlaying()) {
video.stop();
} else {
video.startWhenReady();
}
}
return true;
}
});
}
use of android.view.View.OnTouchListener in project wechat by motianhuo.
the class ChatActivity method setUpView.
private void setUpView() {
activityInstance = this;
iv_emoticons_normal.setOnClickListener(this);
iv_emoticons_checked.setOnClickListener(this);
// position = getIntent().getIntExtra("position", -1);
clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
// 判断单聊还是群聊
chatType = getIntent().getIntExtra(Constants.TYPE, CHATTYPE_SINGLE);
Name = getIntent().getStringExtra(Constants.NAME);
img_right.setVisibility(View.VISIBLE);
if (chatType == CHATTYPE_SINGLE) {
// 单聊
toChatUsername = getIntent().getStringExtra(Constants.User_ID);
img_right.setImageResource(R.drawable.icon_chat_user);
if (TextUtils.isEmpty(Name)) {
initUserInfo();
} else {
txt_title.setText(Name);
}
} else {
// 群聊
if (TextUtils.isEmpty(Name)) {
initGroupInfo();
} else {
txt_title.setText(Name);
}
findViewById(R.id.view_location_video).setVisibility(View.GONE);
toChatUsername = getIntent().getStringExtra(Constants.GROUP_ID);
img_right.setImageResource(R.drawable.icon_groupinfo);
}
conversation = EMChatManager.getInstance().getConversation(toChatUsername);
// 把此会话的未读数置为0
conversation.resetUnreadMsgCount();
adapter = new MessageAdapter(this, toChatUsername, chatType);
// 显示消息
listView.setAdapter(adapter);
listView.setOnScrollListener(new ListScrollListener());
int count = listView.getCount();
if (count > 0) {
listView.setSelection(count);
}
listView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
hideKeyboard();
more.setVisibility(View.GONE);
iv_emoticons_normal.setVisibility(View.VISIBLE);
iv_emoticons_checked.setVisibility(View.INVISIBLE);
emojiIconContainer.setVisibility(View.GONE);
btnContainer.setVisibility(View.GONE);
return false;
}
});
// 注册接收消息广播
receiver = new NewMessageBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
// 设置广播的优先级别大于Mainacitivity,这样如果消息来的时候正好在chat页面,直接显示消息,而不是提示消息未读
intentFilter.setPriority(5);
registerReceiver(receiver, intentFilter);
// 注册一个ack回执消息的BroadcastReceiver
IntentFilter ackMessageIntentFilter = new IntentFilter(EMChatManager.getInstance().getAckMessageBroadcastAction());
ackMessageIntentFilter.setPriority(5);
registerReceiver(ackMessageReceiver, ackMessageIntentFilter);
// 注册一个消息送达的BroadcastReceiver
IntentFilter deliveryAckMessageIntentFilter = new IntentFilter(EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction());
deliveryAckMessageIntentFilter.setPriority(5);
registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter);
// 监听当前会话的群聊解散被T事件
groupListener = new GroupListener();
EMGroupManager.getInstance().addGroupChangeListener(groupListener);
// show forward message if the message is not null
String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
if (forward_msg_id != null) {
// 显示发送要转发的消息
forwardMessage(forward_msg_id);
}
}
use of android.view.View.OnTouchListener in project wechat by motianhuo.
the class GroupSettingActivity method showMembers.
// 显示群成员头像昵称的gridview
private void showMembers(List<User> members) {
adapter = new GridAdapter(this, members);
gridview.setAdapter(adapter);
// 设置OnTouchListener,为了让群主方便地推出删除模》
gridview.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (adapter.isInDeleteMode) {
adapter.isInDeleteMode = false;
adapter.notifyDataSetChanged();
return true;
}
break;
default:
break;
}
return false;
}
});
}
use of android.view.View.OnTouchListener in project android-toolbox by Knickedi.
the class HiddenQuickActionSetup method setupQuickActionTouchListener.
private void setupQuickActionTouchListener() {
mTouchListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int a = event.getAction();
if (a == MotionEvent.ACTION_DOWN) {
if (isHiddenViewCovered()) {
return false;
}
Drawable drawable = ((ImageView) ((ViewGroup) v).getChildAt(0)).getDrawable();
if (drawable instanceof StateListDrawable) {
drawable = ((StateListDrawable) drawable).getCurrent();
}
mIndicatorImage.setImageDrawable(drawable);
mClickedActionView = v;
if (mIndicatorDelay == 0) {
mIndicatorStart.run();
} else if (mIndicatorDelay > 0 && ((ActionInfo) v.getTag()).description != null) {
mPopupDelayHandler.postDelayed(mIndicatorStart, mIndicatorDelay);
}
v.setPressed(true);
v.invalidate();
} else if (a == MotionEvent.ACTION_UP || a == MotionEvent.ACTION_CANCEL) {
if (a == MotionEvent.ACTION_UP) {
if (mCloseSwipeableOnQuickAction) {
closeHiddenView();
}
if (mQuickActionListener != null) {
mQuickActionListener.onQuickAction(getCurrentListView(), getCurrentSwipeableHiddenView(), getCurrentPosition(), ((ActionInfo) v.getTag()).id);
}
}
mPopupDelayHandler.removeCallbacks(mIndicatorStart);
mIndicatorPopup.dismiss();
v.setPressed(false);
v.invalidate();
}
return true;
}
};
}
Aggregations