美文网首页
几个Templates

几个Templates

作者: LvLz | 来源:发表于2020-09-16 14:00 被阅读0次
总结了几个常用的自定义模版
自定义缩写:acthandler
private static class $class$ extends Handler {
    final WeakReference<$ACTIVITY$> mActivityReference;

    private $class$($ACTIVITY$ activity) {
        mActivityReference = new WeakReference<$ACTIVITY$>(activity);
    }

    public void handleMessage(android.os.Message msg) {
        final $ACTIVITY$ mHandlerActivity = mActivityReference.get();
        if (mHandlerActivity == null) {
            return;
        }
          
        switch (msg.what) {
            case :
        
                break;
            case :
        
                break;
            case :
        
                break;
        }  
    }
}
自定义缩写:frahandler
private static class $class$ extends Handler {
    final WeakReference<$fragment$> mFragmentReference;

    private $class$($fragment$ fragment) {
        mFragmentReference = new WeakReference<$fragment$>(fragment);
    }

    public void handleMessage(android.os.Message msg) {
        final $fragment$ mHandlerFragment = mFragmentReference.get();
        if (mHandlerFragment == null) {
            return;
        }
           
        switch (msg.what) {
            case :
        
                break;
            case :
        
                break;
            case :
        
                break;
        } 
    }
}
具体使用时:
private XxHandler xxHandler = new XxHandler(XxActivity.this);
@Override
protected void onDestroy() {
    xxHandler.removeCallbacksAndMessages(null);
    super.onDestroy();
}

自定义缩写:ife
if ($cursor$) {
    
} else {
                       
}

自定义缩写:logg
KLog.d("$cursor$", "success ----- " + jsonObject.toString());
自定义缩写:loog
KLog.d("$cursor$", "fail ----- " + message);

自定义缩写:swi
switch ($cursor$) {
    case :

        break;
    case :

        break;
    case :

        break;
}

自定义缩写:swii
switch (v.getId()) {
    case :

        break;
    case :

        break;
    case :

        break;
}


自定义缩写:tc
try {
    $cursor$
} catch (Exception e) {
    e.printStackTrace();
}

相关文章

网友评论

      本文标题:几个Templates

      本文链接:https://www.haomeiwen.com/subject/axncyktx.html