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
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
String path = ((BgPicEntity) mBgPicAdapter.getItem(position)).path;
systemUtils = new SystemUtils(getActivity());

View File

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

View File

@ -20,36 +20,23 @@ import java.io.IOException;
public class PhotoUtil {
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> recycle
*
* @throws
*/
public static void recycle(Bitmap bitmap) {
// <EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (bitmap != null && !bitmap.isRecycled()) {
// <EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull
bitmap.recycle();
bitmap = null;
}
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,
int height) {
Bitmap bitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>Ŀ<EFBFBD>͸ߣ<EFBFBD>ע<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>bitmapΪnull
bitmap = BitmapFactory.decodeFile(imagePath, options);
options.inJustDecodeBounds = false; // <EFBFBD><EFBFBD>Ϊ false
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
options.inJustDecodeBounds = false;
int h = options.outHeight;
int w = options.outWidth;
int beWidth = w / width;
@ -64,9 +51,7 @@ public class PhotoUtil {
be = 1;
}
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);
// <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,
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
return bitmap;
@ -75,9 +60,9 @@ public class PhotoUtil {
/**
* 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 isDelete --<EFBFBD>Ƿ<EFBFBD>ֻ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
* @param @param isDelete
* @return void
* @throws
*/
@ -89,7 +74,6 @@ public class PhotoUtil {
}
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 (file.exists()) {
file.delete();
@ -100,7 +84,6 @@ public class PhotoUtil {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@ -135,7 +118,6 @@ public class PhotoUtil {
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
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) {
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) {
// <EFBFBD><EFBFBD>תͼƬ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Matrix matrix = new Matrix();
matrix.postRotate(angle);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ͼƬ
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
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) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
@ -231,12 +193,7 @@ public class PhotoUtil {
return output;
}
/**
* <EFBFBD><EFBFBD>ͼƬת<EFBFBD><EFBFBD>ΪԲ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
*
* @Title: toRoundBitmap
* @throws
*/
public static Bitmap toRoundBitmap(Bitmap bitmap) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
@ -283,16 +240,14 @@ public class PhotoUtil {
(int) dst_right, (int) dst_bottom);
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);// <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);
canvas.drawRoundRect(rectF, 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
canvas.drawBitmap(bitmap, src, dst, paint); // <EFBFBD><EFBFBD>Mode.SRC_INģʽ<EFBFBD>ϲ<EFBFBD>bitmap<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>draw<EFBFBD>˵<EFBFBD>Circle
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, src, dst, paint);
return output;
}

View File

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

View File

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

View File

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