需添加权限 {@code
8 | * author: Blankj 9 | * blog : http://blankj.com 10 | * time : 2016/10/09 11 | * desc : 关闭相关工具类 12 | *13 | */ 14 | public final class CloseUtils { 15 | 16 | private CloseUtils() { 17 | throw new UnsupportedOperationException("u can't instantiate me..."); 18 | } 19 | 20 | /** 21 | * 关闭IO 22 | * 23 | * @param closeables closeables 24 | */ 25 | public static void closeIO(Closeable... closeables) { 26 | if (closeables == null) return; 27 | for (Closeable closeable : closeables) { 28 | if (closeable != null) { 29 | try { 30 | closeable.close(); 31 | } catch (IOException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | } 36 | } 37 | 38 | /** 39 | * 安静关闭IO 40 | * 41 | * @param closeables closeables 42 | */ 43 | public static void closeIOQuietly(Closeable... closeables) { 44 | if (closeables == null) return; 45 | for (Closeable closeable : closeables) { 46 | if (closeable != null) { 47 | try { 48 | closeable.close(); 49 | } catch (IOException ignored) { 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/fighter/superframe/gloable/MeiziApp.java: -------------------------------------------------------------------------------- 1 | package com.fighter.superframe.gloable; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.fighter.superframe.BuildConfig; 7 | import com.fighter.superframe.utils.LogUtils; 8 | import com.tencent.android.tpush.XGIOperateCallback; 9 | import com.tencent.android.tpush.XGPushConfig; 10 | import com.tencent.android.tpush.XGPushManager; 11 | 12 | /** 13 | * Created by fighter_lee on 2017/8/8. 14 | */ 15 | 16 | public class MeiziApp extends Application { 17 | 18 | private static final String TAG = MeiziApp.class.getSimpleName(); 19 | public static Context sCx; 20 | 21 | @Override 22 | public void onCreate() { 23 | super.onCreate(); 24 | sCx = getApplicationContext(); 25 | LogUtils.getConfig().setLogSwitch(BuildConfig.DEBUG_MODE); 26 | initPush(); 27 | 28 | } 29 | 30 | private void initPush() { 31 | XGPushConfig.enableDebug(this,BuildConfig.DEBUG_MODE); 32 | XGPushManager.registerPush(this, new XGIOperateCallback() { 33 | @Override 34 | public void onSuccess(Object data, int flag) { 35 | //token在设备卸载重装的时候有可能会变 36 | LogUtils.d("TPush", "注册成功,设备token为:" + data); 37 | } 38 | @Override 39 | public void onFail(Object data, int errCode, String msg) { 40 | LogUtils.d("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg); 41 | } 42 | }); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/fighter/superframe/ui/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.fighter.superframe.ui.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import butterknife.ButterKnife; 11 | import butterknife.Unbinder; 12 | 13 | 14 | public abstract class BaseFragment extends Fragment { 15 | 16 | private Unbinder unbinder; 17 | 18 | /** 19 | * 获取布局ID 20 | */ 21 | protected abstract int getContentViewLayoutID(); 22 | 23 | /** 24 | * 界面初始化 25 | */ 26 | protected abstract void init(); 27 | 28 | @Nullable 29 | @Override 30 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 31 | if (getContentViewLayoutID() != 0) { 32 | return inflater.inflate(getContentViewLayoutID(), container, false); 33 | } else { 34 | return super.onCreateView(inflater, container, savedInstanceState); 35 | } 36 | } 37 | 38 | @Override 39 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 40 | super.onViewCreated(view, savedInstanceState); 41 | unbinder = ButterKnife.bind(this, view); 42 | init(); 43 | } 44 | 45 | @Override 46 | public void onDestroyView() { 47 | super.onDestroyView(); 48 | unbinder.unbind(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/base_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 |
10 | * author: Blankj 11 | * blog : http://blankj.com 12 | * time : 2016/08/07 13 | * desc : Shell相关工具类 14 | *15 | */ 16 | public final class ShellUtils { 17 | 18 | private ShellUtils() { 19 | throw new UnsupportedOperationException("u can't instantiate me..."); 20 | } 21 | 22 | /** 23 | * 是否是在root下执行命令 24 | * 25 | * @param command 命令 26 | * @param isRoot 是否需要root权限执行 27 | * @return CommandResult 28 | */ 29 | public static CommandResult execCmd(String command, boolean isRoot) { 30 | return execCmd(new String[]{command}, isRoot, true); 31 | } 32 | 33 | /** 34 | * 是否是在root下执行命令 35 | * 36 | * @param commands 多条命令链表 37 | * @param isRoot 是否需要root权限执行 38 | * @return CommandResult 39 | */ 40 | public static CommandResult execCmd(List