2a7a269f44ad656d556dL727">727
public static Uri getImageContentUri(Context context, File imageFile) {
String filePath = imageFile.getAbsolutePath();
Cursor cursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media._ID},
MediaStore.Images.Media.DATA + "=? ",
new String[]{filePath}, null);
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getInt(cursor
.getColumnIndex(MediaStore.MediaColumns._ID));
Uri baseUri = Uri.parse("content://media/external/images/media");
return Uri.withAppendedPath(baseUri, "" + id);
} else {
if (imageFile.exists()) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATA, filePath);
return context.getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
} else {
return null;
}
}
}
public Bitmap decodeUriAsBitmap(Uri uri) {
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri));
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
return bitmap;
}
@Override
protected void onRestart() {
protected void onRestart() {
adapter.update();
adapter.update();
super.onRestart();
super.onRestart();
Bimp.max = 0;
Bimp.max = 0;
}
}
private void uploadFeedbackPic() {
Map<String, String> par = new HashMap<String, String>();
String file;
for (int i = 0; i < Bimp.tempSelectBitmap.size(); i++) {
try {
bm = imageZoom(Bimp.tempSelectBitmap.get(i).getBitmap());
file = bitmapToBase64(bm);
par.put("file" + (i + 1), file);
Log.i("file--------" + (i + 1), file);
par.put("filename" + (i + 1), "androidapp.jpg");
} catch (Exception e) {
e.printStackTrace();
}
}
try {
String u = UploadUtil.postTopicPicture(
MainApplication.urlNew + "/topic/sign.do",
// "http://123.57.6.131/zhannew/basic/web/index.php/zhanlist/add",
// "http://59.110.68.162"+"/zhannew/fileupload/multi-upload",
par, null);
System.err.println(u);
// submit(u);
Message msg = new Message();
msg.obj = u;
msg.what = 2;
handler.sendMessage(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
private String bitmapToBase64(Bitmap bitmap) {
String result = null;
ByteArrayOutputStream baos = null;
try {
if (bitmap != null) {
baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
baos.flush();
baos.close();
byte[] bitmapBytes = baos.toByteArray();
result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (baos != null) {
baos.flush();
baos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
private Bitmap imageZoom(Bitmap bm) {
private Bitmap imageZoom(Bitmap bm) {
// 图片允许最大空间 单位:KB
// 图片允许最大空间 单位:KB
double maxSize = 200.00;
double maxSize = 200.00;
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
final String imem;
final String imem;
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
imem = "";
imem = "";
} else {
} else {
imem = telephonyManager.getDeviceId();
imem = telephonyManager.getDeviceId();
/**
/**
* 表单上传
* 表单上传
*
*
* @param SAMPLE_PIC_FILE
* @param sign
* @param sign
* @param saveName
* @param policyServer
*/
*/
private void formUpload(String SAMPLE_PIC_FILE, String sign, String saveName, String policyServer) {
private void formUpload(String SAMPLE_PIC_FILE, String sign, String policyServer) {
File temp = new File(SAMPLE_PIC_FILE);
File temp = new File(SAMPLE_PIC_FILE);
//
// final Map<String, Object> paramsMap = new HashMap<>();
// //上传空间
// paramsMap.put(Params.BUCKET, SPACE);
// //保存路径,任选其中一个
// paramsMap.put(Params.SAVE_KEY, picSavePath);
// //添加 CONTENT_LENGTH 参数使用大文件表单上传
// paramsMap.put(Params.CONTENT_LENGTH, temp.length());
//
//
// paramsMap.put(Params.CONTENT_MD5, UpYunUtils.md5Hex(temp));
//// paramsMap.put(Params.PATH, savePath);
// //可选参数(详情见api文档介绍)
// paramsMap.put(Params.RETURN_URL, "httpbin.org/post");
// //进度回调,可为空
// //进度回调,可为空
UpProgressListener progressListener = new UpProgressListener() {
UpProgressListener progressListener = new UpProgressListener() {
@Override
@Override
Log.e(TAG, isSuccess + ":" + result);
Log.e(TAG, isSuccess + ":" + result);
}
}
};
};
//表单上传(服务器签名方式)
//表单上传(服务器签名方式)
UploadEngine.getInstance().formUpload(temp, policyServer, OPERATER, sign, completeListener, progressListener);
UploadEngine.getInstance().formUpload(temp, policyServer, OPERATER, sign, completeListener,
progressListener);
}
}
|
|
||
| 3 |
|
3 |
|
| 4 |
|
4 |
|
| 5 |
|
5 |
|
|
6 |
|
|
|
7 |
|
|
| 6 |
|
8 |
|
| 7 |
|
9 |
|
|
10 |
|
|
| 8 |
|
11 |
|
| 9 |
|
12 |
|
| 10 |
|
13 |
|
|
|
||
| 14 |
|
17 |
|
| 15 |
|
18 |
|
| 16 |
|
19 |
|
|
20 |
|
|
| 17 |
|
21 |
|
| 18 |
|
22 |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
| 19 |
|
28 |
|
| 20 |
|
29 |
|
| 21 |
|
30 |
|
|
|
||
| 30 |
|
39 |
|
| 31 |
|
40 |
|
| 32 |
|
41 |
|
| 33 |
|
|
|
| 34 |
|
|
|
| 35 |
|
|
|
| 36 |
|
42 |
|
| 37 |
|
|
|
| 38 |
|
43 |
|
| 39 |
|
44 |
|
| 40 |
|
45 |
|
|
|
||
| 43 |
|
48 |
|
| 44 |
|
49 |
|
| 45 |
|
50 |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
| 46 |
|
57 |
|
| 47 |
|
58 |
|
| 48 |
|
59 |
|
|
|
||
| 68 |
|
79 |
|
| 69 |
|
80 |
|
| 70 |
|
81 |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
| 71 |
|
87 |
|
| 72 |
|
88 |
|
| 73 |
|
89 |
|
|
|
||
| 97 |
|
113 |
|
| 98 |
|
114 |
|
| 99 |
|
115 |
|
|
116 |
|
|
| 100 |
|
117 |
|
| 101 |
|
118 |
|
| 102 |
|
119 |
|
|
|
||
| 146 |
|
163 |
|
| 147 |
|
164 |
|
| 148 |
|
165 |
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
| 149 |
|
170 |
|
| 150 |
|
171 |
|
| 151 |
|
172 |
|
|
|
||
| 171 |
|
192 |
|
| 172 |
|
193 |
|
| 173 |
|
194 |
|
| 174 |
|
|
|
|
195 |
|
|
| 175 |
|
196 |
|
| 176 |
|
197 |
|
| 177 |
|
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
| 178 |
|
217 |
|
| 179 |
|
218 |
|
| 180 |
|
219 |
|
| 181 |
|
220 |
|
| 182 |
|
221 |
|
| 183 |
|
|
|
| 184 |
|
222 |
|
| 185 |
|
223 |
|
| 186 |
|
|
|
| 187 |
|
|
|
| 188 |
|
224 |
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
| 189 |
|
229 |
|
| 190 |
|
230 |
|
| 191 |
|
231 |
|
|
|
||
| 68 |
|
68 |
|
| 69 |
|
69 |
|
| 70 |
|
70 |
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
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 |
|
|
| 71 |
|
99 |
|
| 72 |
|
100 |
|
| 73 |
|
101 |
|
|
|
||
| 21 |
|
21 |
|
| 22 |
|
22 |
|
| 23 |
|
23 |
|
| 24 |
|
|
|
|
24 |
|
|
| 25 |
|
25 |
|
| 26 |
|
26 |
|
| 27 |
|
27 |
|