Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
9b0d4771
Commit
9b0d4771
authored
Dec 15, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simugu Bug修复 第二版
parent
e72b4a25
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
27 deletions
+54
-27
src/main/java/tech/starwin/impl/HttpObserver.java
+1
-1
src/main/java/tech/starwin/mvp/ui/activity/TakePhotoActivity.java
+11
-2
src/main/java/tech/starwin/utils/BitmapUtils.java
+1
-0
src/main/java/tech/starwin/widget/CameraView.java
+25
-11
src/main/res/drawable-v21/selector_recycler_item.xml
+8
-0
src/main/res/drawable/selector_recycler_item.xml
+2
-7
src/main/res/layout/activity_take_photo.xml
+2
-2
src/main/res/layout/dialog_photo_face.xml
+1
-1
src/main/res/layout/dialog_photo_id.xml
+1
-1
src/main/res/layout/dialog_photo_work.xml
+2
-2
No files found.
src/main/java/tech/starwin/impl/HttpObserver.java
View file @
9b0d4771
...
...
@@ -68,7 +68,7 @@ public abstract class HttpObserver<T> implements Observer<T> {
}
}
catch
(
Throwable
e
)
{
onError
(
Error
.
APP_ERROR
,
"
Program Exception
: "
+
msg
);
onError
(
Error
.
APP_ERROR
,
"
Error
: "
+
msg
);
}
if
(
disposable
!=
null
)
disposable
.
dispose
();
...
...
src/main/java/tech/starwin/mvp/ui/activity/TakePhotoActivity.java
View file @
9b0d4771
...
...
@@ -82,7 +82,7 @@ public class TakePhotoActivity extends BaseActivity {
cameraView
=
findViewById
(
R
.
id
.
cameraView
);
maskImv
=
findViewById
(
R
.
id
.
activity_takephoto_mask_imv
);
cameraView
.
setTargetPreviewSize
(
1
920
,
108
0
);
cameraView
.
setTargetPreviewSize
(
1
280
,
72
0
);
int
mask
=
getIntent
().
getIntExtra
(
"preview_mask"
,
0
);
int
btnImg
=
getIntent
().
getIntExtra
(
"shoot_btn_img"
,
0
);
...
...
@@ -106,7 +106,16 @@ public class TakePhotoActivity extends BaseActivity {
if
(!
image
.
exists
())
{
image
.
mkdir
();
}
BitmapUtils
.
saveBitmapToSDCard
(
bitmap
,
image
,
100
);
File
file
=
BitmapUtils
.
saveBitmapToSDCard
(
bitmap
,
image
,
100
);
//如果图片过大,则压缩
long
size
=
FileUtils
.
getFileSize
(
file
)/
1024
;
if
(
FileUtils
.
getFileSize
(
file
)
/
1024
>
1024
)
{
int
quality
=
(
int
)
(
100
*
(
1024
f
/
size
));
file
=
BitmapUtils
.
saveBitmapToSDCard
(
bitmap
,
image
,
quality
);
}
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"image_path"
,
image
.
getAbsolutePath
());
setResult
(
RESULT_OK
,
intent
);
...
...
src/main/java/tech/starwin/utils/BitmapUtils.java
View file @
9b0d4771
...
...
@@ -267,4 +267,5 @@ public class BitmapUtils {
return
bitmapDrawable
.
getBitmap
();
}
}
src/main/java/tech/starwin/widget/CameraView.java
View file @
9b0d4771
...
...
@@ -17,6 +17,8 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.util.List
;
import
tech.starwin.utils.ui_utils.DialogFactory
;
/**
* Created by SiKang on 2018/12/14.
*/
...
...
@@ -27,11 +29,13 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback, C
//默认预览尺寸
private
int
imageWidth
=
1920
;
private
int
imageHeight
=
1080
;
//帧率
private
int
frameRate
=
30
;
//默认View尺寸
private
int
defaultWidth
=
0
;
private
int
defaultHeight
=
0
;
private
boolean
isCaptureImage
=
false
;
private
OnSurfaceChangedListener
surfaceChangedListener
;
public
CameraView
(
Context
context
)
{
...
...
@@ -64,9 +68,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback, C
@Override
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
//设置Camera基本参数
if
(
mCamera
!=
null
)
initCameraParams
();
}
@Override
...
...
@@ -126,9 +128,15 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback, C
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
defaultWidth
=
MeasureSpec
.
getSize
(
widthMeasureSpec
);
defaultHeight
=
MeasureSpec
.
getSize
(
heightMeasureSpec
);
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
}
@Override
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
int
bottom
)
{
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
}
/**
* 摄像头配置
...
...
@@ -145,16 +153,19 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback, C
break
;
}
}
camParams
.
setPreviewSize
(
imageWidth
,
imageHeight
);
camParams
.
setPictureSize
(
imageWidth
,
imageHeight
);
//
camParams.setPreviewSize(imageWidth, imageHeight);
//
camParams.setPictureSize(imageWidth, imageHeight);
// Log.v(TAG, "Setting imageWidth: " + imageWidth + " imageHeight: " + imageHeight + " frameRate: " + frameRate);
camParams
.
setPreviewFrameRate
(
frameRate
);
// Log.v(TAG, "Preview Framerate: " + camParams.getPreviewFrameRate());
mCamera
.
setParameters
(
camParams
);
// mCamera.setParameters(camParams);
//取到的图像默认是横向的,这里旋转90度,保持和预览画面相同
mCamera
.
setDisplayOrientation
(
90
);
if
(
defaultWidth
!=
0
)
{
float
xy
=
((
float
)
imageWidth
)
/
imageHeight
;
int
heightSize
=
(
int
)
(
xy
*
defaultWidth
);
layout
(
0
,
(
defaultHeight
-
heightSize
)
/
2
,
defaultWidth
,
heightSize
+
(
defaultHeight
-
heightSize
)
/
2
);
startPreview
();
}
}
...
...
@@ -195,6 +206,9 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback, C
if
(
cameraInfo
.
facing
==
Camera
.
CameraInfo
.
CAMERA_FACING_BACK
)
{
try
{
mCamera
=
Camera
.
open
(
cameraId
);
if
(
mCamera
!=
null
)
{
initCameraParams
();
}
}
catch
(
Exception
e
)
{
if
(
mCamera
!=
null
)
{
mCamera
.
release
();
...
...
src/main/res/drawable-v21/selector_recycler_item.xml
0 → 100644
View file @
9b0d4771
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:color=
"@color/qmui_config_color_gray_9"
tools:ignore=
"NewApi"
>
<item
android:drawable=
"@color/white"
/>
</ripple>
\ No newline at end of file
src/main/res/drawable/selector_recycler_item.xml
View file @
9b0d4771
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:color=
"@color/qmui_config_color_gray_9"
tools:ignore=
"NewApi"
>
<item
android:drawable=
"@color/white"
/>
</ripple>
\ No newline at end of file
<selector></selector>
\ No newline at end of file
src/main/res/layout/activity_take_photo.xml
View file @
9b0d4771
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
<tech.starwin.widget.CameraView
android:id=
"@+id/cameraView"
...
...
src/main/res/layout/dialog_photo_face.xml
View file @
9b0d4771
...
...
@@ -20,7 +20,7 @@
android:textColor=
"@color/qmui_config_color_gray_3"
/>
<TextView
android:layout_width=
"
match_parent
"
android:layout_width=
"
280dp
"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:gravity=
"center"
...
...
src/main/res/layout/dialog_photo_id.xml
View file @
9b0d4771
...
...
@@ -8,7 +8,7 @@
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"
wrap_content
"
android:layout_width=
"
300dp
"
android:layout_height=
"wrap_content"
android:background=
"@drawable/shape_rectangle_navy_solid"
android:orientation=
"vertical"
>
...
...
src/main/res/layout/dialog_photo_work.xml
View file @
9b0d4771
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"
match_par
ent"
android:layout_width=
"
wrap_cont
ent"
android:layout_height=
"match_parent"
android:gravity=
"center"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"
match_parent
"
android:layout_width=
"
300dp
"
android:layout_height=
"wrap_content"
android:background=
"@color/white"
android:orientation=
"vertical"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment