コード例 #1
0
ファイル: BaseActivity.java プロジェクト: cyiwon/iwon
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(getLayout());
   date = TimeUtil.getdate1();
   application = MyApplication.getInstance();
   zDataTask = application.getZDataTask();
   initView();
 }
コード例 #2
0
ファイル: PublicGroupsActivity.java プロジェクト: cyiwon/iwon
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_public_groups);
    MyApplication.getInstance().addActivity(this);

    pb = (ProgressBar) findViewById(R.id.progressBar);
    listView = (ListView) findViewById(R.id.list);

    new Thread(
            new Runnable() {
              public void run() {
                try {
                  // 从服务器获取所用公开的群聊
                  final List<EMGroupInfo> groupsList =
                      EMGroupManager.getInstance().getAllPublicGroupsFromServer();
                  runOnUiThread(
                      new Runnable() {

                        public void run() {
                          pb.setVisibility(View.INVISIBLE);
                          adapter = new GroupsAdapter(PublicGroupsActivity.this, 1, groupsList);
                          listView.setAdapter(adapter);

                          // 设置item点击事件
                          listView.setOnItemClickListener(
                              new OnItemClickListener() {

                                @Override
                                public void onItemClick(
                                    AdapterView<?> parent, View view, int position, long id) {
                                  startActivity(
                                      new Intent(
                                              PublicGroupsActivity.this,
                                              GroupSimpleDetailActivity.class)
                                          .putExtra("groupinfo", adapter.getItem(position)));
                                }
                              });

                          // 搜索框
                          query = (EditText) findViewById(R.id.query);
                          // 搜索框中清除button
                          clearSearch = (ImageButton) 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();
                                }
                              });
                        }
                      });
                } catch (EaseMobException e) {
                  e.printStackTrace();
                  runOnUiThread(
                      new Runnable() {
                        public void run() {
                          pb.setVisibility(View.INVISIBLE);
                        }
                      });
                }
              }
            })
        .start();
  }