今天是2015-07-22,学校制定的时间开始于07.18
2015-07-18
我们组我担任组长,所以小组内的事情基本由我来分配
今天我带领大家制定了项目计划(运动类app),制定了计划随后的分配任务就好办了
2015-07-19
今天昨天的努力分案分配完成
我担任的任务为主界面的设计,我的计划为侧滑菜单,主界面的右上方案为地图,采用3D翻转实行
在此处我了解过DrawerLayout,SlideMenu,以及QQ5.0的侧滑
开始采用了DrawerLayout,但是出现的问题是加载图片的时候出现了卡顿,于是我在左侧菜单由ListView换成了多个布局
我以为是ListView加载数据源的问题导致其左侧菜单加载速度慢,于是我换成了布局,可是还是不理想
2015-07-20
经过昨天的奋战我想了一晚上,可能是这个DrawerLayout本身的问题,于是我换成了SlideMenu,效果吧,有一定的提升不过不明显,在此处说明一下,图片我在阿里巴巴矢量图库下载的,下载的时候没有选择图片的分辨率,我在图片的布局时候调整的大小,左侧菜单到此为止,于是现在的问题是我不知道如何得到左侧菜单的点击事件
晚上,一个来自深圳的朋友帮我远程解决了这个问题,然后他成了我的师傅,经研究:
2015-07-21
如何在左侧菜单栏加入圆形头像,我试过ImageView加shape,在布局中加shape,结果都无济于事,经过在群里的询问,群里的大牛们给了我很多解决方案,
解决方法都是使用的开源库:小编在此整理了一篇博文:http://www.cnblogs.com/boy1025/p/4663672.html
今天下午给女票顺便也做了个网站:http://monsterlin.github.io/Lover_Time/,使用的github-page,关于使用方法,小编写了一篇博文:
2015-07-22
今天我知道了我侧滑卡顿的原因在哪里了?原因在于图片分辨率的问题:在阿里巴巴矢量图标库默认下载的为1024*1024.。。。我怎么这么傻,下载的时候居然没有调整分辨率,进而导致图片的加载速度慢- -,于是我替换了图片,替换为30*30,Ok,问题解决了;现在最大的问题是:组内成员的程序是继承的Activity,而我的主界面的切换为Fragment的切换,我该如何办?- -##
2017-07-23
今天复习了一遍读取手机内部图片和压缩,eg:看代码
Intent intent=new Intent(Intent.ACTION_PICK); intent.setType("image/*"); //设置数据类型 startActivityForResult(intent, PICK_CODE);
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if(requestCode==PICK_CODE){ if(intent!=null){ Uri uri=intent.getData(); Cursor cursor= getContentResolver().query(uri, null, null, null, null); cursor.moveToFirst(); //将游标移到First int idx=cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); mCurrentPhotoStr=cursor.getString(idx); //得到图片的路径 cursor.close(); //游标关闭 residePhoto(); //压缩照片 img_user_photo.setImageBitmap(mPhotoImg); } } super.onActivityResult(requestCode, resultCode, intent); } /** * 此方法用于压缩图片 */ private void residePhoto() { BitmapFactory.Options options=new BitmapFactory.Options(); //如果设置为true,解码器将返回null(没有位图),但出…领域仍将设置,允许调用者查询位图不用其像素分配内存。 options.inJustDecodeBounds=true; BitmapFactory.decodeFile(mCurrentPhotoStr,options); //将解码文件转换成位图 double radio=Math.max(options.outWidth * 1.0d/1024f,options.outHeight *1.0d/1024f); //如果设置的值大于1,要求解码器子样的原始图像,返回一个较小的图像保存记忆。 -->>来自官网帮助文档的解析 options.inSampleSize= (int) Math.ceil(radio); options.inJustDecodeBounds=false; mPhotoImg=BitmapFactory.decodeFile(mCurrentPhotoStr,options); //压缩过后的位图 }
2015-07-24
今天我学会了使用Bmob进行图文的上传:(附:bmob基本操作-->(http://www.cnblogs.com/boy1025/p/4395801.html))
final BmobFile file=new BmobFile(new File(mCurrentPhotoStr));//将图片路径转为BmobFile final WalkerUser walkerUser=new WalkerUser(); file.uploadblock(this, new UploadFileListener() { @Override public void onSuccess() { //上传成功 //Log.e("TAG", "上传文件成功"); walkerUser.setUsername(userName); walkerUser.setPassword(pass); walkerUser.setEmail(email); walkerUser.setMotto(motto); walkerUser.setCity(city); walkerUser.setUserHeight(height); walkerUser.setUserWeight(weight); walkerUser.setStepLength(stepLength); walkerUser.setUserFeatherSport(userFeatherSport); walkerUser.setUserPhoto(file); walkerUser.signUp(Regist.this, new SaveListener() { @Override public void onSuccess() { //数据上传成功 //Log.e("--->", "数据上传成功"); Toast.makeText(Regist.this, "欢迎加入Walker的大家庭",Toast.LENGTH_SHORT).show(); } @Override public void onFailure(int i, String s) { //数据上传失败 //Log.e("--->", "数据上传失败"+s); Toast.makeText(Regist.this, "注册失败",Toast.LENGTH_SHORT).show(); } }); }
2015-07-25~07-26
【安卓中的数据传值】
Activity到Fragment之间的数据传值:
Activitity:
Fragment inform=new ShowInform();//创建Fragment Bundle bundle=new Bundle(); bundle.putSerializable("Info", walkerUser); bundle.putString("imageURL", url); inform.setArguments(bundle); FragmentManager fm_inform=getFragmentManager();//得到Fragment的管理 fm_inform.beginTransaction().replace(R.id.content_frame, inform).commit();//提交事务
Fragment:
final WalkerUser walkerUser=(WalkerUser) getArguments().getSerializable("Info"); String imageURL=getArguments().getString("imageURL");
Fragment到Activity之间的数据传值:
Fragment:
Intent intent=new Intent(context,UpdateInform.class); Bundle bundle=new Bundle(); bundle.putSerializable("userInfo", walkerUser); intent.putExtras(bundle); startActivity(intent);
Activity:
WalkerUser walkerUser=(WalkerUser) getIntent().getExtras().getSerializable("userInfo");
ps:在我这里的传值由于我传的为一个对象,所以其实体类应该为实现Serializable接口:
public class WalkerUser extends BmobUser implements Serializable
【ImageLoader工具类实现图片的异步加载】
package cn.edu.bzu.util; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import android.annotation.SuppressLint; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Handler; import android.os.Message; import android.widget.ImageView; /** * 图片加载工具类 * @author monster * @date 2015-07-26 * 使用多线程的方式进行数据的加载 */ @SuppressLint("HandlerLeak") public class ImageLoader { private ImageView mImageView; private String mUrl; private Handler mHandler=new Handler(){ public void handleMessage(Message msg) { if(mImageView.getTag().equals(mUrl)){ mImageView.setImageBitmap((Bitmap) msg.obj); } }; }; /** * 通过Thread的方式进行图片的加载 * @param imageView * @param url */ public void showImageByThread(ImageView imageView,final String url){ mImageView=imageView; mUrl=url; new Thread() { @Override public void run() { super.run(); Bitmap bitmap=getBitmapFromURL(url); Message message=Message.obtain(); message.obj=bitmap; mHandler.sendMessage(message); } }.start(); } /** * * @param urlString * @return bitmap */ public Bitmap getBitmapFromURL(String urlString) { Bitmap bitmap; InputStream is = null; try { URL url=new URL(urlString); HttpURLConnection connection=(HttpURLConnection) url.openConnection(); is=new BufferedInputStream(connection.getInputStream()); bitmap=BitmapFactory.decodeStream(is); connection.disconnect(); //关闭连接 return bitmap; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ try { is.close(); } catch (IOException e) { e.printStackTrace(); } } return null; } }
2015-07-27
今天,队友在看好声音的时候找到了数据及时刷新的解决方案了,当时我们开心死了,so happy
下面进入正题,由于我们的登陆和编辑资料的时候都是在Fragment中进行的操作,所以说首先登陆成功在数据库读取信息的方法我们书写成了public,然后也把更新资料的方法写成了public,然后我们拿更新资料来说,更新资料结束后需要返回之前的显示个人信息的界面,如果直接销毁掉编辑信息的界面的地方肯定不可取,于是我们在更新资料结束的时候,直接通过公共的方法读取一遍资料,这个过程通过onActivityForResult执行的,打开个页面和关闭页面,得到请求码相同的时候直接在调用获取数据的方法直接在获取了一遍数据,于是我们及时刷新就实现了,在这里我们通过
通过这个方法于是就重新了加载个一遍数据,从而实现了及时刷新
2015-07-28
在图片的圆形图片显示中,之前我们直接在xml中书写开源框架的代码,然后显示的图片只有从QQ上保存下来的头像才会正确显示图片,但是对于自己的图片肯定不行,所以,小编今天偶尔发现这样一段代码,能够完全的把你的图片切成圆形的,小编亲测可用:
/** * 转换图片成圆形 * @param bitmap 传入Bitmap对象 * @return */ public Bitmap toRoundBitmap(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); float roundPx; float left,top,right,bottom,dst_left,dst_top,dst_right,dst_bottom; if (width <= height) { roundPx = width / 2; top = 0; bottom = width; left = 0; right = width; height = width; dst_left = 0; dst_top = 0; dst_right = width; dst_bottom = width; } else { roundPx = height / 2; float clip = (width - height) / 2; left = clip; right = width - clip; top = 0; bottom = height; width = height; dst_left = 0; dst_top = 0; dst_right = height; dst_bottom = height; } Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect src = new Rect((int)left, (int)top, (int)right, (int)bottom); final Rect dst = new Rect((int)dst_left, (int)dst_top, (int)dst_right, (int)dst_bottom); final RectF rectF = new RectF(dst); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, src, dst, paint); return output; }