温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

【FastDev4Android框架开发】Android快速开发框架介绍(一)

发布时间:2020-07-20 14:08:38 来源:网络 阅读:723 作者:jiangqq900826 栏目:移动开发

          本项目是Android快速开发框架,采用AndroidStudio进行开发。 随着公司项目的不断深入,也相信每个公司都有自己的项目开发框架,同时也在不断的完善,本人在工作中也在不断总结,喜欢技术,热爱开源,也乐于和各种技术牛人一起交流。同时一直有一个想法可以做一套相对快速的开发框架用于工作中。所以就有了下面这个项目,各种工具方法都会再接下来的时间中慢慢加入进入,也非常欢迎和我同样想法的牛人加入进来,一起把这个项目完善好~Thankyou

           项目地址:https://github.com/jiangqqlmj/FastDev4Android

              文章主页地址:http://blog.csdn.net/developer_jiangqq

           (一):初步想法集成如下:

               1:开发工具类;

               2:ORM;

               3:网络请求(HTTPClint,Volley,OkHttps);

      4:数据解析;

              5:依赖注入;

              6:xutils;

              7:图片异步加载;

              8:二维码扫描;

             9:自定义控件;

             10:传感器相关功能等等 后续会进行逐步添加。

        【FastDev4Android框架开发】Android快速开发框架介绍(一)

        模块详解如下:

         【FastDev4Android框架开发】Android快速开发框架介绍(一)

        (二):V1.0_001版本功能如下: 

一.Utils工具类加入(1.DataUtils 时间日期处理
2.GuideUtils 是否启动引导处理标志管理
3.IoUtils 网络请求工具类【特别注意】这边采用HTTPClient 由于Android 6.0已经删除该类,
这边libs目录需要加入org.apache.http.legcy.jar依赖包
4.JudgeNetWorker 网络状态判断工具类
5.Log 日志自定义管理
6.ManagerActivity Activity管理工具类
7.StrUtils 字符串相关处理工具类,系统信息获取工具类)
二.sperferences加入SharePerferences加入封装工具可以快速使用SP进行数据保存配置文件
三.Activity基类简单封装BaseActivity和BaseFrameActivity 暂时主要为Toast,LayoutInFlater,打开指定的Activity工具类封装

       (三):实例代码

         1:SharedPerference模块封装类:

SharedPreferencesHelper.java

[java] view plaincopy

  1. package com.chinaztt.fda.spreference;  

  2.   

  3. import android.content.Context;  

  4. import android.content.SharedPreferences;  

  5.   

  6. /** 

  7.  * 当前类注释:当前为SharedPerferences进行封装基本的方法,SharedPerferences已经封装成单例模式 

  8.  * 可以通过SharedPreferences sp=SharedPreferencesHelper.getInstances(FDApplication.getInstance())进行获取当前对象 

  9.  * sp.putStringValue(key,value)进行使用 

  10.  * 项目名:FastDev4Android 

  11.  * 包名:com.chinaztt.fda.spreference 

  12.  * 作者:江清清 on 15/10/22 09:25 

  13.  * 邮箱:jiangqqlmj@163.com 

  14.  * QQ: 781931404 

  15.  * 公司:江苏中天科技软件技术有限公司 

  16.  */  

  17. public class SharedPreferencesHelper {  

  18.     private static final String SHARED_PATH = "fda_shared";  

  19.     private static SharedPreferencesHelper instance;  

  20.     private SharedPreferences sp;  

  21.     private SharedPreferences.Editor editor;  

  22.   

  23.     public static SharedPreferencesHelper getInstance(Context context) {  

  24.         if (instance == null && context != null) {  

  25.             instance = new SharedPreferencesHelper(context);  

  26.         }  

  27.         return instance;  

  28.     }  

  29.   

  30.     private SharedPreferencesHelper(Context context) {  

  31.         sp = context.getSharedPreferences(SHARED_PATH, Context.MODE_PRIVATE);  

  32.         editor = sp.edit();  

  33.     }  

  34.   

  35.     public long getLongValue(String key) {  

  36.         if (key != null && !key.equals("")) {  

  37.             return sp.getLong(key, 0);  

  38.         }  

  39.         return 0;  

  40.     }  

  41.   

  42.     public String getStringValue(String key) {  

  43.         if (key != null && !key.equals("")) {  

  44.             return sp.getString(key, null);  

  45.         }  

  46.         return null;  

  47.     }  

  48.   

  49.     public int getIntValue(String key) {  

  50.         if (key != null && !key.equals("")) {  

  51.             return sp.getInt(key, 0);  

  52.         }  

  53.         return 0;  

  54.     }  

  55.   

  56.     public int getIntValueByDefault(String key)  

  57.     {  

  58.         if (key != null && !key.equals("")) {  

  59.             return sp.getInt(key, 0);  

  60.         }  

  61.         return 0;  

  62.     }  

  63.     public boolean getBooleanValue(String key) {  

  64.         if (key != null && !key.equals("")) {  

  65.             return sp.getBoolean(key, false);  

  66.         }  

  67.         return true;  

  68.     }  

  69.   

  70.     public float getFloatValue(String key) {  

  71.         if (key != null && !key.equals("")) {  

  72.             return sp.getFloat(key, 0);  

  73.         }  

  74.         return 0;  

  75.     }  

  76.   

  77.     public void putStringValue(String key, String value) {  

  78.         if (key != null && !key.equals("")) {  

  79.             editor = sp.edit();  

  80.             editor.putString(key, value);  

  81.             editor.commit();  

  82.         }  

  83.     }  

  84.   

  85.     public void putIntValue(String key, int value) {  

  86.         if (key != null && !key.equals("")) {  

  87.             editor = sp.edit();  

  88.             editor.putInt(key, value);  

  89.             editor.commit();  

  90.         }  

  91.     }  

  92.   

  93.     public void putBooleanValue(String key, boolean value) {  

  94.         if (key != null && !key.equals("")) {  

  95.             editor = sp.edit();  

  96.             editor.putBoolean(key, value);  

  97.             editor.commit();  

  98.         }  

  99.     }  

  100.   

  101.     public void putLongValue(String key, long value) {  

  102.         if (key != null && !key.equals("")) {  

  103.             editor = sp.edit();  

  104.             editor.putLong(key, value);  

  105.             editor.commit();  

  106.         }  

  107.     }  

  108.   

  109.     public void putFloatValue(String key, Float value) {  

  110.         if (key != null && !key.equals("")) {  

  111.             editor = sp.edit();  

  112.             editor.putFloat(key, value);  

  113.             editor.commit();  

  114.         }  

  115.     }  

  116. }  

    SharedPerferencesTag.java


[java] view plaincopy

  1. package com.chinaztt.fda.spreference;  

  2.   

  3. /** 

  4.  * 当前类注释:当前类用户SharedPreferences进行save的时候 配置key常量 

  5.  * 项目名:FastDev4Android 

  6.  * 包名:com.chinaztt.fda.spreference 

  7.  * 作者:江清清 on 15/10/22 09:26 

  8.  * 邮箱:jiangqqlmj@163.com 

  9.  * QQ: 781931404 

  10.  * 公司:江苏中天科技软件技术有限公司 

  11.  */  

  12. public class SharedPreferencesTag {  

  13.     public static final String DEMO_KEY="demo_key";  

  14.   

  15. }  

    2.日志管理类封装


[java] view plaincopy

  1. package com.chinaztt.fda.utils;  

  2.   

  3. /** 

  4.  * 当前类注释:重写系统日志管理类 

  5.  * 使用方法:还是和平时Log.v(key,value)这样使用,需要导入当前类,该类会打印比系统更多的日志信息, 

  6.  * 例如:类名称,当前运行的方法,行数,和日志信息 

  7.  * 项目名:FastDev4Android 

  8.  * 包名:com.chinaztt.fda.utils 

  9.  * 作者:江清清 on 15/10/22 09:35 

  10.  * 邮箱:jiangqqlmj@163.com 

  11.  * QQ: 781931404 

  12.  * 公司:江苏中天科技软件技术有限公司 

  13.  */  

  14. public class Log {  

  15.     public static boolean mIsShow=true;  

  16.   

  17.     /** 

  18.      * 设置是否打开log日志开关 

  19.      * @param pIsShow 

  20.      */  

  21.     public static void setShow(boolean pIsShow)  

  22.     {  

  23.         mIsShow=pIsShow;  

  24.     }  

  25.   

  26.     /** 

  27.      * 根据tag打印相关v信息 

  28.      * @param tag 

  29.      * @param msg 

  30.      */  

  31.     public static void v(String tag,String msg)  

  32.     {  

  33.         if(mIsShow){  

  34.             StackTraceElement ste = new Throwable().getStackTrace()[1];  

  35.             String traceInfo = ste.getClassName() + "::";  

  36.             traceInfo += ste.getMethodName();  

  37.             traceInfo += "@" + ste.getLineNumber() + ">>>";  

  38.             android.util.Log.v(tag, traceInfo+msg);}  

  39.     }  

  40.   

  41.     /** 

  42.      * 根据tag打印v信息,包括Throwable的信息 

  43.      * * @param tag 

  44.      * @param msg 

  45.      * @param tr 

  46.      */  

  47.     public static void v(String tag,String msg,Throwable tr)  

  48.     {  

  49.         if(mIsShow){  

  50.             android.util.Log.v(tag, msg, tr);  

  51.         }  

  52.     }  

  53.   

  54.   

  55.     /** 

  56.      * 根据tag打印输出debug信息 

  57.      * @param tag 

  58.      * @param msg 

  59.      */  

  60.     public static void d(String tag,String msg)  

  61.     {  

  62.         if(mIsShow){  

  63.             StackTraceElement ste = new Throwable().getStackTrace()[1];  

  64.             String traceInfo = ste.getClassName() + "::";  

  65.             traceInfo += ste.getMethodName();  

  66.             traceInfo += "@" + ste.getLineNumber() + ">>>";  

  67.             android.util.Log.d(tag, traceInfo+msg);  

  68.         }}  

  69.   

  70.     /** 

  71.      * 根据tag打印输出debug信息 包括Throwable的信息 

  72.      * * @param tag 

  73.      * @param msg 

  74.      * @param tr 

  75.      */  

  76.     public static void d(String tag,String msg,Throwable tr)  

  77.     {  

  78.         if(mIsShow){  

  79.             android.util.Log.d(tag, msg, tr);  

  80.         }}  

  81.   

  82.     /** 

  83.      * 根据tag打印输出info的信息 

  84.      * * @param tag 

  85.      * @param msg 

  86.      */  

  87.     public static void i(String tag,String msg)  

  88.     {  

  89.         if(mIsShow){  

  90.             StackTraceElement ste = new Throwable().getStackTrace()[1];  

  91.             String traceInfo = ste.getClassName() + "::";  

  92.             traceInfo += ste.getMethodName();  

  93.             traceInfo += "@" + ste.getLineNumber() + ">>>";  

  94.             android.util.Log.i(tag, traceInfo+msg);  

  95.         }}  

  96.   

  97.     /** 

  98.      * 根据tag打印输出info信息 包括Throwable的信息 

  99.      * @param tag 

  100.      * @param msg 

  101.      * @param tr 

  102.      */  

  103.     public static void i(String tag,String msg,Throwable tr)  

  104.     {  

  105.         if(mIsShow){  

  106.             android.util.Log.i(tag, msg, tr);  

  107.         }}  

  108.   

  109.     /** 

  110.      * 根据tag打印输出error信息 

  111.      * @param tag 

  112.      * @param msg 

  113.      */  

  114.     public static void e(String tag,String msg)  

  115.     {  

  116.         if(mIsShow){  

  117.             StackTraceElement ste = new Throwable().getStackTrace()[1];  

  118.             String traceInfo = ste.getClassName() + "::";  

  119.             traceInfo += ste.getMethodName();  

  120.             traceInfo += "@" + ste.getLineNumber() + ">>>";  

  121.             android.util.Log.e(tag, traceInfo+msg);  

  122.         }}  

  123.   

  124.     /** 

  125.      * 根据tag打印输出的error信息 包括Throwable的信息 

  126.      * @param tag 

  127.      * @param msg 

  128.      * @param tr 

  129.      */  

  130.     public static void e(String tag,String msg,Throwable tr)  

  131.     {  

  132.         if(mIsShow){  

  133.             android.util.Log.e(tag, msg, tr);  

  134.         }}  

  135. }  

    以上是部分工具类封装模块,有兴趣的童鞋可以去(https://github.com/jiangqqlmj/FastDev4Android)进行clone,也同时欢迎大家star或者fork一下哈,项目会不断更新,同时如果有兴趣一起完善项目的小伙伴联系我哈~博客资料有联系方式!


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI