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);
}
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);
}
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;
}
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);
}
});
}
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);
}
});
}
Aggregations