質問編集履歴
2
インデント対応、ソース追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,59 +72,123 @@
|
|
72
72
|
|
73
73
|
implements View.OnClickListener, FragmentCompat.OnRequestPermissionsResultCallback {
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
mImageView
|
75
|
+
|
76
|
+
|
77
|
+
…
|
78
|
+
|
79
|
+
private ImageView mImageView;
|
80
|
+
|
81
|
+
…
|
82
|
+
|
83
|
+
private final ImageReader.OnImageAvailableListener mOnImageAvailableListener
|
84
|
+
|
85
|
+
= new ImageReader.OnImageAvailableListener() {
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
@Override
|
90
|
+
|
91
|
+
public void onImageAvailable(ImageReader reader) {
|
92
|
+
|
93
|
+
// mBackgroundHandler.post(new ImageSaver(reader.acquireNextImage(), mFile));
|
94
|
+
|
95
|
+
mBackgroundHandler.post(new ImageSaver(reader.acquireNextImage(), mFile, mImageView));
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
};
|
102
|
+
|
103
|
+
…
|
104
|
+
|
105
|
+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
106
|
+
|
107
|
+
Bundle savedInstanceState) {
|
108
|
+
|
109
|
+
View v = inflater.inflate(R.layout.fragment_camera2_basic, container, false);
|
110
|
+
|
111
|
+
return v;
|
112
|
+
|
113
|
+
…
|
114
|
+
|
115
|
+
public void onViewCreated(final View view, Bundle savedInstanceState) {
|
116
|
+
|
117
|
+
//freddie
|
118
|
+
|
119
|
+
view.findViewById(R.id.picture).setOnClickListener(this);
|
120
|
+
|
121
|
+
view.findViewById(R.id.sb).setOnClickListener(this);
|
122
|
+
|
123
|
+
mTextureView = (AutoFitTextureView) view.findViewById(R.id.texture);
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
mImageView = (ImageView) view.findViewById(R.id.foto);
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
…
|
132
|
+
|
133
|
+
private void takePicture() {
|
134
|
+
|
135
|
+
lockFocus();
|
136
|
+
|
137
|
+
Bitmap src = BitmapFactory.decodeFile(mFile.toString());
|
138
|
+
|
139
|
+
mImageView.setImageBitmap(src);★
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
…
|
144
|
+
|
145
|
+
<追加>
|
146
|
+
|
147
|
+
public void run() {
|
148
|
+
|
149
|
+
ByteBuffer buffer = mImage.getPlanes()[0].getBuffer();
|
150
|
+
|
151
|
+
byte[] bytes = new byte[buffer.remaining()];
|
152
|
+
|
153
|
+
buffer.get(bytes);
|
154
|
+
|
155
|
+
FileOutputStream output = null;
|
156
|
+
|
157
|
+
try {
|
158
|
+
|
159
|
+
output = new FileOutputStream(mFile);
|
160
|
+
|
161
|
+
output.write(bytes);
|
162
|
+
|
163
|
+
} catch (IOException e) {
|
164
|
+
|
165
|
+
e.printStackTrace();
|
166
|
+
|
167
|
+
} finally {
|
168
|
+
|
169
|
+
mImage.close();
|
170
|
+
|
171
|
+
if (null != output) {
|
172
|
+
|
173
|
+
try {
|
174
|
+
|
175
|
+
output.close();
|
176
|
+
|
177
|
+
} catch (IOException e) {
|
178
|
+
|
179
|
+
e.printStackTrace();
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
// Bitmap src = BitmapFactory.decodeFile(mFile.toString());
|
188
|
+
|
189
|
+
// mImageView.setImageBitmap(src);
|
190
|
+
|
191
|
+
}
|
128
192
|
|
129
193
|
…
|
130
194
|
|
1
コード添付の際にインデント自動設定をおこなった
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
###該当のソースコード
|
28
28
|
|
29
|
-
|
29
|
+
```XML
|
30
30
|
|
31
31
|
<fragment_camera2_basic.xml>
|
32
32
|
|
@@ -58,7 +58,11 @@
|
|
58
58
|
|
59
59
|
…
|
60
60
|
|
61
|
+
```
|
61
62
|
|
63
|
+
|
64
|
+
|
65
|
+
```JAVA
|
62
66
|
|
63
67
|
<fragment_camera2_basic.java>
|
64
68
|
|
@@ -124,6 +128,10 @@
|
|
124
128
|
|
125
129
|
…
|
126
130
|
|
131
|
+
```
|
132
|
+
|
133
|
+
|
134
|
+
|
127
135
|
★この処理はエラーにならないものの、takePitureで撮影された写真が保存される前のファイルが表示されてしまう。
|
128
136
|
|
129
137
|
|