src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\ChangeBgFragment.java

src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\RegisterActivity.java
src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\UserInfoActivity.java
src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\PhotoUtil.javasrc\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\SystemUtils.java
This commit is contained in:
zhangnaifu15 2018-04-11 23:43:41 +08:00
parent 23e00ff44b
commit 34d0e34546
7 changed files with 17 additions and 82 deletions

View File

@ -73,7 +73,6 @@ public class ChangeBgFragment extends Fragment {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
String path = ((BgPicEntity) mBgPicAdapter.getItem(position)).path; String path = ((BgPicEntity) mBgPicAdapter.getItem(position)).path;
systemUtils = new SystemUtils(getActivity()); systemUtils = new SystemUtils(getActivity());

View File

@ -20,9 +20,7 @@ import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import cn.bmob.v3.listener.SaveListener; import cn.bmob.v3.listener.SaveListener;
/**
* Created by htq on 2016/9/4.
*/
public class RegisterActivity extends AppCompatActivity { public class RegisterActivity extends AppCompatActivity {
@BindView(R.id.et_username) @BindView(R.id.et_username)
@ -96,7 +94,6 @@ public class RegisterActivity extends AppCompatActivity {
@Override @Override
public void onSuccess() { public void onSuccess() {
// TODO Auto-generated method stub
progress.dismiss(); progress.dismiss();
Snackbar.make(registerBtn,"注册成功", Snackbar.LENGTH_LONG).show(); Snackbar.make(registerBtn,"注册成功", Snackbar.LENGTH_LONG).show();
// 将设备与username进行绑定 // 将设备与username进行绑定
@ -110,7 +107,6 @@ public class RegisterActivity extends AppCompatActivity {
} }
@Override @Override
public void onFailure(int arg0, String arg1) { public void onFailure(int arg0, String arg1) {
// TODO Auto-generated method stub
Snackbar.make(registerBtn,"注册失败:", Snackbar.LENGTH_LONG).show(); Snackbar.make(registerBtn,"注册失败:", Snackbar.LENGTH_LONG).show();
progress.dismiss(); progress.dismiss();
} }

View File

@ -49,9 +49,6 @@ import cn.bmob.v3.datatype.BmobFile;
import cn.bmob.v3.listener.UpdateListener; import cn.bmob.v3.listener.UpdateListener;
import cn.bmob.v3.listener.UploadFileListener; import cn.bmob.v3.listener.UploadFileListener;
/**
* Created by htq on 2016/9/4.
*/
public class UserInfoActivity extends AppCompatActivity { public class UserInfoActivity extends AppCompatActivity {
@ -218,7 +215,6 @@ public class UserInfoActivity extends AppCompatActivity {
@Override @Override
public void onClick(View arg0) { public void onClick(View arg0) {
// TODO Auto-generated method stub
layout_choose.setBackgroundColor(getResources().getColor( layout_choose.setBackgroundColor(getResources().getColor(
R.color.base_color_text_white)); R.color.base_color_text_white));
layout_photo.setBackgroundDrawable(getResources().getDrawable( layout_photo.setBackgroundDrawable(getResources().getDrawable(
@ -243,7 +239,6 @@ public class UserInfoActivity extends AppCompatActivity {
@Override @Override
public void onClick(View arg0) { public void onClick(View arg0) {
// TODO Auto-generated method stub
// ShowLog("点击相册"); // ShowLog("点击相册");
layout_photo.setBackgroundColor(getResources().getColor( layout_photo.setBackgroundColor(getResources().getColor(
R.color.base_color_text_white)); R.color.base_color_text_white));
@ -315,7 +310,6 @@ public class UserInfoActivity extends AppCompatActivity {
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) { switch (requestCode) {
case BmobConstants.REQUESTCODE_UPLOADAVATAR_CAMERA:// 拍照修改头像 case BmobConstants.REQUESTCODE_UPLOADAVATAR_CAMERA:// 拍照修改头像
@ -358,7 +352,6 @@ public class UserInfoActivity extends AppCompatActivity {
break; break;
case BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP:// 裁剪头像返回 case BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP:// 裁剪头像返回
// TODO sent to crop
if (avatorPop != null) { if (avatorPop != null) {
avatorPop.dismiss(); avatorPop.dismiss();
} }
@ -391,7 +384,6 @@ public class UserInfoActivity extends AppCompatActivity {
@Override @Override
public void onSuccess() { public void onSuccess() {
// TODO Auto-generated method stub
String url = bmobFile.getFileUrl(UserInfoActivity.this); String url = bmobFile.getFileUrl(UserInfoActivity.this);
updateUserAvatar(url); updateUserAvatar(url);
AccountUtils.saveUserHeadUrl(UserInfoActivity.this,url); AccountUtils.saveUserHeadUrl(UserInfoActivity.this,url);
@ -400,14 +392,12 @@ public class UserInfoActivity extends AppCompatActivity {
@Override @Override
public void onProgress(Integer arg0) { public void onProgress(Integer arg0) {
// TODO Auto-generated method stub
} }
@Override @Override
public void onFailure(int arg0, String msg) { public void onFailure(int arg0, String msg) {
// TODO Auto-generated method stub
Snackbar.make(exitBtn,"头像上传失败:" + msg+ String.valueOf(arg0), Snackbar.LENGTH_LONG).show(); Snackbar.make(exitBtn,"头像上传失败:" + msg+ String.valueOf(arg0), Snackbar.LENGTH_LONG).show();
// ShowToast("头像上传失败:" + msg+String.valueOf(arg0)); // ShowToast("头像上传失败:" + msg+String.valueOf(arg0));
} }
@ -420,7 +410,6 @@ public class UserInfoActivity extends AppCompatActivity {
updateUserData(u,new UpdateListener() { updateUserData(u,new UpdateListener() {
@Override @Override
public void onSuccess() { public void onSuccess() {
// TODO Auto-generated method stub
Snackbar.make(exitBtn,"头像更新成功!", Snackbar.LENGTH_SHORT).show(); Snackbar.make(exitBtn,"头像更新成功!", Snackbar.LENGTH_SHORT).show();
//ShowToast(); //ShowToast();
// 更新头像 // 更新头像
@ -429,7 +418,6 @@ public class UserInfoActivity extends AppCompatActivity {
@Override @Override
public void onFailure(int code, String msg) { public void onFailure(int code, String msg) {
// TODO Auto-generated method stub
Snackbar.make(exitBtn,"头像更新失败:" + msg+ String.valueOf(code), Snackbar.LENGTH_SHORT).show(); Snackbar.make(exitBtn,"头像更新失败:" + msg+ String.valueOf(code), Snackbar.LENGTH_SHORT).show();
//ShowToast(); //ShowToast();
} }

View File

@ -20,36 +20,23 @@ import java.io.IOException;
public class PhotoUtil { public class PhotoUtil {
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> recycle
*
* @throws
*/
public static void recycle(Bitmap bitmap) { public static void recycle(Bitmap bitmap) {
// <EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (bitmap != null && !bitmap.isRecycled()) { if (bitmap != null && !bitmap.isRecycled()) {
// <EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull
bitmap.recycle(); bitmap.recycle();
bitmap = null; bitmap = null;
} }
System.gc(); System.gc();
} }
/**
* <EFBFBD><EFBFBD>ȡָ<EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ͼƬ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ getImageThumbnail
*
* @return Bitmap
* @throws
*/
public static Bitmap getImageThumbnail(String imagePath, int width, public static Bitmap getImageThumbnail(String imagePath, int width,
int height) { int height) {
Bitmap bitmap = null; Bitmap bitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true; options.inJustDecodeBounds = true;
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>Ŀ<EFBFBD>͸ߣ<EFBFBD>ע<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>bitmapΪnull
bitmap = BitmapFactory.decodeFile(imagePath, options); bitmap = BitmapFactory.decodeFile(imagePath, options);
options.inJustDecodeBounds = false; // <EFBFBD><EFBFBD>Ϊ false options.inJustDecodeBounds = false;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
int h = options.outHeight; int h = options.outHeight;
int w = options.outWidth; int w = options.outWidth;
int beWidth = w / width; int beWidth = w / width;
@ -64,9 +51,7 @@ public class PhotoUtil {
be = 1; be = 1;
} }
options.inSampleSize = be; options.inSampleSize = be;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><EFBFBD>bitmap<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>options.inJustDecodeBounds <EFBFBD><EFBFBD>Ϊ false
bitmap = BitmapFactory.decodeFile(imagePath, options); bitmap = BitmapFactory.decodeFile(imagePath, options);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ThumbnailUtils<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>Bitmap<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height, bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
ThumbnailUtils.OPTIONS_RECYCLE_INPUT); ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
return bitmap; return bitmap;
@ -75,9 +60,9 @@ public class PhotoUtil {
/** /**
* saveBitmap * saveBitmap
* *
* @param @param filename---<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ-<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>Լ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> * @param @param filename
* @param @param bitmap * @param @param bitmap
* @param @param isDelete --<EFBFBD>Ƿ<EFBFBD>ֻ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> * @param @param isDelete
* @return void * @return void
* @throws * @throws
*/ */
@ -89,7 +74,6 @@ public class PhotoUtil {
} }
File file = new File(dirpath, filename); File file = new File(dirpath, filename);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>ɾ<EFBFBD><EFBFBD>-Ĭ<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
if (isDelete) { if (isDelete) {
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
@ -100,7 +84,6 @@ public class PhotoUtil {
try { try {
file.createNewFile(); file.createNewFile();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -135,7 +118,6 @@ public class PhotoUtil {
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return file; return file;
@ -153,12 +135,6 @@ public class PhotoUtil {
} }
} }
/**
*
* <EFBFBD><EFBFBD>ȡͼƬ<EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ĽǶ<EFBFBD>
* @param path ͼƬ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
* @return degree<EFBFBD><EFBFBD>ת<EFBFBD>ĽǶ<EFBFBD>
*/
public static int readPictureDegree(String path) { public static int readPictureDegree(String path) {
int degree = 0; int degree = 0;
@ -185,30 +161,16 @@ public class PhotoUtil {
} }
/** <EFBFBD><EFBFBD>תͼƬһ<EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>
* rotaingImageView
* @return Bitmap
* @throws
*/
public static Bitmap rotaingImageView(int angle, Bitmap bitmap) { public static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
// <EFBFBD><EFBFBD>תͼƬ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Matrix matrix = new Matrix(); Matrix matrix = new Matrix();
matrix.postRotate(angle); matrix.postRotate(angle);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ͼƬ
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), matrix, true); bitmap.getWidth(), bitmap.getHeight(), matrix, true);
return resizedBitmap; return resizedBitmap;
} }
/**
* <EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD>ΪԲ<EFBFBD><EFBFBD>
*
* @param bitmap
* ԭBitmapͼƬ
* @param pixels
* ͼƬԲ<EFBFBD>ǵĻ<EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>λ:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(px))
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ǵ<EFBFBD>ͼƬ(Bitmap <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
*/
public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) { public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888); bitmap.getHeight(), Config.ARGB_8888);
@ -231,12 +193,7 @@ public class PhotoUtil {
return output; return output;
} }
/**
* <EFBFBD><EFBFBD>ͼƬת<EFBFBD><EFBFBD>ΪԲ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
*
* @Title: toRoundBitmap
* @throws
*/
public static Bitmap toRoundBitmap(Bitmap bitmap) { public static Bitmap toRoundBitmap(Bitmap bitmap) {
int width = bitmap.getWidth(); int width = bitmap.getWidth();
int height = bitmap.getHeight(); int height = bitmap.getHeight();
@ -283,16 +240,14 @@ public class PhotoUtil {
(int) dst_right, (int) dst_bottom); (int) dst_right, (int) dst_bottom);
final RectF rectF = new RectF(dst); final RectF rectF = new RectF(dst);
paint.setAntiAlias(true);// <EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޾<EFBFBD><EFBFBD> paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Canvas canvas.drawARGB(0, 0, 0, 0);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ,drawRounRect<EFBFBD><EFBFBD>drawCircle canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);// <EFBFBD><EFBFBD>Բ<EFBFBD>Ǿ<EFBFBD><EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>򣬵ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>ˮƽԲ<EFBFBD>ǰ뾶<EFBFBD>ʹ<EFBFBD>ֱԲ<EFBFBD>ǰ뾶<EFBFBD><EFBFBD>
// canvas.drawCircle(roundPx, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>ཻʱ<EFBFBD><EFBFBD>ģʽ,<EFBFBD>ο<EFBFBD>http://trylovecatch.iteye.com/blog/1189452 paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, src, dst, paint); // <EFBFBD><EFBFBD>Mode.SRC_INģʽ<EFBFBD>ϲ<EFBFBD>bitmap<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>draw<EFBFBD>˵<EFBFBD>Circle canvas.drawBitmap(bitmap, src, dst, paint);
return output; return output;
} }

View File

@ -22,9 +22,7 @@ import java.io.InputStream;
import static android.content.Context.MODE_PRIVATE; import static android.content.Context.MODE_PRIVATE;
/**
* Created by htq on 2016/8/10.
*/
public class SystemUtils { public class SystemUtils {
private Context context; private Context context;
@ -151,7 +149,6 @@ public boolean isTarn()
fileOutputStream = mActivity.openFileOutput( fileOutputStream = mActivity.openFileOutput(
"share.jpg", MODE_PRIVATE); "share.jpg", MODE_PRIVATE);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -178,7 +175,7 @@ public boolean isTarn()
// fileOutputStream = mActivity.openFileOutput( // fileOutputStream = mActivity.openFileOutput(
// "share.jpg", 1); // "share.jpg", 1);
// } catch (FileNotFoundException e) { // } catch (FileNotFoundException e) {
// // TODO Auto-generated catch block //
// e.printStackTrace(); // e.printStackTrace();
// } // }
// //

View File

@ -26,7 +26,6 @@ public class ActAutoUpdate extends BaseActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);

View File

@ -1,3 +1,4 @@
package cn.bmob.sdkdemo.push; package cn.bmob.sdkdemo.push;
import android.os.Bundle; import android.os.Bundle;