GSON 解析null异常问题

Gson gson = new GsonBuilder().registerTypeHierarchyAdapter(List.class, new JsonDeserializer<List<?>>() {
    @Override
    public List<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        if (json.isJsonArray()){
            //这里要自己负责解析了
            Gson newGson = new Gson();
            try {
                return newGson.fromJson(json,typeOfT);
            }catch (Exception e){
                return Collections.EMPTY_LIST;//解析异常返回空数组
            }
        }else {
            //和接口类型不符,返回空List
            return Collections.EMPTY_LIST;
        }
    }
}).create();
registerTypeHierarchAdapter注册一个反序列号。上面是list中值是null的问题。
int,string都可以参照上面方式处理,在deserialize中处理json数据。

Flutter分析工具

1.view->tool windows里可以选择对应的flutter工具:flutter performances
2.flutter run将程序跑起来,在控制台会有一个网址,将网址拷贝的浏览器上打开,这个是dart分析工具,也可以协助分析和调试,devTool可以根据W、S控制放大缩小,A、D控制左右移动
3.设置debug
debugProfileBuildsEnabled = true;
debugProfilePaintsEnabled = true;
debugPaintLayerBordersEnabled = true;
4.savelayer 和clipPath少用
savelayer在opacity和shadermask中可能调用;
如果需要clip尽量使用:clip.antialians和clip.hardedge
5.控件更新定义一个特定的模块;

Flutter 问题汇总

1、启动页黑屏和启动之后黑屏问题
drawable下可以设置启动页的背景或者颜色;
mainifest下在对应的activity加上:



2.AndroidStudio 打开yaml文件,造成AndroidStudio卡死问题:
检查是否安装了插件:Flutter EnhanceMent Suite,如果安装了,把该插件卸载掉。

android 视频播放器

使用第三方库:https://github.com/maiwenchang/ArtPlayer
1.其中可以设置不同播放器,如果做需要横屏,从横向小屏到大屏,修改
if(video_view!=null){
VideoView videoView = new VideoView(this);
//set parent
videoView.setParentVideoView(video_view);
videoView.setUp(video_view.getDataSourceObject(), VideoView.WindowType.FULLSCREEN, video_view.getData());
videoView.setControlPanel(new ControlVideoPanel(this,this));
videoView.startFullscreen(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
2.HTTPS,ijkplayer不支持,可以把播放器设置成其他的
MediaPlayerManager.instance().releasePlayerAndView(this);
MediaPlayerManager.instance().setMediaPlayer(new ExoPlayer(this));
引用的库:
implementation ‘org.salient.artvideoplayer:artplayer-java:0.7.0’
implementation ‘org.salient.artvideoplayer:artplayer-ui:0.7.0’
implementation “org.salient.artvideoplayer:artplayer-exo:0.7.0”
3.可以定制panel extends AbsControlPanel来实现播放页面