|
| 1 | +package com.ve.acpp; |
| 2 | + |
| 3 | +import android.os.Bundle; |
| 4 | +import android.support.v7.app.AppCompatActivity; |
| 5 | +import android.view.View; |
| 6 | + |
| 7 | +import com.ve.view.editor.Editor; |
| 8 | +import com.ve.view.editor.out.Config; |
| 9 | +import com.ve.view.editor.out.TextInterface; |
| 10 | +import com.ve.view.ext.ClipboardPanel; |
| 11 | + |
| 12 | +import java.util.Random; |
| 13 | + |
| 14 | +public class MainActivity extends AppCompatActivity { |
| 15 | + |
| 16 | + Editor editor; |
| 17 | + |
| 18 | + ClipboardPanel clipboardPanel; |
| 19 | + @Override |
| 20 | + protected void onCreate(Bundle savedInstanceState) { |
| 21 | + super.onCreate(savedInstanceState); |
| 22 | + setContentView(R.layout.activity_main); |
| 23 | + editor = findViewById(R.id.activity_main_editor); |
| 24 | + Config config=new Config(); |
| 25 | + config.showNonPrinting=true; |
| 26 | + config.wordWrap=false; |
| 27 | + editor.applyConfig(config); |
| 28 | + clipboardPanel=new ClipboardPanel(editor); |
| 29 | + editor.getOperator().setSelectionChangedListener((active, selStart, selEnd) -> { |
| 30 | + if (active){ |
| 31 | + clipboardPanel.show(); |
| 32 | + }else { |
| 33 | + clipboardPanel.hide(); |
| 34 | + } |
| 35 | + }); |
| 36 | + |
| 37 | + test(); |
| 38 | + } |
| 39 | + |
| 40 | + private void test() { |
| 41 | + StringBuffer stringBuffer = new StringBuffer(); |
| 42 | + Random random=new Random(); |
| 43 | + for (int i = 0; i < 20; i++) { |
| 44 | + if (random.nextBoolean()) { |
| 45 | + stringBuffer.append(" asfgweilfuWEF72QWDFYFregargaergnwderghwaefwsefweg数的rnwd文档发给nueffgeriugiesgier\n"); |
| 46 | + } |
| 47 | + stringBuffer.append(" asfgweilfuWEF72G\nQWDFYF、nwdwefgGAGDGSDFGHAWERGHWERHERREGRAGEsddnwd、nuef\nefgeriugiesgier\n"); |
| 48 | + |
| 49 | + } |
| 50 | + |
| 51 | + TextInterface textInterface = editor.getTextInterface(); |
| 52 | + textInterface.paste(stringBuffer.toString()); |
| 53 | + textInterface.replaceText(0,textInterface.getLength()-1,"Good!"); |
| 54 | + } |
| 55 | + |
| 56 | + public void onRedo(View view) { |
| 57 | + editor.getTextInterface().redo(); |
| 58 | + } |
| 59 | + |
| 60 | + public void onUndo(View view) { |
| 61 | + editor.getTextInterface().undo(); |
| 62 | + } |
| 63 | +} |
0 commit comments