213 lines
7.1 KiB
Java
213 lines
7.1 KiB
Java
package com.ubt.jimu.widgets;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.text.Editable;
|
|
import android.text.TextWatcher;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.EditText;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.R$styleable;
|
|
import com.ubt.jimu.utils.InputMethod;
|
|
import com.ubtrobot.log.ALog;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class CommentKeyBoard extends LinearLayout {
|
|
private String a;
|
|
private Activity b;
|
|
private RelativeLayout c;
|
|
private FrameLayout d;
|
|
private boolean e;
|
|
private int f;
|
|
private ImageView g;
|
|
private ImageView h;
|
|
private EditText i;
|
|
private TextView j;
|
|
private KeyBoardCommentListener k;
|
|
|
|
public interface KeyBoardCommentListener {
|
|
void onHideView();
|
|
|
|
void onKeyBoardCommitListener(String str);
|
|
}
|
|
|
|
public CommentKeyBoard(Context context) {
|
|
super(context);
|
|
this.a = "CommentKeyBoard";
|
|
this.e = true;
|
|
this.f = TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE;
|
|
a(context, (AttributeSet) null);
|
|
}
|
|
|
|
static /* synthetic */ boolean a(View view, MotionEvent motionEvent) {
|
|
return true;
|
|
}
|
|
|
|
private void d(View view) {
|
|
this.c = (RelativeLayout) view.findViewById(R.id.rl_keyboard);
|
|
this.g = (ImageView) view.findViewById(R.id.cancel);
|
|
this.h = (ImageView) view.findViewById(R.id.commit);
|
|
this.i = (EditText) view.findViewById(R.id.edit_comment);
|
|
this.j = (TextView) view.findViewById(R.id.text_count);
|
|
this.d = (FrameLayout) view.findViewById(R.id.fm_cancel);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
return this.e;
|
|
}
|
|
|
|
public void setAuthor(String str) {
|
|
String str2 = "@" + str + " ";
|
|
this.i.setText(str2);
|
|
this.i.setSelection(str2.length());
|
|
}
|
|
|
|
public void setCommentKey(boolean z) {
|
|
}
|
|
|
|
public void setEditTextContent(String str) {
|
|
this.i.setText(str);
|
|
}
|
|
|
|
public void setOnTouch(boolean z) {
|
|
this.e = z;
|
|
}
|
|
|
|
public void setTextCount(int i) {
|
|
this.f = i;
|
|
}
|
|
|
|
public void setonKeyBoardCommitListener(KeyBoardCommentListener keyBoardCommentListener) {
|
|
this.k = keyBoardCommentListener;
|
|
}
|
|
|
|
private void a(Context context, AttributeSet attributeSet) {
|
|
this.b = (Activity) context;
|
|
this.b.obtainStyledAttributes(attributeSet, R$styleable.CommentKeyBoard).getBoolean(0, false);
|
|
View inflate = LayoutInflater.from(context).inflate(R.layout.layout_comment_keyboard, (ViewGroup) this, true);
|
|
this.b.getWindow().getDecorView();
|
|
ALog.a(this.a).c("view 的地址根===" + inflate.toString(), new Object[0]);
|
|
d(inflate);
|
|
c();
|
|
setVisibility(8);
|
|
}
|
|
|
|
private void c() {
|
|
this.c.setOnTouchListener(new View.OnTouchListener() { // from class: com.ubt.jimu.widgets.c
|
|
@Override // android.view.View.OnTouchListener
|
|
public final boolean onTouch(View view, MotionEvent motionEvent) {
|
|
return CommentKeyBoard.a(view, motionEvent);
|
|
}
|
|
});
|
|
this.h.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.widgets.d
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
CommentKeyBoard.this.a(view);
|
|
}
|
|
});
|
|
this.g.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.widgets.a
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
CommentKeyBoard.this.b(view);
|
|
}
|
|
});
|
|
this.d.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.widgets.b
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
CommentKeyBoard.this.c(view);
|
|
}
|
|
});
|
|
this.i.addTextChangedListener(new TextWatcher() { // from class: com.ubt.jimu.widgets.CommentKeyBoard.1
|
|
@Override // android.text.TextWatcher
|
|
public void afterTextChanged(Editable editable) {
|
|
if (editable == null || editable.toString().length() <= 0) {
|
|
CommentKeyBoard.this.j.setText("0/" + CommentKeyBoard.this.f);
|
|
CommentKeyBoard.this.h.setSelected(false);
|
|
return;
|
|
}
|
|
CommentKeyBoard.this.j.setText(String.format("%s/" + CommentKeyBoard.this.f, Integer.valueOf(editable.toString().length())));
|
|
CommentKeyBoard.this.h.setSelected(true);
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
}
|
|
});
|
|
}
|
|
|
|
public /* synthetic */ void b(View view) {
|
|
KeyBoardCommentListener keyBoardCommentListener = this.k;
|
|
if (keyBoardCommentListener != null) {
|
|
keyBoardCommentListener.onHideView();
|
|
}
|
|
a();
|
|
}
|
|
|
|
public void b() {
|
|
setVisibility(0);
|
|
d();
|
|
ALog.a(this.a).c("键盘+" + this.i.isFocusable() + "comment==", new Object[0]);
|
|
InputMethod.c(this.b, this.i);
|
|
}
|
|
|
|
public CommentKeyBoard(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.a = "CommentKeyBoard";
|
|
this.e = true;
|
|
this.f = TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE;
|
|
a(context, attributeSet);
|
|
}
|
|
|
|
private void d() {
|
|
this.i.setFocusable(true);
|
|
this.i.setFocusableInTouchMode(true);
|
|
this.i.requestFocus();
|
|
}
|
|
|
|
public /* synthetic */ void c(View view) {
|
|
KeyBoardCommentListener keyBoardCommentListener = this.k;
|
|
if (keyBoardCommentListener != null) {
|
|
keyBoardCommentListener.onHideView();
|
|
}
|
|
a();
|
|
}
|
|
|
|
public CommentKeyBoard(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.a = "CommentKeyBoard";
|
|
this.e = true;
|
|
this.f = TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE;
|
|
a(context, attributeSet);
|
|
}
|
|
|
|
public /* synthetic */ void a(View view) {
|
|
KeyBoardCommentListener keyBoardCommentListener;
|
|
String trim = this.i.getText().toString().trim();
|
|
if ("".equals(trim) || (keyBoardCommentListener = this.k) == null) {
|
|
return;
|
|
}
|
|
keyBoardCommentListener.onKeyBoardCommitListener(trim);
|
|
this.i.setText("");
|
|
}
|
|
|
|
public void a() {
|
|
setVisibility(8);
|
|
InputMethod.a(this.b, this.i);
|
|
}
|
|
}
|