设为首页 收藏本站
查看: 1343|回复: 0

[经验分享] Android Studio 插件--postfix

[复制链接]

尚未签到

发表于 2015-11-24 11:30:01 | 显示全部楼层 |阅读模式

一、介绍


同志们,是不是都已经从Eclipse转到了Android Studio,没转的同志们,在此给个建议,尽快转到Android Studio吧,能提高工作效率,何乐而不为。已经在用Android Studio开发的,是不是觉得以前Eclipse的sys的快捷输入是多么方便,怎么Android
Studio就不能这么方便的书写呢,不要着急,今天介绍的这个插件,可以让你开发更加轻松,看完你会叫好,会去下载的。






二、使用



下面先睹为快


DSC0000.jpg



DSC0001.jpg







下面开始具体介绍下插件功能:


1.布尔表达式(非)——!(!expr)


使用前:




public class Foo {
void m(boolean b) {
m(b!);
}
}
  



使用后:




public class Foo {
void m(boolean b) {
m(!b);
}
}  
  


  2.创建单元测试的断言assert——assert(assert expr)

使用前:


  

public void m(boolean value) {
value.assert
}
  



使用后:




public void m(boolean value) {
assert value;
}
  

3.包含的表达式——cast((SomeType) expr)


使用前:




public class Foo {
void m(Object o) {
o.cast
}
}
  



使用后:




public class Foo {
void m(Object o) {
(() o)
}
}
  



4.检查Boolean为假——else(if(!expr))


使用前:




public class Foo {
void m(boolean b) {
b.else
}
}
  



使用后:




public class Foo {
void m(boolean b) {
if (!b) {
}
}
}
  



5.生成field——field(myField = expr)


使用前:


public class Foo {
public Foo(int arg) {
arg.field
}
}
  

使用后:




public class Foo {
private int foo;
public Foo(int arg) {
foo = arg;
}
}
  



6.for循环——for(for(T item : expr))



使用前:




public class Foo {
void m() {
int[] values = {1, 2, 3};
values.for
}
}
  



使用后:




public class Foo {
void m() {
int[] values = {1, 2, 3};
for (int value : values) {
}
}
}
  

7.for循环从头开始——fori(for(int i = 0; i < expr.length; i&#43;&#43;))


使用前:




public class Foo {
void m() {
int foo = 100;
foo.fori
}
}
  



使用后:


public class Foo {
void m() {
int foo = 100;
for (int i = 0; i < foo; i++) {
}
}
}
  

8.String的format函数——format(String.format(expr))


使用前:


public void m(String value) {
value.format
}
  



使用后:


public void m(String value) {
String.format(value, );
}
  



9.for循环从最尾开始——forr(for(int i = expr.length-1;i >= 0;i--))


使用前:


public class Foo {
void m() {
int foo = 100;
foo.forr
}
}
  



使用后:


public class Foo {
void m() {
int foo = 100;
for (int i = foo; i > 0; i--) {
}
}
}
  

10.if语句——if(if(expr))


使用前:


public class Foo {
void m(boolean b) {
b.if
}
}
  



使用后:


public class Foo {
void m(boolean b) {
if (b) {
}
}
}
  

11.ins语句——inst(expr
instanceof Type ? ((Type)expr).:null)



使用前:


public class Foo {
void m(Object o) {
o.inst
}
}
  



使用后:


public class Foo {
void m(Object o) {
o instanceof  ? (() o) : null;
}
}
  

12.instanceof语句——inst(expr
instanceof Type ? ((Type)expr).:null)


使用前:


public class Foo {
void m(Object o) {
o.instanceof
}
}
  



使用后:


public class Foo {
void m(Object o) {
o instanceof  ? (() o) : null;
}
}
  


  13.not null语句——nn(if(expr != null))
  使用前:

public class Foo {
void m(Object o) {
o.nn
}
}
  
  
  使用后:

public class Foo {
void m(Object o) {
if (o != null){
}
}
}
  
  

14.布尔表达式(非)——not(!expr)


使用前:


public class Foo {
void m(boolean b) {
m(b.not);
}
}
  



使用后:


public class Foo {
void m(boolean b) {
m(!b);
}
}  
  


  15.not
null语句——
notnull(if(expr != null))

  使用前:

public class Foo {
void m(Object o) {
o.notnull
}
}
  
  
  使用后:

public class Foo {
void m(Object o) {
if (o != null){
}
}
}
  
  
  16.null语句——null(if(expr
== null))

  使用前:

public class Foo {
void m(Object o) {
o.null
}
}

  
  
  使用后:

public class Foo {
void m(Object o) {
if (o == null){
}
}
}
  
  
  17.括号包含——par((expr))
  使用前:

public class Foo {
void m(Object o) {
o.par
}
}
  
  
  使用后:

public class Foo {
void m(Object o) {
(o)
}
}
  
  18.return语句——return(return expr)
  使用前:

public class Foo {
String m() {
&quot;result&quot;.return
}
}
  
  
  使用后:

public class Foo {
String m() {
return &quot;result&quot;;
}
}
  
  
  19.sys语句——sout(System.out.println(expr))
  使用前:

public class Foo {
void m(boolean b) {
b.sout
}
}
  
  
  使用后:

public class Foo {
void m(boolean b) {
System.out.println(b);
}
}
  
  
  20.switch语句——switch(switch(expr))
  使用前:

public enum Foo {
A, B, C;
void f(Foo foo) {
foo.switch
}
}
  
  使用后:

public enum Foo {
A, B, C;
void f(Foo foo) {
switch (foo) {
}
}
}
  
  21.锁定表达式——synchronized(synchronized(expr))
  使用前:

public class Foo {
void m(Object o) {
o.synchronized
}
}
  
  使用后:

public class Foo {
void m(Object o) {
synchronized (o) {
}
}
}
  
  22.异常语句——throw(throw expr)
  使用前:

public class Foo {
void m() {
new RuntimeException(&quot;error&quot;).throw
}
}
  
  使用后:

public class Foo {
void m() {
throw new RuntimeException(&quot;error&quot;);
}
}
  
  23.捕获异常语句——try(try { exp } catch (Exception
e))

  使用前:

public void m2() {
m().try
}
public void m() throws CheckedException { }
  
  使用后:

public void m2() {
try {
m();
} catch(CheckedException e) {
e.printStackTrace();
}
}
public void m() throws CheckedException { }
  
  24.捕获异常语句——twr(try(Type f = new Type()) catch
(Exception e))

  使用前:

public class Foo {
void m() {
getStream().twr
}
AutoCloseable getStream()
{
return null;
}
}
  
  使用后:

public class Foo {
void m() {
try (AutoCloseable stream = getStream()) {
} catch (Exception e) {
}
}
AutoCloseable getStream()
{
return null;
}
}
  
  25.引入变量表达式——var(T name = expr)
  使用前:

public class Foo {
void m(Object o) {
o instanceof String.var
}
}
  
  使用后:

public class Foo {
void m(Object o) {
boolean foo = o instanceof String;
}
}
  
  26.while表达式——while(while(expr))
  使用前:

public class Foo {
void m(boolean x) {
x.while
return;
}
}
  
  使用后:

public class Foo {
void m(boolean x) {
while (x)
return;
}
}
  
  27.判空表达式——isemp(TextUtils.isEmpty(expr))
  使用前:

public class Foo {
void m(Object o) {
o.isemp
}
}
  
  使用后:

import com.google.common.base.Preconditions;
public class Foo {
void m(Object o) {
TextUtils.isEmpty(&quot;test&quot;)
}
}
  
  28.log输出表达式——log(Log.d(TAG,expr);)
  使用前:

public class Foo {
void m(Object o) {
o.log
}
}
  
  使用后:

import com.google.common.base.Preconditions;
public class Foo {
void m(Object o) {
Log.d(TAG, o);
}
}
  
  29.debug模式的log输出表达式——logd(if(BuildConfig.DEBUG)
Log.d(TAG,expr);)

  使用前:

public class Foo {
void m(Object o) {
o.logd
}
}
  
  使用后:

import com.google.common.base.Preconditions;
public class Foo {
void m(Object o) {
if (BuildConfig.DEBUG) Log.d(TAG, o);
}
}
  
  30.吐司输出表达式——toast(Toast.makeText(context,expr,Toast.LENGTH_SHORT).show();)
  使用前:

public class Foo {
void m(Object o) {
o.toast
}
}
  
  使用后:

import com.google.common.base.Preconditions;
public class Foo {
void m(Object o) {
Toast.makeText(MyActivity.this, &quot;test&quot;, Toast.LENGTH_SHORT).show();
}
}
  
  


  二、安装
  打开设置,找到插件,输入postfix,第一个出来的就是,然后点击安装即可,安装完成记得需要重新启动Android
Studio。



DSC0002.jpg
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-143031-1-1.html 上篇帖子: centos 下安装Postfix 下篇帖子: ★★★基于FreeBSD和Postfix的邮件系统与邮件列表的web mail安装4.51
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表