Example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

List of usage examples for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Prototype

int HIDE_NOT_ALWAYS

To view the source code for android.view.inputmethod InputMethodManager HIDE_NOT_ALWAYS.

Click Source Link

Document

Flag for #hideSoftInputFromWindow and InputMethodService#requestShowSelf(int) to indicate that the soft input window should normally be hidden, unless it was originally shown with #SHOW_FORCED .

Usage

From source file:com.sft.blackcatapp.SearchCoachActivity.java

private void initData() {
    searchCoach.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    searchCoach.setOnEditorActionListener(new OnEditorActionListener() {

        @Override//w  w  w . j  av  a  2 s.  c  o  m
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                // ??
                ((InputMethodManager) searchCoach.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(SearchCoachActivity.this.getCurrentFocus().getWindowToken(),
                                InputMethodManager.HIDE_NOT_ALWAYS);

                // ?
                LogUtil.print("?");
                coachname = searchCoach.getText().toString().trim();
                searchcoach(true);
                return true;
            }
            return false;
        }

    });
}

From source file:zzh.cn.imdemo.view.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.em_fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMClient.getInstance().groupManager().getAllGroups();
    groupListView = (ListView) findViewById(R.id.list);
    //show group list
    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light,
            R.color.holo_orange_light, R.color.holo_red_light);
    //pull down to refresh
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override// w  w w  .  ja  v a 2  s. co  m
        public void onRefresh() {
            new Thread() {
                @Override
                public void run() {
                    try {
                        EMClient.getInstance().groupManager().getJoinedGroupsFromServer();
                        handler.sendEmptyMessage(0);
                    } catch (HyphenateException e) {
                        e.printStackTrace();
                        handler.sendEmptyMessage(1);
                    }
                }
            }.start();
        }
    });

    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 1) {
                // create a new group TODO 
                startActivityForResult(new Intent(GroupsActivity.this, ECNewGroupActivity.class), 0);
                //            } else if (position == 2) {
                // join a public group TODO 
                //               startActivityForResult(new Intent(GroupsActivity.this, PublicGroupsActivity.class), 0);
            } else {
                // enter group chat
                Intent intent = new Intent(GroupsActivity.this, ECChatActivity.class);
                // it is group chat
                intent.putExtra("chatType", Constant.CHATTYPE_GROUP);
                intent.putExtra("userId", groupAdapter.getItem(position - 2).getGroupId());
                startActivityForResult(intent, 0);
            }
        }

    });
    groupListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

}

From source file:com.efithealth.app.activity.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMGroupManager.getInstance().getAllGroups();
    groupListView = (ListView) findViewById(R.id.list);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
            android.R.color.holo_orange_light, android.R.color.holo_red_light);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override/*ww w.  j  a  va 2 s  .  co  m*/
        public void onRefresh() {
            // MainActivity.asyncFetchGroupsFromServer();
        }
    });

    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 1) {
                // ?
                startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0);
            } else if (position == 2) {
                // 
                startActivityForResult(new Intent(GroupsActivity.this, PublicGroupsActivity.class), 0);
            } else {
                // ?
                Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
                // it is group chat
                intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                intent.putExtra("groupId", groupAdapter.getItem(position - 3).getGroupId());
                startActivityForResult(intent, 0);
            }
        }

    });
    groupListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    progressBar = (View) findViewById(R.id.progress_bar);

    syncListener = new SyncListener();
    HXSDKHelper.getInstance().addSyncGroupListener(syncListener);

    if (!HXSDKHelper.getInstance().isGroupsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }

    refresh();
}

From source file:com.shengtao.chat.chatUI.activity.GroupsActivity.java

@SuppressLint("InlinedApi")
@Override/*from w  w  w  .  java2s  .  c om*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMGroupManager.getInstance().getAllGroups();

    groupListView = (ListView) findViewById(R.id.list);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            MainActivity.asyncFetchGroupsFromServer();
        }
    });

    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 1) {
                // ?
                startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0);
            } else if (position == 2) {
                // 
                startActivityForResult(new Intent(GroupsActivity.this, PublicGroupsActivity.class), 0);
            } else {
                // ?
                Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
                // it is group chat
                intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                intent.putExtra("groupId", groupAdapter.getItem(position - 3).getGroupId());
                startActivityForResult(intent, 0);
            }
        }
    });
    groupListView.setOnTouchListener(new OnTouchListener() {
        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    progressBar = (View) findViewById(R.id.progress_bar);

    syncListener = new SyncListener();
    HXSDKHelper.getInstance().addSyncGroupListener(syncListener);

    if (!HXSDKHelper.getInstance().isGroupsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }

    refresh();
}

From source file:com.easemob.qixin.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;//from  w w  w . java  2s .c o m
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);
    View huanxinView = getView().findViewById(R.id.huanxin_contact_list);
    View groupView = getView().findViewById(R.id.group_contact_list);
    huanxinView.setOnClickListener(this);
    groupView.setOnClickListener(this);

    // ?
    query = (EditText) getView().findViewById(R.id.query);
    query.setHint(R.string.search);
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().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();
        }
    });

    list = new ArrayList<QXUser>();

    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, loadConversationsWithRecentChat());
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            startActivity(new Intent(getActivity(), PersonalInfoActivity.class).putExtra("userId",
                    adapter.getItem(position).getHXid()));
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    registerForContextMenu(listView);

}

From source file:com.feytuo.chat.activity.ContactlistFragment.java

public void initView() {
    // TODO Auto-generated method stub
    Log.i("ContactlistFragment", "-->initView");
    isInitialized = true;//from  w ww  .  ja v  a2s.  c om
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    noFriendImageView = (ImageView) getView().findViewById(R.id.contact_list_no_friend_img);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();
    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList, sidebar);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = App.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else {
                // demo??
                Intent intent = new Intent(getActivity(), ChatActivity.class);
                intent.putExtra("userId", adapter.getItem(position).getUsername());
                intent.putExtra("userNickName", adapter.getItem(position).getNickName());
                startActivity(intent);
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
    registerForContextMenu(listView);
    setNoFriendBackGround();
}

From source file:com.app.khclub.base.easeim.activity.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMGroupManager.getInstance().getAllGroups();
    groupListView = (ListView) findViewById(R.id.list);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override//  ww w.  j  a va 2  s  . c o  m
        public void onRefresh() {
            MainTabActivity.asyncFetchGroupsFromServer();
        }
    });

    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //            if (position == 0) {
            //               // ?
            //               startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0);
            //            } else if (position == 1) {
            //               // 
            //               startActivityForResult(new Intent(GroupsActivity.this, PublicGroupsActivity.class), 0);
            //            } else {
            // ?
            Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
            // it is group chat
            intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
            intent.putExtra("groupId", groupAdapter.getItem(position).getGroupId());
            startActivityForResult(intent, 0);
            //            }
        }

    });
    groupListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    progressBar = (View) findViewById(R.id.progress_bar);

    syncListener = new SyncListener();
    HXSDKHelper.getInstance().addSyncGroupListener(syncListener);

    if (!HXSDKHelper.getInstance().isGroupsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }

    refresh();
}

From source file:com.easemob.chatui.activity.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMGroupManager.getInstance().getAllGroups();
    groupListView = (ListView) findViewById(R.id.list);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override/* ww  w. jav  a  2 s .c o  m*/
        public void onRefresh() {
            // MainActivity.asyncFetchGroupsFromServer();
        }
    });

    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 1) {
                // ?
                startActivityForResult(
                        new Intent(GroupsActivity.this, com.easemob.chatui.activity.NewGroupActivity.class), 0);
            } else if (position == 2) {
                // 
                startActivityForResult(
                        new Intent(GroupsActivity.this, com.easemob.chatui.activity.PublicGroupsActivity.class),
                        0);
            } else {
                // ?
                Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
                // it is group chat
                intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                intent.putExtra("groupId", groupAdapter.getItem(position - 3).getGroupId());
                startActivityForResult(intent, 0);
            }
        }

    });
    groupListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    progressBar = (View) findViewById(R.id.progress_bar);

    syncListener = new SyncListener();
    HXSDKHelper.getInstance().addSyncGroupListener(syncListener);

    if (!HXSDKHelper.getInstance().isGroupsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }

    refresh();
}

From source file:com.dlam.activity.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    grouplist = EMGroupManager.getInstance().getAllGroups();
    groupListView = (ListView) findViewById(R.id.list);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override/*from   w w w.j a va2s  .  c  om*/
        public void onRefresh() {
            MainActivity.asyncFetchGroupsFromServer();
        }
    });

    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 1) {
                // ?
                startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0);
            } else if (position == 2) {
                // 
                startActivityForResult(new Intent(GroupsActivity.this, PublicGroupsActivity.class), 0);
            } else {
                // ?
                Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
                // it is group chat
                intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                intent.putExtra("groupId", groupAdapter.getItem(position - 3).getGroupId());
                startActivityForResult(intent, 0);
            }
        }

    });
    groupListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    progressBar = (View) findViewById(R.id.progress_bar);

    syncListener = new SyncListener();
    HXSDKHelper.getInstance().addSyncGroupListener(syncListener);

    if (!HXSDKHelper.getInstance().isGroupsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }

    refresh();
}

From source file:cn.gen.superwechat.activity.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    grouplist = SuperWeChatApplication.getInstance().getGroupList();
    groupListView = (ListView) findViewById(R.id.list);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override/*from   w w  w.  j a v  a  2s .com*/
        public void onRefresh() {
            MainActivity.asyncFetchGroupsFromServer();
        }
    });

    groupAdapter = new GroupAdapter(this, 1, grouplist);
    groupListView.setAdapter(groupAdapter);
    groupListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 1) {
                // ?
                startActivityForResult(new Intent(GroupsActivity.this, NewGroupActivity.class), 0);
            } else if (position == 2) {
                // 
                startActivityForResult(new Intent(GroupsActivity.this, PublicGroupsActivity.class), 0);
            } else {
                // ?
                Intent intent = new Intent(GroupsActivity.this, ChatActivity.class);
                // it is group chat
                intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
                intent.putExtra("groupId", groupAdapter.getItem(position).getMGroupHxid());
                startActivityForResult(intent, 0);
            }
        }

    });
    groupListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    progressBar = (View) findViewById(R.id.progress_bar);

    syncListener = new SyncListener();
    HXSDKHelper.getInstance().addSyncGroupListener(syncListener);

    if (!HXSDKHelper.getInstance().isGroupsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }

    refresh();
}