context

Golang go-gin路由

谁都会走 提交于 2020-02-05 12:27:25
代码实现 main.go package main import ( "fmt" "github.com/jihite/go-gin-example/pkg/setting" "github.com/jihite/go-gin-example/routers" "net/http" ) func main() { router := routers.InitRouter() s := &http.Server{ Addr: fmt.Sprintf(":%d", setting.HTTPPort), Handler: router, ReadTimeout: setting.ReadTimeout, WriteTimeout: setting.WriteTimeout, MaxHeaderBytes: 1 << 20, } s.ListenAndServe() } http:Server: Addr:监听的TCP地址,格式为 :8000 Handler:http句柄,实质为 ServeHTTP ,用于处理程序响应HTTP请求 ReadTimeout:允许读取的最大时间 WriteTimeout:允许写入的最大时间 MaxHeaderBytes:请求头的最大字节数 实现InitRouter() func InitRouter() *gin.Engine { r := gin.New()

Picaso完美兼容OkHttp3.3,缓存优化两不误 - Tamic Developer\"s Blog

断了今生、忘了曾经 提交于 2020-02-05 09:23:56
为何在Fresco,Glide这么强大的背景下,我又想起了当初的Picasso,又为何写这篇文章?是因为最近项目采用了square公司的RxAndroid,Retrfit和OKhttp, 不得不联想到这个公司曾经还有款图片加载Picasso,所以采用了square公司的全家桶来进行项目开发,为了减少开发成本和也防止Apk增大,毕竟一个公司的框架之前兼容性不用担心,那么请让我们回顾一下Picass之路 首先先让我们看看主流图片加载库 Picasso,Square公司的开源项目 ,和Square的网络库一起能发挥最大作用。占用内存小,自身不带缓存,需依赖OKhttps实现缓存,不支持gif图片 Fresco,FB的明星项目,也是2015最火的项目之一,匿名共享缓存等机制保证低端机表现极佳,但是源代码基于C/C++,阅读困难度提升。效率高,sdk库占用包体积比较大 Glide,Google员工私人项目,但是Google很多项目在用,占用内存小,减低oom更靠谱,相对Picasso在Gif方面有优势,并自带缓存功能! 我做了一个实验对比 用一个普通listview加载50张图片,并快速滑动列表,下面分别是glide和picasso消耗内存图 分析后得出 一个占用内存大 一个占用cpu资源大, 这种区别是由于picasso只缓存一张大图,每次加载根据imagview的大小裁剪

判断当前是wifi 还是网络

点点圈 提交于 2020-02-05 07:38:34
//判断当前是wifi 还是网络 public static boolean checkNetworkConnection(Context context) { final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); final android.net.NetworkInfo wifi =connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); final android.net.NetworkInfo mobile =connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if(wifi.isAvailable()||mobile.isAvailable()) return true; else return false; } public class extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { State wifiState = null; State

Flutter: 使用相机拍照

安稳与你 提交于 2020-02-05 03:11:03
文档 camera import 'dart:io'; import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; List<CameraDescription> cameras; void main() async { /// 获取设备上可用摄像头的列表。 cameras = await availableCameras(); runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: HomePage(), ); } } class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> {

Android自定义控件开发

我是研究僧i 提交于 2020-02-05 02:43:40
项目中需要实现自定义控件,参照了网上的一些方法,实现了自己的需求,现在将实现过程简单做一下记录。 首先,上效果图: 图上的每一张图片加title都是自定义控件。 下面是实现过程: 1. 编写自定义控件的布局: menu.xml < LinearLayout xmlns : android = "http://schemas.android.com/apk/res/android" android : layout_width = "wrap_content" android : layout_height = "wrap_content" android : padding = "6dp" android : orientation = "vertical" android : gravity = "center" > < de . hdodenhof . circleimageview . CircleImageView xmlns : app = "http://schemas.android.com/apk/res-auto" android : id = "@+id/iv_menu" android : layout_width = "72dp" android : layout_height = "72dp" android : layout_marginBottom =

8 -- 深入使用Spring -- 5...2 使用@Cacheable执行缓存

余生颓废 提交于 2020-02-05 02:26:40
      8.5.2 使用@Cacheable执行缓存         @Cacheable可用于修饰类或修饰方法,当使用@Cacheable修饰类时,用于告诉Spring在类级别上进行缓存 ------ 程序调用该类的实例的任何方法时都需要缓存,而且共享同一个缓存区;当使用@Cacheable修饰方法时,用于告诉Spring在方法级别上进行缓存 ------ 只有当程序调用该方法时才需要缓存。         1. 类级别的缓存           当使用@Cacheable修饰类时,就可控制Spring在类级别进行缓存,这样程序调用类的任意方法时,只要传入的参数相同,Spring就会使用缓存。           Component : UserServiceImpl package edu.pri.lime._8_5_2.classrank.impl; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import edu.pri.lime._8_5_2.classrank.UserService; import edu.pri.lime._8_5_2.classrank.bean.User; @Service(value

Spring+SpringMVC+Mybatis 环境搭建

独自空忆成欢 提交于 2020-02-05 00:12:36
一、环境 mac + Idea + 数据库 mysql 二、项目整合过程 1⃣️. 创建动态Web项目,请参考: https://www.cnblogs.com/KennyWang0314/p/12261890.html 2⃣️.引入 jar 包 === ***注意:c3p0包依赖 mchange-commons 记得导入    3⃣️.文件配置 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:application-base.xml</param-value> </context-param> <listener>

SSM整合配置文件怎么写?

六月ゝ 毕业季﹏ 提交于 2020-02-04 21:04:28
文章目录 一. 搭建环境 1. 创建Maven工程 2.导入依赖 I. 版本锁定 II.导入dependencies依赖 3.编写实体类 二. 进行整合 1.配置SqlMapConfig.xml 2.配置springmvc.xml 3.配置applicationContext.xml(企业常用applicationContext.xml命名表示是spring的配置) 一. 搭建环境 1. 创建Maven工程 2.导入依赖 I. 版本锁定 < properties > < spring.version > 5.0.2.RELEASE </ spring.version > < slf4j.version > 1.6.6 </ slf4j.version > < log4j.version > 1.2.12 </ log4j.version > < mysql.version > 5.1.6 </ mysql.version > < mybatis.version > 3.4.5 </ mybatis.version > </ properties > II.导入dependencies依赖 < dependencies > <!-- spring --> < dependency > < groupId > org.aspectj </ groupId > < artifactId

Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 解决方案

好久不见. 提交于 2020-02-04 15:17:07
SpringBoot启动时的异常信息 "C:\Program Files\Java\jdk1.8.0_161\bin\java" ......... com.fangxing.javalearning.annotationlearning.ComponentScanApp hello world . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.0.RELEASE) 2018-04-03 22:25:07.232 INFO 4976 --- [ main] c.f.j.a.ComponentScanApp : Starting ComponentScanApp on DESKTOP-BHGM3HS with PID 4976 (started by hasee in D:\test\projects\java-learning) 2018-04-03 22

Glide的加载图片的帮助类,用来把图片圆角或者改成圆形图片

可紊 提交于 2020-02-04 11:46:17
Glide虽然非常好用但是没找到把图片圆角的方法,所以百度了一个非常不错的加载类自己实现圆角图 感谢原文章作者:http://blog.csdn.net/weidongjian/article/details/47144549 自定义一个extend BitmapTransformation的方法,把获得的bitmap转化成圆形图片 import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; /** * 这是一个Glide的加载图片的帮助类,用来把图片圆角 * Created by Lizhanqi on 2016/9