Search in sources :

Example 51 with OnTouchListener

use of android.view.View.OnTouchListener in project JustAndroid by chinaltz.

the class ChatListActivity method initView.

public void initView() {
    abPullToRefreshView = (AbPullToRefreshView) findViewById(R.id.chat_PullRefreshView);
    navBack = (LinearLayout) findViewById(R.id.nav_back);
    navBack.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    titleText = (TextView) findViewById(R.id.nav_title);
    titleText.setText("简单的聊天布局");
    listView = (ListView) findViewById(R.id.chat_listView);
    mAdapter = new ChatAdapter(mContext);
    listView.setAdapter(mAdapter);
    listView.setItemsCanFocus(true);
    contentEt = (EditText) findViewById(R.id.tv_send_content);
    sendBtn = (Button) findViewById(R.id.sendBtn);
    addBtn = (ImageButton) findViewById(R.id.addBtn);
    voiceBtn = (ImageButton) findViewById(R.id.voiceBtn);
    voiceSendBtn = (Button) findViewById(R.id.voiceSendBtn);
    otherTypeLy = (LinearLayout) findViewById(R.id.chatAppPanel);
    sendPic = (ImageView) findViewById(R.id.send_picture);
    sendVedio = (ImageView) findViewById(R.id.send_vedio);
    sendCameraPic = (ImageView) findViewById(R.id.send_camera);
    // 添加不同的消息类型
    addBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (otherTypeLy.getVisibility() == View.VISIBLE) {
                otherTypeLy.setVisibility(View.GONE);
            } else {
                InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE);
                mInputMethodManager.hideSoftInputFromWindow(contentEt.getWindowToken(), 0);
                otherTypeLy.setVisibility(View.VISIBLE);
            }
        }
    });
    voiceSendBtn.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch(event.getAction()) {
                case // 按下
                MotionEvent.ACTION_DOWN:
                    voiceSendBtn.setText("松开取消");
                    break;
                case // 抬起
                MotionEvent.ACTION_UP:
                    voiceSendBtn.setText("按住说话");
                    break;
                default:
                    break;
            }
            return false;
        }
    });
    voiceBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (contentEt.getVisibility() == View.GONE) {
                contentEt.setVisibility(View.VISIBLE);
                voiceSendBtn.setVisibility(View.GONE);
                isHide = false;
                voiceBtn.setBackgroundResource(R.drawable.button_selector_chat_voice);
                if (!isHide) {
                    InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE);
                    mInputMethodManager.hideSoftInputFromWindow(contentEt.getWindowToken(), 0);
                    isHide = true;
                }
            } else {
                contentEt.setVisibility(View.GONE);
                voiceSendBtn.setVisibility(View.VISIBLE);
                voiceBtn.setBackgroundResource(R.drawable.button_selector_chat_key);
                InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE);
                mInputMethodManager.hideSoftInputFromWindow(contentEt.getWindowToken(), 0);
                isHide = true;
            }
            otherTypeLy.setVisibility(View.GONE);
        }
    });
    // 切换发送和添加按钮
    contentEt.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String str = contentEt.getText().toString().trim();
            int length = str.length();
            if (length > 0) {
                sendBtn.setVisibility(View.VISIBLE);
                addBtn.setVisibility(View.GONE);
            } else {
                sendBtn.setVisibility(View.GONE);
                addBtn.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    sendBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
        }
    });
    // 拍照
    sendCameraPic.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
        // 选择本地图片
        }
    });
    sendPic.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
        }
    });
    sendVedio.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnClickListener(android.view.View.OnClickListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager) ChatAdapter(com.litingzhe.justandroid.ui.listandGridView.adapter.ChatAdapter) ImageView(android.widget.ImageView) View(android.view.View) AbPullToRefreshView(com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView) TextView(android.widget.TextView) ListView(android.widget.ListView) MotionEvent(android.view.MotionEvent)

Example 52 with OnTouchListener

use of android.view.View.OnTouchListener in project MaterialDesignLibrary by navasmdc.

the class ProgressDialog method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.progress_dialog);
    view = (RelativeLayout) findViewById(R.id.contentDialog);
    backView = (RelativeLayout) findViewById(R.id.dialog_rootView);
    backView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getX() < view.getLeft() || event.getX() > view.getRight() || event.getY() > view.getBottom() || event.getY() < view.getTop()) {
                dismiss();
            }
            return false;
        }
    });
    this.titleTextView = (TextView) findViewById(R.id.title);
    setTitle(title);
    if (progressColor != -1) {
        ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate);
        progressBarCircularIndeterminate.setBackgroundColor(progressColor);
    }
}
Also used : OnTouchListener(android.view.View.OnTouchListener) ProgressBarCircularIndeterminate(com.gc.materialdesign.views.ProgressBarCircularIndeterminate) TextView(android.widget.TextView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 53 with OnTouchListener

use of android.view.View.OnTouchListener in project SmartCampus by Vegen.

the class EaseConversationListFragment method setUpView.

@Override
protected void setUpView() {
    conversationList.addAll(loadConversationList());
    conversationListView.init(conversationList);
    if (listItemClickListener != null) {
        conversationListView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                EMConversation conversation = conversationListView.getItem(position);
                listItemClickListener.onListItemClicked(conversation);
            }
        });
    }
    EMClient.getInstance().addConnectionListener(connectionListener);
    query.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            conversationListView.filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });
    conversationListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideSoftKeyboard();
            return false;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) MotionEvent(android.view.MotionEvent) EMConversation(com.hyphenate.chat.EMConversation) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OnClickListener(android.view.View.OnClickListener)

Example 54 with OnTouchListener

use of android.view.View.OnTouchListener in project zype-android by zype.

the class PlayerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    mainView = inflater.inflate(R.layout.fragment_custom_player, container, false);
    mainView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(final View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                view.performClick();
            }
            return true;
        }
    });
    mainView.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
                return false;
            } else {
                return mediaController.dispatchKeyEvent(event);
            }
        }
    });
    videoFrame = mainView.findViewById(R.id.video_frame);
    surfaceView = mainView.findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(surfaceCallback);
    subtitleLayout = mainView.findViewById(R.id.subtitles);
    thumbnailView = mainView.findViewById(R.id.thumbnailView);
    if (contentType == TYPE_AUDIO_WEB || contentType == TYPE_AUDIO_LOCAL) {
        thumbnailView.setVisibility(View.VISIBLE);
    } else if (contentType == TYPE_AUDIO_LIVE) {
        thumbnailView.setVisibility(View.VISIBLE);
        UiUtils.loadImage(getActivity().getApplicationContext(), SettingsProvider.getInstance().getOnAirPictureUrl(), thumbnailView);
    } else {
        thumbnailView.setVisibility(View.GONE);
    }
    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager) {
        CookieHandler.setDefault(defaultCookieManager);
    }
    audioCapabilitiesReceiverRegister();
    return mainView;
}
Also used : KeyEvent(android.view.KeyEvent) OnTouchListener(android.view.View.OnTouchListener) OnKeyListener(android.view.View.OnKeyListener) ImageView(android.widget.ImageView) SurfaceView(android.view.SurfaceView) View(android.view.View) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent) CookieHandler(java.net.CookieHandler)

Example 55 with OnTouchListener

use of android.view.View.OnTouchListener in project atlas by alibaba.

the class Dialog method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    View dialogContent = LayoutInflater.from(getContext()).inflate(R.layout.update_dialog, null);
    super.setContentView(dialogContent);
    view = (RelativeLayout) findViewById(R.id.update_contentDialog);
    backView = (FrameLayout) findViewById(R.id.update_dialog_rootView);
    backView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getX() < view.getLeft() || event.getX() > view.getRight() || event.getY() > view.getBottom() || event.getY() < view.getTop()) {
                if (clickBackViewToExit) {
                    if (null != onCancelButtonClickListener) {
                        onCancelButtonClickListener.onClick(buttonCancel);
                    }
                    dismiss();
                }
            }
            return false;
        }
    });
    this.titleTextView = (TextView) findViewById(R.id.update_title);
    setTitle(title);
    if (mCustomContentView != null) {
        FrameLayout dialogContentFrame = (FrameLayout) findViewById(R.id.update_dialog_content);
        dialogContentFrame.addView(mCustomContentView);
        findViewById(R.id.message_scrollView).setVisibility(View.GONE);
    } else {
        this.messageTextView = (TextView) findViewById(R.id.update_message);
        setMessage(message);
    }
    if (buttonCancelText != null) {
        this.buttonCancel = (ButtonFlat) findViewById(R.id.update_button_cancel);
        this.buttonCancel.setVisibility(View.VISIBLE);
        this.buttonCancel.setText(buttonCancelText);
        buttonCancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dismiss();
                if (onCancelButtonClickListener != null)
                    onCancelButtonClickListener.onClick(v);
            }
        });
    }
    if (buttonAcceptText != null) {
        this.buttonAccept = (ButtonFlat) findViewById(R.id.update_button_accept);
        this.buttonAccept.setVisibility(View.VISIBLE);
        this.buttonAccept.setText(buttonAcceptText);
        buttonAccept.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dismiss();
                if (onAcceptButtonClickListener != null)
                    onAcceptButtonClickListener.onClick(v);
            }
        });
    }
}
Also used : OnTouchListener(android.view.View.OnTouchListener) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Aggregations

OnTouchListener (android.view.View.OnTouchListener)70 MotionEvent (android.view.MotionEvent)68 View (android.view.View)68 TextView (android.widget.TextView)40 OnClickListener (android.view.View.OnClickListener)21 ImageView (android.widget.ImageView)19 ListView (android.widget.ListView)16 AdapterView (android.widget.AdapterView)15 SuppressLint (android.annotation.SuppressLint)12 KeyEvent (android.view.KeyEvent)8 Intent (android.content.Intent)7 AbsListView (android.widget.AbsListView)7 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)6 Rect (android.graphics.Rect)5 Handler (android.os.Handler)5 GestureDetector (android.view.GestureDetector)5 OnGenericMotionListener (android.view.View.OnGenericMotionListener)5 WindowManager (android.view.WindowManager)5 DialogInterface (android.content.DialogInterface)4 Editable (android.text.Editable)4