override

Android - java.lang.IllegalArgumentException: Receiver not registered

a 夏天 提交于 2019-11-29 18:45:37
java.lang.IllegalArgumentException: Receiver not registered 从平台上可以看到Crash的错误问题, 出现了以下这条 java.lang.IllegalArgumentException: Receiver not registered 明明我OnResume有注册、OnPause有移除。 但为什么会发生这个问题 private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { ... doSomeThing } }; BroadcastReceiver这样命 onResume如下 @Override protected void onResume() { super.onResume(); registerReceiver(mReceiver, new IntentFilter("filter_action")); } onPause如下 @Override protected void onPause() { super.onPause(); unregisterReceiver(mReceiver); } 但会出现如下的错误消息

使用Arrays.asList()时遇到的问题

[亡魂溺海] 提交于 2019-11-29 18:19:58
Arrays.asList()是JDK自带的一个将数组转换为集合的方法, 但是在使用中发现, 使用该方式在将数组转换为集合之后,相应的集合修改方法使用时会抛出异常, 如果add/remove/clear等.打开JDK源码, 发现该方法是返回了一个ArrayList,但是我们进入到ArrayList内部,发现,这个ArrayList和我们平常使用的是不一样的,源码如下: private static class ArrayList<E> extends AbstractList<E> implements RandomAccess, java.io.Serializable { private static final long serialVersionUID = -2764017481108945198L; private final E[] a; ArrayList(E[] array) { a = Objects.requireNonNull(array); } @Override public int size() { return a.length; } @Override public Object[] toArray() { return a.clone(); } @Override @SuppressWarnings("unchecked") public <T>

【R】调整ggplot图例大小

风格不统一 提交于 2019-11-29 04:45:35
图例太多时,会挤压正图,显得正图展示区域很小,这时有必要缩小图例。 ################# # 减小ggplot图例 ################# library(ggplot2) p <- ggplot(mtcars, aes(drat, mpg, color = factor(gear), shape = factor(vs))) + geom_point(size = 2) + theme_classic() + theme(legend.position = c(0.1, 0.7)) p # Overwrite given size (2) to 0.5 (super small) p <- p + guides(shape = guide_legend(override.aes = list(size = 0.5))) p p <- p + guides(color = guide_legend(override.aes = list(size = 0.5))) p p <- p + theme(legend.title = element_text(size = 3), legend.text = element_text(size = 3)) p addSmallLegend <- function(myPlot, pointSize = 0.5,

flutter 中的搜索条实现

扶醉桌前 提交于 2019-11-28 22:59:42
import 'package:flutter/material.dart'; import 'package:flutter_app/SearchBarDemo.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.green, //定义主题风格 primarySwatch ), home: SearchBarDemo(), ); } } import 'package:flutter/material.dart'; import 'asset.dart'; class SearchBarDemo extends StatefulWidget { _SearchBarDemoState createState() => _SearchBarDemoState(); } class _SearchBarDemoState extends State<SearchBarDemo> { @override Widget build

内部类

依然范特西╮ 提交于 2019-11-28 10:37:46
1. 链接外部类 // innerclasses/Sequence.java // Holds a sequence of Objects interface Selector { boolean end(); Object current(); void next(); } public class Sequence { private Object[] items; private int next = 0; public Sequence(int size) { items = new Object[size]; } public void add(Object x) { if(next < items.length) items[next++] = x; } private class SequenceSelector implements Selector { private int i = 0; @Override public boolean end() { return i == items.length; } @Override public Object current() { return items[i]; } @Override public void next() { if(i < items.length) i++; } } public

测试

六眼飞鱼酱① 提交于 2019-11-27 12:04:32
public class TransportClientFactory implements FactoryBean<TransportClient>,InitializingBean,DisposableBean { private String clusterName; private String host; private String xpacksecurityuser; private int port; private TransportClient client; @Override public void afterPropertiesSet() throws Exception { Settings settings = Settings.builder() .put("cluster.name", clusterName) .put("xpack.security.user", xpacksecurityuser) .put("client.transport.sniff", false) .build(); client=new PreBuiltXPackTransportClient(settings).addTransportAddress(new InetSocketTransportAddress( InetAddress.getByName

Spark RDD高级编程:基于排序机制的wordcount程序+二次排序+topn

前提是你 提交于 2019-11-27 06:17:23
(1)基于排序机制的wordcount程序 对于以下文件 进行wordcount,并按照出现次数多少排序 代码如下: /** * 排序的wordcount程序 * @author Administrator * */ public class SortWordCount { public static void main(String[] args) { SparkConf conf=new SparkConf().setAppName("SortWordCount").setMaster("local"); JavaSparkContext sparkContext=new JavaSparkContext(conf); sparkContext.textFile("D://Bigdata//18.spark//wc.txt") .flatMap(new FlatMapFunction<String, String>() { @Override public Iterator<String> call(String s) throws Exception { return new Arrays.Iterator<>(s.split(" ")); } }).mapToPair(new PairFunction<String, String, Integer>() {

Java防止XSS攻击

限于喜欢 提交于 2019-11-27 01:48:43
方法一: 1.添加XssFilter @Configuration public class XssFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest)servletRequest; filterChain.doFilter(new XssHttpServletRequestWrapper(request),servletResponse); } @Override public void destroy() { } } XSSFilter 2.添加XssHttpServletRequestWrapper.java类 public class XssHttpServletRequestWrapper

简单的实现网路请求

你说的曾经没有我的故事 提交于 2019-11-26 23:57:43
动画 public class MainActivity extends AppCompatActivity { private ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Intent intent=new Intent(MainActivity.this,Main2Activity.class); // startActivity(intent); img = (ImageView) findViewById(R.id.img); Animation animation=new AlphaAnimation(0.1f,1.0f); animation.setDuration(5000); img.startAnimation(animation); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { }