android:update snapshot control api
This commit is contained in:
parent
227cc09824
commit
cf116dbb31
@ -7,7 +7,7 @@
|
|||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
<activity android:name=".ui.DoricDevActivity" />
|
<activity android:name=".ui.DoricDevActivity" android:exported="true"/>
|
||||||
<activity android:name=".qrcode.activity.CaptureActivity" />
|
<activity android:name=".qrcode.activity.CaptureActivity" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2019] [Doric.Pub]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package pub.doric.devkit.ui;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: pub.doric.devkit.ui
|
||||||
|
* @Author: pengfei.zhou
|
||||||
|
* @CreateDate: 2021/7/13
|
||||||
|
*/
|
||||||
|
public class DoricFloatingView extends FrameLayout {
|
||||||
|
private int lastX;
|
||||||
|
|
||||||
|
private int lastY;
|
||||||
|
|
||||||
|
public DoricFloatingView(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
int x = (int) event.getX();
|
||||||
|
int y = (int) event.getY();
|
||||||
|
|
||||||
|
switch (event.getAction()) {
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
lastX = x;
|
||||||
|
lastY = y;
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
int offsetX = x - lastX;
|
||||||
|
int offsetY = y - lastY;
|
||||||
|
FrameLayout.LayoutParams layoutParams = (LayoutParams) getLayoutParams();
|
||||||
|
layoutParams.leftMargin += offsetX;
|
||||||
|
layoutParams.topMargin += offsetY;
|
||||||
|
requestLayout();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -21,10 +21,8 @@ import android.content.Context;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -50,10 +48,7 @@ import pub.doric.utils.ThreadMode;
|
|||||||
* @CreateDate: 2021/7/9
|
* @CreateDate: 2021/7/9
|
||||||
*/
|
*/
|
||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
public class DoricSnapshotView extends FrameLayout {
|
public class DoricSnapshotView extends DoricFloatingView {
|
||||||
private int lastX;
|
|
||||||
|
|
||||||
private int lastY;
|
|
||||||
private final DoricContext doricContext;
|
private final DoricContext doricContext;
|
||||||
private int snapNo = -1;
|
private int snapNo = -1;
|
||||||
private int snapSize = 0;
|
private int snapSize = 0;
|
||||||
@ -65,7 +60,7 @@ public class DoricSnapshotView extends FrameLayout {
|
|||||||
super(context);
|
super(context);
|
||||||
this.doricContext = doricContext;
|
this.doricContext = doricContext;
|
||||||
initView(context);
|
initView(context);
|
||||||
this.setAlpha(0.5f);
|
this.setAlpha(0.8f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initView(Context context) {
|
private void initView(Context context) {
|
||||||
@ -131,31 +126,9 @@ public class DoricSnapshotView extends FrameLayout {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
|
||||||
int x = (int) event.getX();
|
|
||||||
int y = (int) event.getY();
|
|
||||||
|
|
||||||
switch (event.getAction()) {
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
lastX = x;
|
|
||||||
lastY = y;
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
int offsetX = x - lastX;
|
|
||||||
int offsetY = y - lastY;
|
|
||||||
layout(getLeft() + offsetX, getTop() + offsetY, getRight() + offsetX, getBottom() + offsetY);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rollupSnapshot(int index) {
|
private void rollupSnapshot(int index) {
|
||||||
spanPre.setVisibility(index <= 0 ? View.INVISIBLE : View.VISIBLE);
|
spanPre.setImageAlpha(index <= 0 ? 0x7f : 0xff);
|
||||||
spanNext.setVisibility(index >= snapSize ? View.INVISIBLE : View.VISIBLE);
|
spanNext.setImageAlpha(index >= snapSize ? 0x7f : 0xff);
|
||||||
snapIndex.setText(String.valueOf(index));
|
snapIndex.setText(String.valueOf(index));
|
||||||
doricContext.callEntity("__restoreRenderSnapshot__", index).setCallback(new AsyncResult.Callback<JSDecoder>() {
|
doricContext.callEntity("__restoreRenderSnapshot__", index).setCallback(new AsyncResult.Callback<JSDecoder>() {
|
||||||
@Override
|
@Override
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
@ -5,18 +5,29 @@
|
|||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="255dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="70dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:background="#ecf0f1"
|
android:background="#ecf0f1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="15dp">
|
android:paddingLeft="0dp"
|
||||||
|
android:paddingTop="15dp"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:paddingBottom="15dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/icon_doricdev_move" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/snap_pre"
|
android:id="@+id/snap_pre"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
android:scaleType="fitXY"
|
||||||
android:src="@drawable/icon_doricdev_prev" />
|
android:src="@drawable/icon_doricdev_prev" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -34,6 +45,7 @@
|
|||||||
android:id="@+id/snap_next"
|
android:id="@+id/snap_next"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
android:scaleType="fitXY"
|
||||||
android:src="@drawable/icon_doricdev_next" />
|
android:src="@drawable/icon_doricdev_next" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -41,6 +53,7 @@
|
|||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginLeft="20dp"
|
||||||
|
android:scaleType="fitXY"
|
||||||
android:src="@drawable/icon_doricdev_close" />
|
android:src="@drawable/icon_doricdev_close" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user