Skip to content

Commit 4ed3530

Browse files
committed
update ui
1 parent f16e349 commit 4ed3530

4 files changed

Lines changed: 60 additions & 8 deletions

File tree

app/src/main/java/com/moioio/moioio_lib/TestView.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.moioio.moioio_lib;
22

3+
import android.app.Activity;
4+
import android.content.ClipboardManager;
35
import android.content.Context;
46
import android.graphics.Color;
57
import android.widget.ImageView;
68

79
import com.moioio.android.MyAndroidLib;
810
import com.moioio.android.easyui.UI;
11+
import com.moioio.android.easyui.widget.MyEditText;
912
import com.moioio.android.easyui.widget.MyGifView;
1013
import com.moioio.android.easyui.widget.MyImageView;
1114
import com.moioio.android.easyui.widget.MyLayout;
@@ -14,6 +17,7 @@
1417
import com.moioio.android.util.BitmapUtil;
1518
import com.moioio.android.util.DisplayUtil;
1619
import com.moioio.android.util.ViewUtil;
20+
import com.moioio.util.MyLog;
1721

1822
public class TestView extends MyView {
1923

@@ -27,6 +31,7 @@ public TestView(Context context) {
2731
@Override
2832
public void initPage(Context context) {
2933
setBackgroundColor(Color.BLUE);
34+
registerClipListener(getActivity());
3035

3136
// myGifView = new MyGifView(context);
3237
// myGifView.load("assets://ic_game.gif");
@@ -83,13 +88,57 @@ public void initPage(Context context) {
8388
// btn.setOnClickListener(v->{
8489
//
8590
// });
91+
92+
MyEditText myEditText = new MyEditText(context);
93+
myEditText.makeLayout(UI.FILL_PARENT,UI.WRAP_CONTENT);
94+
95+
8696
//
8797
this.addView(view);
8898
this.addView(view2);
99+
this.addView(myEditText);
89100

90101

91102
view.setOnClickListener(v->{
92103
v.requestLayout();
93104
});
94105
}
106+
107+
108+
ClipboardManager mClipboardManager;
109+
ClipboardManager.OnPrimaryClipChangedListener mOnPrimaryClipChangedListener;
110+
private void registerClipListener(Activity activity) {
111+
mClipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
112+
mOnPrimaryClipChangedListener = new ClipboardManager.OnPrimaryClipChangedListener() {
113+
@Override
114+
public void onPrimaryClipChanged() {
115+
116+
117+
118+
if (mClipboardManager.hasPrimaryClip()
119+
&& mClipboardManager.getPrimaryClip().getItemCount() > 0) {
120+
// 获取复制、剪切的文本内容
121+
CharSequence content = mClipboardManager.getPrimaryClip().getItemAt(0).getText();
122+
MyLog.debug( "复制、剪切的内容为:" + content);
123+
}
124+
}
125+
};
126+
mClipboardManager.addPrimaryClipChangedListener(mOnPrimaryClipChangedListener);
127+
}
128+
129+
130+
private void clearClipListener()
131+
{
132+
try {
133+
if (mClipboardManager != null && mOnPrimaryClipChangedListener != null) {
134+
mClipboardManager.removePrimaryClipChangedListener(mOnPrimaryClipChangedListener);
135+
}
136+
}
137+
catch (Exception e)
138+
{
139+
e.printStackTrace();
140+
}
141+
}
142+
143+
95144
}

easy-ui/src/main/java/com/moioio/android/easyui/widget/round/RoundHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ private void setData() {
5757
mPaint = new Paint();
5858
mPath = new Path();
5959
mTempPath = new Path();
60-
mXfermode = new PorterDuffXfermode(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PorterDuff.Mode.DST_OUT : PorterDuff.Mode.DST_IN);
60+
// mXfermode = new PorterDuffXfermode(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PorterDuff.Mode.DST_OUT : PorterDuff.Mode.DST_IN);
61+
mXfermode = new PorterDuffXfermode(PorterDuff.Mode.XOR);
6162
}
6263

6364

easy-ui/src/main/java/com/moioio/android/g2d/Graphics.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class Graphics
5656
private Matrix matrix = new Matrix();
5757
private DashPathEffect dashPathEffect = new DashPathEffect(new float[]{7, 7}, 0);
5858

59-
59+
private int canvasInitSave;
6060
public Graphics()
6161
{
6262
paint = new Paint();
@@ -74,7 +74,7 @@ public Graphics(Canvas canvas)
7474
paint = new Paint();
7575
paint.setAntiAlias(true);
7676
paint.setDither(true);
77-
77+
canvasInitSave = canvas.save();
7878
// textPaint = new TextPaint();
7979
// textPaint.setAntiAlias(true);
8080
// textPaint.setDither(true);
@@ -87,6 +87,7 @@ public Graphics(Canvas canvas)
8787
public void setCanvas(Canvas canvas)
8888
{
8989
grap = canvas;
90+
canvasInitSave = canvas.save();
9091
}
9192

9293

@@ -204,6 +205,8 @@ public void setClip(int x, int y, int width, int height)
204205
clip.set(x+offX, y+offY, x+offX + width, y+offY + height);
205206
// grap.clipRect(clip, Region.Op.REPLACE);
206207
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
208+
grap.restore();
209+
grap.save();
207210
grap.clipRect(clip );//p,
208211
}else {
209212
grap.clipRect(clip, Region.Op.REPLACE);
@@ -225,6 +228,8 @@ public void setOutClip(int x, int y, int width, int height, Region.Op op)
225228
{
226229
clip.set(x+offX, y+offY, x+offX + width, y+offY + height);
227230
if(Build.VERSION.SDK_INT >= 26){
231+
grap.restore();
232+
grap.save();
228233
grap.clipOutRect(clip );//p, android.graphics.Region.Op.REPLACE
229234
}else {
230235
grap.clipRect(clip, op);

util-lib/src/main/java/com/moioio/util/RandomUtil.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Random;
66

77
public class RandomUtil {
8+
static Random rand = new Random();
89

910

1011
public static void makeRandomList(List list)
@@ -45,10 +46,9 @@ public static int[] getRandomArray(int min,int max,int n){
4546
}
4647

4748
int[] result = new int[n];
48-
Random rd = new Random();
4949
int index = 0;
5050
for (int i = 0; i < result.length; i++) {
51-
index = Math.abs(rd.nextInt() % len--);
51+
index = Math.abs(rand.nextInt() % len--);
5252
result[i] = source[index];
5353
source[index] = source[len];
5454
}
@@ -57,20 +57,17 @@ public static int[] getRandomArray(int min,int max,int n){
5757

5858

5959
public static int getRandom(int size) {
60-
Random rand = new Random();
6160
int which = Math.abs(rand.nextInt()%size);
6261
return which;
6362
}
6463

6564
public static int getRandomNoSign(int size) {
66-
Random rand = new Random();
6765
int which = rand.nextInt()%size;
6866
return which;
6967
}
7068

7169
public static String getRandomStr(String[] letters)
7270
{
73-
Random rand = new Random();
7471
int which = Math.abs(rand.nextInt()%letters.length);
7572
String s = letters[which];
7673
return s;

0 commit comments

Comments
 (0)