自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(2)
  • 资源 (2)
  • 收藏
  • 关注

原创 Android 使用DigestUtils 工具加密报错的解决方法

由于工作遇到,解决后只是简单记录一下(小白一枚),大佬勿喷首先肯定是的导入第三方包 commons-codec-1.15.jar, (我用的1.15) 否则androidDigestUtils.md5或者其他的是点不出来的。如下图:当你导好包写好一切,运行时会发现报错,如下图:原因大致是因为Androidframework 层里面有相同包名,导致冲突没办法,想继续用的话只能上网找办法,一顿猛如虎操作,总算解决了,下面是解决方法因为是包名冲突,那我们就修改包名首先下个ja...

2021-06-25 15:54:46 801

转载 关于eclipse adt更新的问题

今早刚一开机,打开eclipse ,提示什么adt版本过低,提示我更新,但我不想更新,打算原来的版本,在这里写下方法,便于以后使用windows 下面安装Android虚拟机,有时候选择更新SDK后,在Eclipse preference里指向android_sdk_windows_x86时。会出现诸如This AndroidSDK requires  Android Develope

2015-01-12 10:36:22 758

jarjar包和commons-codec修改后的包.zip

android项目使用DigestUtils 报错解决方法,详情可看https://mp.csdn.net/mp_blog/creation/editor/118181327

2021-06-24

android折线图

package com.yzxy.draw; 002 003 import java.util.ArrayList; 004 import java.util.HashMap; 005 import java.util.Iterator; 006 import java.util.Map; 007 import java.util.Set; 008 009 import android.annotation.SuppressLint; 010 import android.content.Context; 011 import android.graphics.Canvas; 012 import android.graphics.Color; 013 import android.graphics.Paint; 014 import android.graphics.Path; 015 import android.graphics.Point; 016 import android.graphics.RectF; 017 import android.graphics.Paint.Style; 018 import android.graphics.Typeface; 019 import android.util.AttributeSet; 020 import android.view.MotionEvent; 021 import android.view.View; 022 023 /** 024 * 025 * @author zhangyayun1@gmail.com 026 * 027 */ 028 @SuppressLint("ViewConstructor") 029 class MyChartView extends View{ 030 031 public static final int RECT_SIZE = 10; 032 private Point mSelectedPoint; 033 034 //枚举实现坐标桌面的样式风格 035 public static enum Mstyle 036 { 037 Line,Curve 038 } 039 040 private Mstyle mstyle=Mstyle.Line; 041 private Point[] mPoints = new Point[100]; 042 043 Context context; 044 int bheight=0; 045 HashMap<Double, Double> map; 046 ArrayList<Double> dlk; 047 int totalvalue=30; 048 int pjvalue=5; 049 String xstr,ystr="";//横纵坐标的属性 050 int margint=15; 051 int marginb=40; 052 int c=0; 053 int resid=0; 054 Boolean isylineshow; 055 056 /** 057 * @param map 需要的数据,虽然key是double,但是只用于排序和显示,与横向距离无关 058 * @param totalvalue Y轴的最大值 059 * @param pjvalue Y平均值 060 * @param xstr X轴的单位 061 * @param ystr Y轴的单位 062 * @param isylineshow 是否显示纵向网格 063 * @return 064 */ 065 public void SetTuView(HashMap<Double, Double> map,int totalvalue,int pjvalue,String xstr,String ystr,Boolean isylineshow) 066 { 067 this.map=map; 068 this.totalvalue=totalvalue; 069 this.pjvalue=pjvalue; 070 this.xstr=xstr; 071 this.ystr=ystr; 072 this.isylineshow=isylineshow; 073 //屏幕横向 074 // act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 075 } 076 077 public MyChartView(Context ct) 078 { 079 super(ct); 080 this.context=ct; 081 } 082 083 public MyChartView(Context ct, AttributeSet attrs) 084 { 085 super( ct, attrs ); 086 this.context=ct; 087 } 088 089 public MyChartView(Context ct, AttributeSet attrs, int defStyle) 090 { 091 super( ct, attrs, defStyle ); 092 this.context=ct; 093 } 094 095 @SuppressLint("DrawAllocation") 096 @Override 097 protected void onDraw(Canvas canvas) { 098 super.onDraw(canvas); 099 if(c!=0) 100 this.setbg(c); 101 if(resid!=0) 102 this.setBackgroundResource(resid); 103 dlk=getintfrommap(map); 104 int height=getHeight(); 105 if(bheight==0) 106 bheight=height-marginb; 107 108 int width=getWidth(); 109 int blwidh=dip2px(context,50); 110 int pjsize=totalvalue/pjvalue;//界面布局的尺寸的比例 111 // set up paint 112 Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 113 paint.setColor(Color.GRAY); 114 paint.setStrokeWidth(1); 115 paint.setStyle(Style.STROKE); 116 for(int i=0;i<pjsize+1;i++)//将顶点的线变为红色的 警戒线 117 { 118 if(i==pjsize) 119 paint.setColor(Color.RED); 120 canvas.drawLine(blwidh,bheight-(bheight/pjsize)*i+margint,width,bheight-(bheight/pjsize)*i+margint, paint);//Y坐标 121 drawline(pjvalue*i+ystr, blwidh/2, bheight-(bheight/pjsize)*i+margint, canvas); 122 } 123 ArrayList<Integer> xlist=new ArrayList<Integer>();//记录每个x的值 124 //画直线(纵向) 125 paint.setColor(Color.GRAY); 126 if(dlk==null) 127 return; 128 for(int i=0;i<dlk.size();i++) 129 { 130 xlist.add(blwidh+(width-blwidh)/dlk.size()*i); 131 if(isylineshow) 132 { 133 canvas.drawLine(blwidh+(width-blwidh)/dlk.size()*i,margint,blwidh+(width-blwidh)/dlk.size()*i,bheight+margint, paint); 134 } 135 drawline(dlk.get(i)+xstr, blwidh+(width-blwidh)/dlk.size()*i, bheight+40, canvas);//X坐标 136 } 137 138 //点的操作设置 139 mPoints=getpoints(dlk, map, xlist, totalvalue, bheight); 140 // Point[] ps=getpoints(dlk, map, xlist, totalvalue, bheight); 141 // mPoints=ps; 142 143 paint.setColor(Color.GREEN); 144 paint.setStyle(Style.STROKE); 145 paint.setStrokeWidth(0); 146 147 if(mstyle==Mstyle.Curve) 148 drawscrollline(mPoints, canvas, paint); 149 else 150 drawline(mPoints, canvas, paint); 151 152 paint.setColor(Color.RED); 153 paint.setStyle(Style.FILL); 154 for (int i=0; i<mPoints.length; i++) 155 { 156 canvas.drawRect(pointToRect(mPoints[i]),paint); 157 } 158 } 159 160 @Override 161 public boolean onTouchEvent(MotionEvent event) 162 { 163 switch (event.getAction()) 164 { 165 case MotionEvent.ACTION_DOWN: 166 for (int i=0; i<mPoints.length; i++) 167 { 168 if (pointToRect(mPoints[i]).contains(event.getX(),event.getY())) 169 { 170 System.out.println("-yes-"+i); 171 mSelectedPoint = mPoints[i]; 172 } 173 } 174 break; 175 case MotionEvent.ACTION_MOVE: 176 if ( null != mSelectedPoint) 177 { 178 // mSelectedPoint.x = (int) event.getX(); 179 mSelectedPoint.y = (int) event.getY(); 180 // invalidate(); 181 } 182 break; 183 case MotionEvent.ACTION_UP: 184 mSelectedPoint = null; 185 break; 186 default: 187 break; 188 } 189 return true; 190 191 } 192 193 194 private RectF pointToRect(Point p) 195 { 196 return new RectF(p.x -RECT_SIZE/2, p.y - RECT_SIZE/2,p.x + RECT_SIZE/2, p.y + RECT_SIZE/2); 197 } 198 199 200 private void drawscrollline(Point[] ps,Canvas canvas,Paint paint) 201 { 202 Point startp=new Point(); 203 Point endp=new Point(); 204 for(int i=0;i<ps.length-1;i++) 205 { 206 startp=ps[i]; 207 endp=ps[i+1]; 208 int wt=(startp.x+endp.x)/2; 209 Point p3=new Point(); 210 Point p4=new Point(); 211 p3.y=startp.y; 212 p3.x=wt; 213 p4.y=endp.y; 214 p4.x=wt; 215 216 Path path = new Path(); 217 path.moveTo(startp.x,startp.y); 218 path.cubicTo(p3.x, p3.y, p4.x, p4.y,endp.x, endp.y); 219 canvas.drawPath(path, paint); 220 221 } 222 } 223 224 225 private void drawline(Point[] ps,Canvas canvas,Paint paint) 226 { 227 Point startp=new Point(); 228 Point endp=new Point(); 229 for(int i=0;i<ps.length-1;i++) 230 { 231 startp=ps[i]; 232 endp=ps[i+1]; 233 canvas.drawLine(startp.x,startp.y,endp.x,endp.y, paint); 234 } 235 } 236 237 238 private Point[] getpoints(ArrayList<Double> dlk,HashMap<Double, Double> map,ArrayList<Integer> xlist,int max,int h) 239 { 240 Point[] points=new Point[dlk.size()]; 241 for(int i=0;i<dlk.size();i++) 242 { 243 int ph=h-(int)(h*(map.get(dlk.get(i))/max)); 244 245 points[i]=new Point(xlist.get(i),ph+margint); 246 } 247 return points; 248 } 249 250 251 private void drawline(String text,int x,int y,Canvas canvas) 252 { 253 Paint p = new Paint(); 254 p.setAlpha(0x0000ff); 255 p.setTextSize(20); 256 String familyName = "宋体"; 257 Typeface font = Typeface.create(familyName,Typeface.ITALIC); 258 p.setTypeface(font); 259 p.setTextAlign(Paint.Align.CENTER); 260 canvas.drawText(text, x, y, p); 261 } 262 263 264 public int dip2px(Context context, float dpValue) 265 { 266 final float scale = context.getResources().getDisplayMetrics().density; 267 return (int) (dpValue * scale + 0.5f); 268 } 269 270 271 public int px2dip(Context context, float pxValue) 272 { 273 final float scale = context.getResources().getDisplayMetrics().density; 274 return (int) (pxValue / scale + 0.5f); 275 } 276 277 278 279 @SuppressWarnings("rawtypes") 280 public ArrayList<Double> getintfrommap(HashMap<Double, Double> map) 281 { 282 ArrayList<Double> dlk=new ArrayList<Double>(); 283 int position=0; 284 if(map==null) 285 return null; 286 Set set= map.entrySet(); 287 Iterator iterator = set.iterator(); 288 289 while(iterator.hasNext()) 290 { 291 @SuppressWarnings("rawtypes") 292 Map.Entry mapentry = (Map.Entry)iterator.next(); 293 dlk.add((Double)mapentry.getKey()); 294 } 295 for(int i=0;i<dlk.size();i++) 296 { 297 int j=i+1; 298 position=i; 299 Double temp=dlk.get(i); 300 for(;j<dlk.size();j++) 301 { 302 if(dlk.get(j)<temp) 303 { 304 temp=dlk.get(j); 305 position=j; 306 } 307 } 308 309 dlk.set(position,dlk.get(i)); 310 dlk.set(i,temp); 311 } 312 return dlk; 313 314 } 315 316 317 318 319 public void setbg(int c) 320 { 321 this.setBackgroundColor(c); 322 } 323 324 public HashMap<Double, Double> getMap() { 325 return map; 326 } 327 328 public void setMap(HashMap<Double, Double> map) { 329 this.map = map; 330 } 331 332 public int getTotalvalue() { 333 return totalvalue; 334 } 335 336 public void setTotalvalue(int totalvalue) { 337 this.totalvalue = totalvalue; 338 } 339 340 public int getPjvalue() { 341 return pjvalue; 342 } 343 344 public void setPjvalue(int pjvalue) { 345 this.pjvalue = pjvalue; 346 } 347 348 public String getXstr() { 349 return xstr; 350 } 351 352 public void setXstr(String xstr) { 353 this.xstr = xstr; 354 } 355 356 public String getYstr() { 357 return ystr; 358 } 359 360 public void setYstr(String ystr) { 361 this.ystr = ystr; 362 } 363 364 public int getMargint() { 365 return margint; 366 } 367 368 public void setMargint(int margint) { 369 this.margint = margint; 370 } 371 372 public Boolean getIsylineshow() { 373 return isylineshow; 374 } 375 376 public void setIsylineshow(Boolean isylineshow) { 377 this.isylineshow = isylineshow; 378 } 379 380 public int getMarginb() { 381 return marginb; 382 } 383 384 public void setMarginb(int marginb) { 385 this.marginb = marginb; 386 } 387 388 public Mstyle getMstyle() { 389 return mstyle; 390 } 391 392 public void setMstyle(Mstyle mstyle) { 393 this.mstyle = mstyle; 394 } 395 396 public int getBheight() { 397 return bheight; 398 } 399 400 public void setBheight(int bheight) { 401 this.bheight = bheight; 402 } 403 404 public int getC() { 405 return c; 406 } 407 408 public void setC(int c) { 409 this.c = c; 410 } 411 412 public int getResid() { 413 return resid; 414 } 415 416 public void setResid(int resid) { 417 this.resid = resid; 418 } 419 420 421 422 }

2014-03-12

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除