本文介绍了如何自定义Java注解处理器及涉及到的相关知识,看完本文可以很轻松看懂并理解各大开源框架的注解处理器的应用。

要点概述:1.keystore有两种格式,即keystore和jks,keystore为旧版本中使用的,jks为AS版本专用。2.创建key的两种方式,AS方式、命令行方式3.配置Gradle签署APK4.获取sha1

自定义波浪动画

今天讲讲以前项目的一个动画,先看看效果,实际是连贯的,gif会卡一下

图片 12017-08-18-20-38-38.gif


图片 22017-08-19-12-02-52.gifgithub
地址

原理:正弦曲线y=asin(bα+c)+m;

a:控制振幅 b:控制波长 c:控制轴偏移 m:控制y轴偏移 α:角度

思路:画出波的path,通过动画控制振幅a达到水波的起伏效果控制c的值达到移动效果

 <com.example.ck.waveanimation.WaveView android: android:background="#999" android:layout_width="match_parent" android:layout_height="match_parent" /> //监听硬币偏移量 WaveView waveView=  findViewById(R.id.waveline); waveView.setWaveHeightListener(new WaveView.WaveHeightListener() { @Override public void currentWaveHeightMove(float currentWavePercent) { Log.i("WaveView", "currentWaveHeightScal: "+currentWavePercent); } });

在非EXACTLY模式下,默认一个高度 if (heightMeasureMode == MeasureSpec.AT_MOST || heightMeasureMode == MeasureSpec.UNSPECIFIED) { heightMeaure = dp2px(DEFAULT_HEIGHT); heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightMeaure, MeasureSpec.EXACTLY); }

在onSizeChanged获取一些初始值 protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); viewHeight = h; viewWidth = w; viewCenterY = 2 * viewHeight / 3; waveAmplifier = (waveAmplifier * 2 > viewHeight) ? (viewHeight / 2) : waveAmplifier; waveAnim(); }

各个波的path路径绘制出来 path1.reset(); path2.reset(); path3.reset(); path1.moveTo(0, viewCenterY - waveAmplifier * getRoundRate(wavePhase, waveFrequency, -1)); path2.moveTo(0, viewCenterY - 1.3f * waveAmplifier2 * getRoundRate(wavePhase + 90, waveFrequency, -1)); path3.moveTo(0, viewCenterY + waveAmplifier2 * getRoundRate(wavePhase, waveFrequency, -1)); for (int i = 0; i < viewWidth - 1; i++) { path1.lineTo , viewCenterY - waveAmplifier * getRoundRate(wavePhase, waveFrequency, ; path2.lineTo , viewCenterY - 1.3f * waveAmplifier2 * getRoundRate(wavePhase + 90, 0.8f * waveFrequency, ; path3.lineTo , viewCenterY + waveAmplifier2 * getRoundRate(wavePhase, waveFrequency, -1)); } path1.lineTo(viewWidth, viewHeight + 5); path2.lineTo(viewWidth, viewHeight); path3.lineTo(viewWidth, viewHeight); path1.lineTo(0, viewHeight + 5); path2.lineTo(0, viewHeight); path3.lineTo(0, viewHeight); path1.close(); path2.close(); path3.close();

draw path以及硬币wavePaint.setColor(0xc0ffffff); canvas.drawPath(path1, wavePaint); wavePaint.setColor(0xB0ffffff); canvas.drawPath(path2, wavePaint); wavePaint.setColor(0xffffffff); canvas.drawBitmap(bitmap, viewWidth / 2 - bitmap.getWidth() / 2, viewCenterY - 1.3f * waveAmplifier * getRoundRate(wavePhase + 90, waveFrequency * 0.8f, (viewWidth / 2 + 1)) - bitmap.getHeight() + 20, wavePaint); wavePaint.setColor(0x80ffffff); canvas.drawPath(path3, wavePaint);

动画的控制 public void waveAnim() { set = new AnimatorSet(); //控制平移 ValueAnimator valueAnimator = ValueAnimator.ofFloat; valueAnimator.setDuration; valueAnimator.setRepeatMode(ValueAnimator.RESTART); valueAnimator.setRepeatCount(ValueAnimator.INFINITE); valueAnimator.setInterpolator(new LinearInterpolator; valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Float aFloat = Float.valueOf(animation.getAnimatedValue().toString; wavePhase = 360.F * aFloat; if (waveHeightListener != null) { waveHeightListener.currentWaveHeightMove(1.3f * waveAmplifier * getRoundRate(wavePhase + 90, waveFrequency * 0.8f, (viewWidth / 2 + 1))); } invalidate; //控制振幅 ValueAnimator valueAnimator2 = ValueAnimator.ofFloat; valueAnimator2.setDuration; valueAnimator2.setRepeatMode(ValueAnimator.REVERSE); valueAnimator2.setRepeatCount(ValueAnimator.INFINITE); valueAnimator2.setInterpolator(new LinearInterpolator; valueAnimator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Float aFloat = Float.valueOf(animation.getAnimatedValue().toString; waveAmplifier = 10f + 10 * aFloat; waveAmplifier2 = 20f + 10 * (1f - aFloat); } }); set.playTogether(valueAnimator, valueAnimator2); set.start(); }

《游园不值》应怜屐齿印苍苔 ,小扣柴扉久不开 。春色满园关不住
,一枝红杏出墙来 。-宋,叶绍翁

官方教程SHA1参考链接

本文首发:

1.点击Build–>Generate Signed APK

图片 3进入Generate
Signed APK

关于自定义Java注解请查看自定义注解。

2.一路Next后,进入Generate Signed APK界面,点击Create New…

图片 4Generate
Signed APK界面

本文已授权微信公众号:鸿洋(hongyangAndroid)原创首发。

3.进入New Key Store界面,点击右上角的…

图片 5创建新的keystore

1.指定一个jks文件。2.设置文件读取的密码。3.设置别名,⚠️会在项目中使用。4.设置key的密码,⚠️会在项目中使用。5.设置有效期,默认25年。6.填写基本信息,如姓名、公司、所在城市等,⚠️至少填写一项。

发表评论

电子邮件地址不会被公开。 必填项已用*标注