Search in sources :

Example 1 with SimpleTextWatcher

use of forpdateam.ru.forpda.common.simple.SimpleTextWatcher in project ForPDA by RadiationX.

the class MessagePanel method init.

private void init() {
    inflate(getContext(), fullForm ? R.layout.message_panel_full : R.layout.message_panel_quick, this);
    setClickable(true);
    advancedButton = (ImageButton) findViewById(R.id.button_advanced_input);
    attachmentsButton = (ImageButton) findViewById(R.id.button_attachments);
    sendButton = (ImageButton) findViewById(R.id.button_send);
    fullButton = (ImageButton) findViewById(R.id.button_full);
    hideButton = (ImageButton) findViewById(R.id.button_hide);
    editPollButton = (ImageButton) findViewById(R.id.button_edt_poll);
    messageField = (CodeEditor) findViewById(R.id.message_field);
    sendProgress = (ProgressBar) findViewById(R.id.send_progress);
    formProgress = (ProgressBar) findViewById(R.id.form_load_progress);
    messageWrapper = (ScrollView) findViewById(R.id.message_wrapper);
    messageField.attachToScrollView(messageWrapper);
    messageWrapper.setEnabled(true);
    messageWrapper.setVerticalFadingEdgeEnabled(true);
    messageWrapper.setFadingEdgeLength(App.px8);
    panelBehavior = new MessagePanelBehavior();
    params = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullForm ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT);
    // params.setBehavior(panelBehavior);
    params.gravity = Gravity.BOTTOM;
    if (!fullForm)
        params.setMargins(App.px8, App.px8, App.px8, App.px8);
    setLayoutParams(params);
    setClipToPadding(true);
    setRadius(fullForm ? 0 : App.px8);
    setPreventCornerOverlap(false);
    setCardBackgroundColor(App.getColorFromAttr(getContext(), R.attr.cards_background));
    // На случай, когда добавляются несколько слушателей
    advancedButton.setOnClickListener(v -> {
        for (OnClickListener listener : advancedListeners) listener.onClick(v);
    });
    attachmentsButton.setOnClickListener(v -> {
        for (OnClickListener listener : attachmentsListeners) listener.onClick(v);
    });
    sendButton.setOnClickListener(v -> {
        for (OnClickListener listener : sendListeners) listener.onClick(v);
    });
    lastHeight = getHeight() + App.px16;
    addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
        if (heightChangeListener == null)
            return;
        int newHeight = getHeight() + App.px16;
        if (newHeight != lastHeight) {
            lastHeight = newHeight;
            heightChangeListener.onChangedHeight(newHeight);
        }
    });
    messageField.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > 0) {
                if (sendButton.getColorFilter() == null) {
                    sendButton.setColorFilter(App.getColorFromAttr(getContext(), R.attr.colorAccent));
                }
            } else {
                if (sendButton.getColorFilter() != null) {
                    sendButton.clearColorFilter();
                }
            }
        }
    });
    messageField.setTypeface(isMonospace ? Typeface.MONOSPACE : Typeface.DEFAULT);
    App.get().addPreferenceChangeObserver(preferenceObserver);
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher) SuppressLint(android.annotation.SuppressLint)

Example 2 with SimpleTextWatcher

use of forpdateam.ru.forpda.common.simple.SimpleTextWatcher in project ForPDA by RadiationX.

the class QmsBlackListFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    viewsReady();
    nickField.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            searchUser(s.toString());
        }
    });
    refreshLayout.setOnRefreshListener(this::loadData);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    adapter = new QmsContactsAdapter();
    recyclerView.setAdapter(adapter);
    adapter.setOnItemClickListener(this);
}
Also used : SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher) QmsContactsAdapter(forpdateam.ru.forpda.ui.fragments.qms.adapters.QmsContactsAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 3 with SimpleTextWatcher

use of forpdateam.ru.forpda.common.simple.SimpleTextWatcher in project ForPDA by RadiationX.

the class ArticleCommentsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.article_comments, container, false);
    refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_list);
    recyclerView = (RecyclerView) view.findViewById(R.id.base_list);
    writePanel = (RelativeLayout) view.findViewById(R.id.comment_write_panel);
    messageField = (EditText) view.findViewById(R.id.message_field);
    sendContainer = (FrameLayout) view.findViewById(R.id.send_container);
    buttonSend = (AppCompatImageButton) view.findViewById(R.id.button_send);
    progressBarSend = (ProgressBar) view.findViewById(R.id.send_progress);
    additionalContent = (ViewGroup) view.findViewById(R.id.additional_content);
    refreshLayout.setProgressBackgroundColorSchemeColor(App.getColorFromAttr(getContext(), R.attr.colorPrimary));
    refreshLayout.setColorSchemeColors(App.getColorFromAttr(getContext(), R.attr.colorAccent));
    refreshLayout.setOnRefreshListener(() -> {
        refreshLayout.setRefreshing(true);
        RxApi.NewsList().getDetails(article.getId()).map(page -> {
            Comment commentTree = Api.NewsApi().updateComments(article, page);
            article.setCommentTree(commentTree);
            return Api.NewsApi().commentsToList(article.getCommentTree());
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(comments -> {
            refreshLayout.setRefreshing(false);
            createFunny(comments);
            adapter.addAll(comments);
        });
    });
    recyclerView.setBackgroundColor(App.getColorFromAttr(getContext(), R.attr.background_for_lists));
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setHasFixedSize(true);
    recyclerView.addItemDecoration(new BrandFragment.SpacingItemDecoration(App.px12, false));
    adapter = new ArticleCommentsAdapter();
    adapter.setClickListener(this);
    Observable.fromCallable(() -> {
        if (article.getCommentTree() == null) {
            Comment commentTree = Api.NewsApi().parseComments(article.getKarmaMap(), article.getCommentsSource());
            article.setCommentTree(commentTree);
        }
        return Api.NewsApi().commentsToList(article.getCommentTree());
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(comments -> {
        createFunny(comments);
        adapter.addAll(comments);
        if (article.getCommentId() > 0) {
            for (int i = 0; i < comments.size(); i++) {
                if (comments.get(i).getId() == article.getCommentId()) {
                    recyclerView.scrollToPosition(i);
                    break;
                }
            }
        }
    });
    recyclerView.setAdapter(adapter);
    messageField.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() == 0) {
                currentReplyComment = null;
            }
            buttonSend.setClickable(s.length() > 0);
        }
    });
    buttonSend.setOnClickListener(v -> sendComment());
    if (ClientHelper.getAuthState()) {
        writePanel.setVisibility(View.VISIBLE);
    } else {
        writePanel.setVisibility(View.GONE);
    }
    ClientHelper.get().addLoginObserver(loginObserver);
    contentController = new ContentController(null, additionalContent, refreshLayout);
    return view;
}
Also used : Observer(java.util.Observer) ContentController(forpdateam.ru.forpda.ui.views.ContentController) Context(android.content.Context) Bundle(android.os.Bundle) SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher) ProgressBar(android.widget.ProgressBar) FrameLayout(android.widget.FrameLayout) Comment(forpdateam.ru.forpda.api.news.models.Comment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager) ArrayList(java.util.ArrayList) RxApi(forpdateam.ru.forpda.apirx.RxApi) View(android.view.View) FunnyContent(forpdateam.ru.forpda.ui.views.FunnyContent) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) Api(forpdateam.ru.forpda.api.Api) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) BrandFragment(forpdateam.ru.forpda.ui.fragments.devdb.BrandFragment) LayoutInflater(android.view.LayoutInflater) ClientHelper(forpdateam.ru.forpda.client.ClientHelper) Fragment(android.support.v4.app.Fragment) AppCompatImageButton(android.support.v7.widget.AppCompatImageButton) IntentHandler(forpdateam.ru.forpda.common.IntentHandler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) AlertDialog(android.support.v7.app.AlertDialog) DetailsPage(forpdateam.ru.forpda.api.news.models.DetailsPage) RelativeLayout(android.widget.RelativeLayout) App(forpdateam.ru.forpda.App) Nullable(android.support.annotation.Nullable) R(forpdateam.ru.forpda.R) EditText(android.widget.EditText) Comment(forpdateam.ru.forpda.api.news.models.Comment) SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher) BrandFragment(forpdateam.ru.forpda.ui.fragments.devdb.BrandFragment) ContentController(forpdateam.ru.forpda.ui.views.ContentController) Editable(android.text.Editable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Nullable(android.support.annotation.Nullable)

Example 4 with SimpleTextWatcher

use of forpdateam.ru.forpda.common.simple.SimpleTextWatcher in project ForPDA by RadiationX.

the class ChatThemeCreator method initCreatorViews.

private void initCreatorViews() {
    titleField.addTextChangedListener(textWatcher);
    nickField.addTextChangedListener(textWatcher);
    editItem = fragment.getMenu().add(R.string.change).setIcon(App.getVecDrawable(fragment.getContext(), R.drawable.ic_fab_create)).setOnMenuItemClickListener(menuItem -> {
        viewStub.setVisibility(View.VISIBLE);
        doneItem.setVisible(true);
        editItem.setVisible(false);
        return false;
    });
    doneItem = fragment.getMenu().add(R.string.ok).setIcon(App.getVecDrawable(fragment.getContext(), R.drawable.ic_toolbar_done)).setOnMenuItemClickListener(menuItem -> {
        viewStub.setVisibility(View.GONE);
        editItem.setVisible(true);
        doneItem.setVisible(false);
        return false;
    });
    doneItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    editItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    editItem.setVisible(false);
    doneItem.setVisible(false);
    if (userNick != null) {
        nickField.setVisibility(View.GONE);
    } else {
        nickField.addTextChangedListener(new SimpleTextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                userNick = s.toString();
                searchUser(userNick);
                fragment.setSubtitle(userNick);
            }
        });
    }
    titleField.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            themeTitle = s.toString();
            fragment.setTitle(themeTitle);
        }
    });
}
Also used : ViewStub(android.view.ViewStub) SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher) AppCompatAutoCompleteTextView(android.support.v7.widget.AppCompatAutoCompleteTextView) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) RxApi(forpdateam.ru.forpda.apirx.RxApi) ArrayAdapter(android.widget.ArrayAdapter) List(java.util.List) Toast(android.widget.Toast) View(android.view.View) App(forpdateam.ru.forpda.App) R(forpdateam.ru.forpda.R) AppCompatEditText(android.support.v7.widget.AppCompatEditText) TextWatcher(android.text.TextWatcher) ForumUser(forpdateam.ru.forpda.api.others.user.ForumUser) SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher)

Example 5 with SimpleTextWatcher

use of forpdateam.ru.forpda.common.simple.SimpleTextWatcher in project ForPDA by RadiationX.

the class CodesPanelItem method listInsert.

private void listInsert(String tag, boolean num, List<String> listLines) {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.report_layout, null);
    assert layout != null;
    final EditText messageField = (EditText) layout.findViewById(R.id.report_text_field);
    final TextInputLayout inputLayout = (TextInputLayout) layout.findViewById(R.id.report_input_layout);
    final int[] i = { listLines.size() + 1 };
    inputLayout.setHint(String.format(App.get().getString(R.string.codes_list_item_Pos), i[0]));
    AlertDialog alertDialog = new AlertDialog.Builder(getContext()).setView(layout).setPositiveButton(R.string.add, null).setNegativeButton(R.string.close, (dialog, which) -> {
        StringBuilder body = new StringBuilder();
        for (String line : listLines) {
            body.append("[*]").append(line).append('\n');
        }
        List<Pair<String, String>> resultHeaders = new ArrayList<>();
        if (num) {
            resultHeaders.add(new Pair<>(null, "1"));
        }
        String[] bbcodes = createBbCode(tag, resultHeaders, body.toString());
        messagePanel.insertText(bbcodes[0], bbcodes[1], false);
    }).show();
    Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    positiveButton.setEnabled(false);
    positiveButton.setOnClickListener(v -> {
        i[0]++;
        listLines.add(messageField.getText().toString());
        messageField.setText("");
        inputLayout.setHint(String.format(App.get().getString(R.string.codes_list_item_Pos), i[0]));
    });
    messageField.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            positiveButton.setEnabled(s.length() > 0);
        }
    });
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher) Pair(android.util.Pair) HashMap(java.util.HashMap) InsertHelper(forpdateam.ru.forpda.ui.views.messagepanel.inserthelper.InsertHelper) TextInputLayout(android.support.design.widget.TextInputLayout) ArrayList(java.util.ArrayList) ItemDragCallback(forpdateam.ru.forpda.ui.views.messagepanel.advanced.adapters.ItemDragCallback) ApiUtils(forpdateam.ru.forpda.api.ApiUtils) SuppressLint(android.annotation.SuppressLint) MessagePanel(forpdateam.ru.forpda.ui.views.messagepanel.MessagePanel) SimpleInstruction(forpdateam.ru.forpda.ui.views.messagepanel.SimpleInstruction) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) Map(java.util.Map) View(android.view.View) Button(android.widget.Button) PanelItemAdapter(forpdateam.ru.forpda.ui.views.messagepanel.advanced.adapters.PanelItemAdapter) DialogInterface(android.content.DialogInterface) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) ColorPicker(forpdateam.ru.forpda.ui.views.messagepanel.colorpicker.ColorPicker) App(forpdateam.ru.forpda.App) R(forpdateam.ru.forpda.R) Collections(java.util.Collections) EditText(android.widget.EditText) View(android.view.View) SuppressLint(android.annotation.SuppressLint) SimpleTextWatcher(forpdateam.ru.forpda.common.simple.SimpleTextWatcher) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) ArrayList(java.util.ArrayList) List(java.util.List) TextInputLayout(android.support.design.widget.TextInputLayout) Pair(android.util.Pair)

Aggregations

SimpleTextWatcher (forpdateam.ru.forpda.common.simple.SimpleTextWatcher)5 View (android.view.View)3 App (forpdateam.ru.forpda.App)3 R (forpdateam.ru.forpda.R)3 ArrayList (java.util.ArrayList)3 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 AlertDialog (android.support.v7.app.AlertDialog)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 LayoutInflater (android.view.LayoutInflater)2 EditText (android.widget.EditText)2 RxApi (forpdateam.ru.forpda.apirx.RxApi)2 List (java.util.List)2 DialogInterface (android.content.DialogInterface)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 TextInputLayout (android.support.design.widget.TextInputLayout)1 Fragment (android.support.v4.app.Fragment)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1