public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mainView = inflater.inflate(R.layout.create_player_list, container);

    Button b = (Button) mainView.findViewById(R.id.addPlayerConfirm);
    b.setOnClickListener(this);
    b.setText("Invite");

    setTitle("Invite people who will text to play:");

    contactsLV = (ListView) mainView.findViewById(R.id.listView1);
    contactsLV.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
    contactsLV.setStackFromBottom(true);

    final EditText et = (EditText) mainView.findViewById(R.id.addPlayerContent);
    et.addTextChangedListener(
        new TextWatcher() {
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          public void afterTextChanged(Editable s) {
            startQuery(et.getText().toString());
          }
        });
    return mainView;
  }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_discussion);

    discussionTopic = getIntent().getStringExtra(Const.DISCUSSION_TOPIC);
    discussionTableName = getIntent().getStringExtra(Const.DISCUSSION_TABLE_NAME);
    getSupportActionBar().setTitle(discussionTopic);

    saveDiscussionObject();

    messagesList = new ArrayList<>();

    ListView list = (ListView) findViewById(R.id.list);
    chatAdapter = new ChatAdapter();
    list.setAdapter(chatAdapter);
    list.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    list.setStackFromBottom(true);

    // Custom new message area
    EditText messageTxt = (EditText) findViewById(R.id.txt);
    messageTxt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);

    // Custom send button
    setTouchNClick(R.id.btnSend);

    handler = new Handler();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout layout = new LinearLayout(getActivity());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    View connectionHeaderView = inflater.inflate(R.layout.connection_header, null);
    layout.addView(connectionHeaderView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

    View bufferHeaderView = inflater.inflate(R.layout.fragment_buffer_header, null);
    layout.addView(bufferHeaderView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

    ListView listView = new ListView(getActivity());
    listView.setId(android.R.id.list);
    listView.setDivider(null);
    listView.setStackFromBottom(true);
    listView.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_NORMAL);
    listView.setSmoothScrollbarEnabled(false);
    //        listView.setCacheColorHint(Color.TRANSPARENT);

    LayoutParams params = new LayoutParams(MATCH_PARENT, 0);
    params.weight = 1;
    layout.addView(listView, params);
    View footerView = inflater.inflate(R.layout.fragment_buffer_footer, null);
    layout.addView(footerView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

    ((TextView) footerView.findViewById(R.id.text_entry))
        .setOnEditorActionListener(
            new TextView.OnEditorActionListener() {
              public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (event != null && event.getAction() != KeyEvent.ACTION_DOWN) {
                  return false;
                }

                sendMessage();
                return true;
              }
            });

    footerView
        .findViewById(R.id.send_button)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                sendMessage();
              }
            });

    return layout;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    stcont = getApplicationContext();

    logList = new ListView(this);
    logList.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

    serviceList = new ListView(this);

    connectService();
  }
Пример #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat_conversation_win);
    final SharedPreferences prefernces = PreferenceManager.getDefaultSharedPreferences(this);
    MY_ID = prefernces.getString(getString(R.string.user_parse_id), "");
    // set friend image
    ((ImageView) findViewById(R.id.ConversationUserImage)).setImageBitmap(FriendImage);
    // set friend first name
    ((TextView) findViewById(R.id.user_name_chat_win)).setText(FriendFirstName);
    // open old message
    GetingHistoryChat(FriendParseObjectID, MY_ID);
    // checking every 2.5 seconds new message
    checkingmessage(FriendParseObjectID, MY_ID);

    send = (Button) findViewById(R.id.btnsend);
    list = (ListView) findViewById(R.id.listmessage);
    abp = new ChatArrayAdapter(getApplicationContext(), R.layout.chat_single_message);
    chattext = (EditText) findViewById(R.id.chat);
    // *send message --------------------------------------------------------------
    send.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (!chattext.getText().toString().isEmpty()) {
              // update message on parse
              userMessage = chattext.getText().toString();
              send();
            }
          }
        });
    list.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    list.setAdapter(abp);
    abp.registerDataSetObserver(
        new DataSetObserver() {
          public void OnChanged() {
            super.onChanged();
            list.setSelection(abp.getCount() - 1);
          }
        });
    back = (Button) findViewById(R.id.cht2list);
    back.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(Chat_ConversationWindow.this, Chat_Contact_List.class);
            startActivity(intent);
            finish();
          }
        });
  }
Пример #6
0
  private void init() {
    mNotificationManager =
        (NotificationManager) this.getSystemService(Service.NOTIFICATION_SERVICE);
    // 获取Intent传过来的用户名
    this.pUSERID = getIntent().getStringExtra("USERID");
    this.userChat = getIntent().getStringExtra("user"); /*
															 * + "/" +
															 * FriendListActivity
															 * .RESOUCE_NAME;
															 */
    userChatSendFile = userChat + "/" + FriendListActivity.MY_RESOUCE_NAME;
    this.pFRIENDID = getIntent().getStringExtra("FRIENDID");
    listMsg.addAll(
        (Collection<? extends MessageInfo>) getIntent().getParcelableArrayListExtra("cached"));
    /*
     * System.out.println("接收消息的用户pFRIENDID是:" + userChat);
     * System.out.println("发送消息的用户pUSERID是:" + pUSERID);
     * System.out.println(" 消息的用户pFRIENDID是:" + pFRIENDID);
     */

    chat_name = (TextView) findViewById(R.id.chat_name);
    chat_name.setText(pFRIENDID);
    ListView listview = (ListView) findViewById(R.id.formclient_listview);
    listview.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    this.adapter = new ChatListAdapter(this, listMsg);
    listview.setAdapter(adapter);
    // 获取文本信息
    this.msgText = (EditText) findViewById(R.id.formclient_text);
    // 消息监听
    cm = XmppConnection.getConnection().getChatManager();

    // 返回按钮
    Button mBtnBack = (Button) findViewById(R.id.chat_back);
    mBtnBack.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            finish();
          }
        });

    //		receivedMsg();// 接收消息
    textMsg(); // 发送+接受消息
    receivedFile(); // 接收文件
  }
Пример #7
0
  // TODO 设置listview下拉刷新,为了阅后即焚暂时取消
  private void setupWidget() {
    singleChatLv.setOnScrollListener(mOnScrollListener);
    singleChatLv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_NORMAL);
    singleChatLv.setOnTouchListener(mOnTouchListener);
    singleChatLv.setOnItemClickListener(mItemClickListener);
    singleChatLv.setKeepScreenOn(true);
    singleChatLv.post(
        new Runnable() {
          @Override
          public void run() {
            singleChatLv.setSelection(singleChatLv.getCount());
          }
        });
    registerForContextMenu(singleChatLv);

    mmPullDownView = (ChatPullDownListView) findViewById(R.id.chat_list_pulldown_view);
    mmPullDownView.setTopViewInitialize(true);
    mmPullDownView.setIsCloseTopAllowRefersh(false);
    mmPullDownView.setHasbottomViewWithoutscroll(false);
    mmPullDownView.setOnRefreshAdapterDataListener(mOnRefreshAdapterDataListener);
    mmPullDownView.setOnListViewTopListener(mOnListViewTopListener);
    mmPullDownView.setOnListViewBottomListener(mOnListViewBottomListener);
  }
Пример #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    buttonSend = (Button) findViewById(R.id.buttonSend);
    listView = (ListView) findViewById(R.id.listView1);
    datasource = new RingToDataSource(this);
    datasource.open();

    chatArrayAdapter =
        new ChatArrayAdapter(this.getApplicationContext(), R.layout.activity_chat_singlemessage);
    listView.setAdapter(chatArrayAdapter);
    listView.setDivider(null);
    chatText = (EditText) findViewById(R.id.chatText);
    chatText.setOnKeyListener(
        new View.OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              return sendChatMessage();
            }

            return false;
          }
        });

    buttonSend.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            sendChatMessage();
          }
        });

    //        else
    //        {
    //            message_list = new ArrayList<Message>(datasource.getAllMessages());
    //            chatArrayAdapter.addListOfMessages(message_list);
    //        }

    //        FragmentManager managerFragment = getSupportFragmentManager();
    //        app = (RingToAPI) managerFragment.findFragmentByTag(String.valueOf(0));
    //
    //        if(app == null)
    //        {
    //            app = new RingToAPI();
    to_number = getIntent().getExtras().getString("to_number");
    from_number = getIntent().getExtras().getString("from_number");

    //            app.setAPI(this, token);
    //            managerFragment.beginTransaction().add(app, String.valueOf(0)).commit();
    //        }

    listView.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    listView.setAdapter(chatArrayAdapter);

    // to scroll the list view to bottom on data change
    chatArrayAdapter.registerDataSetObserver(
        new DataSetObserver() {
          @Override
          public void onChanged() {
            super.onChanged();
            listView.setSelection(chatArrayAdapter.getCount() - 1);
          }
        });

    chatArrayAdapter.addListOfMessages(datasource.getChatThread(to_number, from_number));

    //        if (savedInstanceState != null)
    //        {
    //            RingToApplication singleton = (RingToApplication) getApplicationContext();
    //            token = singleton.getToken();
    //            app = new RingToAPI();
    //            app.setToken(token);
    //        }
    //
    //        else
    //        {
    //            // Takes the previous saved list of messages on screen and appends them to
    //            // the current message list on screen.
    ////            message_list = savedInstanceState.getParcelableArrayList("here");
    ////            chatArrayAdapter.addListOfMessages(message_list);
    //        }

    //        Toast.makeText(getApplicationContext(), Integer.toString(messages.length()),
    // Toast.LENGTH_LONG);
    //        app.pullMessages(getActivity());

  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent i = getIntent();
    int drawable = i.getIntExtra("logo", 1);
    this.name = i.getStringExtra("name");
    setContentView(R.layout.activity_chat);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back);
    toolbar.setLogo(R.drawable.ic_dp);

    getSupportActionBar().setSubtitle("Online");
    getSupportActionBar().setTitle(name);
    toolbar.setTitleTextColor(getResources().getColor(R.color.white));
    toolbar.setSubtitleTextColor(getResources().getColor(R.color.white));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    buttonSend = (ImageButton) findViewById(R.id.buttonSend);

    listView = (ListView) findViewById(R.id.listView1);
    if (!App.chats.containsKey(name)) {
      ChatArrayAdapter adapter = new ChatArrayAdapter(this, R.layout.activity_chat_singlemessage);
      App.chats.put(name, adapter);
    }
    listView.setAdapter(App.chats.get(name));

    chatText = (EditText) findViewById(R.id.chatText);
    chatText.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              return sendChatMessage();
            }
            return false;
          }
        });
    buttonSend.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            sendChatMessage();
          }
        });

    listView.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

    // to scroll the list view to bottom on data change
    App.chats
        .get(name)
        .registerDataSetObserver(
            new DataSetObserver() {
              @Override
              public void onChanged() {
                super.onChanged();
                listView.setSelection(App.chats.get(name).getCount() - 1);
              }
            });
    //        supportInvalidateOptionsMenu();
  }
  @Override
  public View onCreateView(
      final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_conversation, container, false);
    view.setOnClickListener(null);
    mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
    setupIme();
    mEditMessage.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (activity != null) {
              activity.hideConversationsOverview();
            }
          }
        });
    mEditMessage.setOnEditorActionListener(mEditorActionListener);

    mSendButton = (ImageButton) view.findViewById(R.id.textSendButton);
    mSendButton.setOnClickListener(this.mSendButtonListener);

    snackbar = (RelativeLayout) view.findViewById(R.id.snackbar);
    snackbarMessage = (TextView) view.findViewById(R.id.snackbar_message);
    snackbarAction = (TextView) view.findViewById(R.id.snackbar_action);

    messagesView = (ListView) view.findViewById(R.id.messages_view);
    messagesView.setOnScrollListener(mOnScrollListener);
    messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
    messageListAdapter = new MessageAdapter((ConversationActivity) getActivity(), this.messageList);
    messageListAdapter.setOnContactPictureClicked(
        new OnContactPictureClicked() {

          @Override
          public void onContactPictureClicked(Message message) {
            if (message.getStatus() <= Message.STATUS_RECEIVED) {
              if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
                if (message.getCounterpart() != null) {
                  String user =
                      message.getCounterpart().isBareJid()
                          ? message.getCounterpart().toString()
                          : message.getCounterpart().getResourcepart();
                  if (!message.getConversation().getMucOptions().isUserInRoom(user)) {
                    Toast.makeText(
                            activity,
                            activity.getString(R.string.user_has_left_conference, user),
                            Toast.LENGTH_SHORT)
                        .show();
                  }
                  highlightInConference(user);
                }
              } else {
                activity.switchToContactDetails(
                    message.getContact(), message.getAxolotlFingerprint());
              }
            } else {
              Account account = message.getConversation().getAccount();
              Intent intent = new Intent(activity, EditAccountActivity.class);
              intent.putExtra("jid", account.getJid().toBareJid().toString());
              intent.putExtra("fingerprint", message.getAxolotlFingerprint());
              startActivity(intent);
            }
          }
        });
    messageListAdapter.setOnContactPictureLongClicked(
        new OnContactPictureLongClicked() {

          @Override
          public void onContactPictureLongClicked(Message message) {
            if (message.getStatus() <= Message.STATUS_RECEIVED) {
              if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
                if (message.getCounterpart() != null) {
                  String user = message.getCounterpart().getResourcepart();
                  if (user != null) {
                    if (message.getConversation().getMucOptions().isUserInRoom(user)) {
                      privateMessageWith(message.getCounterpart());
                    } else {
                      Toast.makeText(
                              activity,
                              activity.getString(R.string.user_has_left_conference, user),
                              Toast.LENGTH_SHORT)
                          .show();
                    }
                  }
                }
              }
            } else {
              activity.showQrCode();
            }
          }
        });
    messagesView.setAdapter(messageListAdapter);

    registerForContextMenu(messagesView);

    return view;
  }