Skip to content

Commit

Permalink
Fix getText issue.Add getTextProcessor().
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadaghazadeh committed Oct 24, 2018
1 parent 258ff88 commit bc3433a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {
```groovy
dependencies {
...
implementation 'com.github.ahmadaghazadeh:CodeEditor:1.0.15'
implementation 'com.github.ahmadaghazadeh:CodeEditor:1.0.16'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CodeModel codeModel = new CodeModel("<html>", "html");
CodeModel codeModel = new CodeModel("<html>111111111111111111", "html");
ActivityMainBinding mViewDataBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
mViewDataBinding.setVariable(BR.viewModel, codeModel);
mViewDataBinding.setLifecycleOwner(this);
// mViewDataBinding.editor.setOnTextChange(str -> {
// Toast.makeText(this,str,Toast.LENGTH_LONG).show();
// });
mViewDataBinding.editor.setOnTextChange(str -> {
Toast.makeText(this, mViewDataBinding.editor.getText(),Toast.LENGTH_LONG).show();
});


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public class CodeEditor extends FrameLayout {
boolean isShowExtendedKeyboard = false;
int preHeight = 0;
private Context context;

public TextProcessor getTextProcessor() {
return editor;
}

private TextProcessor editor;
private Language language;
private LinesCollection lineNumbers;
Expand Down Expand Up @@ -414,20 +419,20 @@ public void setText(String text, int flag) {
if (text != null) {
setText(Editable.Factory.getInstance().newEditable(text), flag);
} else {
setText("", flag);
setText(Editable.Factory.getInstance().newEditable(""), flag);
}
}

public void setText(Editable text, int flag) {
if (flag == 1) {
this.text = text;
// this.text = text;
if (editor != null)
editor.setText(this.text);
editor.setText(text);
return;
}
int length = 0;
if (this.text != null) {
length = this.text.length();
if (text != null) {
length = text.length();
}
replaceText(0, length, text);
setDirty(false);
Expand Down

0 comments on commit bc3433a

Please sign in to comment.