Search in sources :

Example 1 with StatusModeAdapter

use of com.xabber.android.ui.adapter.StatusModeAdapter in project xabber-android by redsolution.

the class StatusEditor method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFinishing()) {
        return;
    }
    actionWithItem = null;
    setContentView(R.layout.status_editor);
    Toolbar toolbar = (Toolbar) findViewById(R.id.top_toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
    setTitle(null);
    setSupportActionBar(toolbar);
    Intent intent = getIntent();
    account = StatusEditor.getAccount(intent);
    BarPainter barPainter = new BarPainter(this, toolbar);
    if (account != null) {
        barPainter.updateWithAccountName(account);
    } else {
        barPainter.setDefaultColor();
    }
    ListView listView = getListView();
    listView.setOnItemClickListener(this);
    registerForContextMenu(listView);
    adapter = new StatusEditorAdapter(this);
    View footerView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.status_history_footer, null, false);
    footerView.findViewById(R.id.clear_status_history_button).setOnClickListener(this);
    listView.addFooterView(footerView);
    setListAdapter(adapter);
    statusTextView = (EditText) findViewById(R.id.status_text);
    statusModeView = (Spinner) findViewById(R.id.status_icon);
    statusModeView.setAdapter(new StatusModeAdapter(this));
    savedStatusesTextView = findViewById(R.id.saved_statuses_textview);
    StatusMode statusMode;
    String statusText;
    if (savedInstanceState == null) {
        if (account == null) {
            statusMode = SettingsManager.statusMode();
            statusText = SettingsManager.statusText();
        } else {
            AccountItem accountItem = AccountManager.getInstance().getAccount(account);
            if (accountItem == null) {
                Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
                finish();
                return;
            }
            statusMode = accountItem.getFactualStatusMode();
            statusText = accountItem.getStatusText();
        }
    } else {
        statusMode = StatusMode.valueOf(savedInstanceState.getString(SAVED_MODE));
        statusText = savedInstanceState.getString(SAVED_TEXT);
    }
    showStatus(statusMode, statusText);
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode) ListView(android.widget.ListView) AccountItem(com.xabber.android.data.account.AccountItem) LayoutInflater(android.view.LayoutInflater) StatusEditorAdapter(com.xabber.android.ui.adapter.StatusEditorAdapter) Intent(android.content.Intent) StatusModeAdapter(com.xabber.android.ui.adapter.StatusModeAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Toolbar(android.support.v7.widget.Toolbar) BarPainter(com.xabber.android.ui.color.BarPainter)

Aggregations

Intent (android.content.Intent)1 Toolbar (android.support.v7.widget.Toolbar)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 AccountItem (com.xabber.android.data.account.AccountItem)1 StatusMode (com.xabber.android.data.account.StatusMode)1 StatusEditorAdapter (com.xabber.android.ui.adapter.StatusEditorAdapter)1 StatusModeAdapter (com.xabber.android.ui.adapter.StatusModeAdapter)1 BarPainter (com.xabber.android.ui.color.BarPainter)1