Search in sources :

Example 1 with AbPullToRefreshView

use of com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView in project JustAndroid by chinaltz.

the class NetDemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_news);
    ButterKnife.bind(this);
    navTitle.setText("科技新闻");
    navBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    newsArrayList = new ArrayList();
    newsAdapter = new NewsAdapter(newsArrayList, mContext);
    newsListView.setAdapter(newsAdapter);
    newsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            NewslistBean news = (NewslistBean) newsAdapter.getItem(position);
            Intent intent = new Intent();
            intent.setClass(mContext, WebViewActivity.class);
            intent.putExtra("title", news.getDescription());
            intent.putExtra("url", news.getUrl());
            startActivity(intent);
        }
    });
    getData();
    PullToRefreshView.setPullRefreshEnable(true);
    PullToRefreshView.setLoadMoreEnable(false);
    PullToRefreshView.setOnHeaderRefreshListener(new AbPullToRefreshView.OnHeaderRefreshListener() {

        @Override
        public void onHeaderRefresh(AbPullToRefreshView view) {
            getData();
        }
    });
}
Also used : AbPullToRefreshView(com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView) ArrayList(java.util.ArrayList) NewslistBean(com.litingzhe.justandroid.netdb.net.model.NewslistBean) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) AbPullToRefreshView(com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) NewsAdapter(com.litingzhe.justandroid.netdb.net.adapter.NewsAdapter) AdapterView(android.widget.AdapterView)

Example 2 with AbPullToRefreshView

use of com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView 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)

Aggregations

View (android.view.View)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 AbPullToRefreshView (com.ningcui.mylibrary.viewLib.refresh.AbPullToRefreshView)2 Intent (android.content.Intent)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 MotionEvent (android.view.MotionEvent)1 OnClickListener (android.view.View.OnClickListener)1 OnTouchListener (android.view.View.OnTouchListener)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 AdapterView (android.widget.AdapterView)1 BindView (butterknife.BindView)1 NewsAdapter (com.litingzhe.justandroid.netdb.net.adapter.NewsAdapter)1 NewslistBean (com.litingzhe.justandroid.netdb.net.model.NewslistBean)1 ChatAdapter (com.litingzhe.justandroid.ui.listandGridView.adapter.ChatAdapter)1 ArrayList (java.util.ArrayList)1