DeYi 技术博客

总结&记录


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

HEXO 安装、命令

发表于 2017-09-26 | 分类于 网站 , hexo

安装

  1. 下载安装 nodejs
    下载地址
  2. 创建一个文件夹,hexo.site,用于存放网站代码
  3. 安装 hexo 相关的 npm 包
    在命令行中,CD到 hexo.site 文件夹,执行下面的安装命令
    1
    2
    3
    4
    npm install hexo --save
    npm install hexo-cli --save
    npm install hexo-server --save
    npm install hexo-deployer-git --save

npm install hexo -g 在 c: 下安装后,到 d: 运行时,找不到命令 hexo

遇到的问题

  1. hexo d 发布时,把 hexo.site 文件夹发布到网站了
    解决办法:删除 hexo.site/.deploy_git 目录,重新发布。

  2. hexo.site/.deploy_git 换电脑后,会重新生成,并强制推送到网站
    解决办法:把这个目录,加入到 hexo.site 仓库的子模块
    参考 git submodule add

  3. npm 更新包

    1
    2
    3
    $ npm help list
    Update available 5.3.0 → 5.4.2 │
    │ Run npm i -g npm to update
1
2
3
4
5
6
7
8
9
10
11
12
13
C:\github.io>hexo version
hexo: 3.3.8
hexo-cli: 1.0.3
os: Windows_NT 10.0.17134 win32 x64
http_parser: 2.7.0
node: 6.11.2
v8: 5.1.281.103
uv: 1.11.0
zlib: 1.2.11
ares: 1.10.1-DEV
icu: 58.2
modules: 48
openssl: 1.0.2l

git submodule

发表于 2017-09-25 | 分类于 工程管理 , git

子模块允许你将一个 Git 仓库作为另一个 Git 仓库的子目录。
它能让你将另一个仓库克隆到自己的项目中,同时还保持提交的独立

帮助文档

1
2
3
4
5
6
7
8
9
usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: git submodule [--quiet] init [--] [<path>...]
or: git submodule [--quiet] deinit [-f|--force] (--all| [--] <path>...)
or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--] [<path>...]
or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: git submodule [--quiet] foreach [--recursive] <command>
or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
or: git submodule [--quiet] absorbgitdirs [--] [<path>...]

创建的配置文件

  • .gitmodules
    1
    2
    3
    [submodule "themes/next"]
    path = themes/next
    url = git@github.com:VideoTec/hexo-theme-next.git

子模块文件夹 虽然是工作目录中的一个子目录,但 Git 还是会将它视作一个子模块。
当你不在那个目录中时,Git 并不会跟踪它的内容, 而是将它看作该仓库中的一个特殊提交。

资料

Git 工具 - 子模块

例子

  • 增加子模块

    1
    2
    git submodule add https://github.com/chaconinc/DbConnector
    git submodule add https://github.com/iissnan/hexo-theme-next themes/next
  • 删除子模块
    way-to-remove-a-git-submodule

    1
    2
    3
    4
    5
    6
    git submodule deinit <asubmodule>    
    git rm <asubmodule>
    # Note: asubmodule (no trailing slash)
    # or, if you want to leave it in your working tree
    git rm --cached <asubmodule>
    rm -rf .git/modules/<asubmodule>
  • 克隆仓库后,第一次拉取子模块的,需要初始化
    git submodule init

  • 列出所有子模块
    git submodule status
  • 拉取子模块
    git submodule update

拉取子模块时的错误

1
2
3
> $ git submodule update .deploy_git
> Fetched in submodule path '.deploy_git', but it did not contain d0146b46d71549946f37804f694af92b9db0a9e7. Direct fetching of that commit failed.
>

解决办法,cd,到子模块目录,使用 git status 查看状态,进行处理。

java.lang.IllegalStateException MediaPlayer setDataSource

发表于 2017-09-25 | 分类于 编程 , android , exception

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public void addEffect(String effectPath) {
if (effectPlayer == null) {
effectPlayer = new MediaPlayer();
} else {
effectPlayer.stop(); //问题出在这里,stop 进入 stopped 状态,需要再调用 reset 才能进入 Idle 状态
}
try {
effectPlayer.setDataSource(effectPath);
twoVideoLayer.setDisplayTexture2(true);
effectPlayer.setSurface(new Surface(twoVideoLayer.getVideoTexture2()));
effectPlayer.prepare();
effectPlayer.start();

} catch (Exception e) {
Log.e(TAG, "播放特效失败", e);
}
}

异常信息

1
2
3
4
5
6
7
8
9
java.lang.IllegalStateException
at android.media.MediaPlayer._setDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1154)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1139)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1118)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1067)
at com.lansosdk.videoeditor.LansoPlayer.addEffect(LansoPlayer.java:88)
at work.wangxiang.lansodemo.PlayerActivity.onEffect(PlayerActivity.java:50)
at java.lang.reflect.Method.invoke(Native Method)

Idle 状态下,才可调用 setDataSource 方法。
调用 reset,才会进入 Idle 状态。
mediaplayer status machine

java.lang.IllegalStateException setSupportActionBar

发表于 2017-09-25 | 分类于 编程 , android , exception

代码

1
2
3
4
5
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

异常信息

1
2
3
4
5
6
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:204)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:129)
at work.wangxiang.lansodemo.PlayerActivity.onCreate(PlayerActivity.java:20)
at android.app.Activity.performCreate(Activity.java:6288)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)

清单文件

1
2
3
4
5
<activity
android:name=".PlayerActivity"
android:label="@string/title_activity_player"
android:theme="@style/AppTheme">
</activity>

样式代码 @style/AppTheme

1
2
3
4
5
6
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

解决方法,修改成下面的样式

1
2
3
4
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

Android Studio 布局预览时 渲染错误

发表于 2017-09-25 | 分类于 编程 , android , android studio , res , layout

错误 Missing classes

1
2
3
4
5
6
7
Missing classes

The following classes could not be found:
- com.caiyi.youle.camera.ui.CameraFilterHorizontalScrollView (Fix Build Path, Edit XML, Create Class)
- com.caiyi.youle.camera.ui.FocusImageView (Fix Build Path, Edit XML, Create Class)
- com.caiyi.youle.camera.ui.VideoProgressView (Fix Build Path, Edit XML, Create Class)
Tip: Try to build the project. Tip: Try to refresh the layout

解决方法:去掉布局文件中,不存在的 viewModel 对象的引用。重新 build,就可以了。

error: Error: Dimension types not allowed (at ‘shadowDx’ with value ‘5dp’

1
2
3
4
5
6
7
8
9
10
11
12
13
<TextView
android:id="@+id/iv_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_filter_selector"
android:gravity="center"
android:padding="8dp"
android:text="@string/filter"
android:textSize="@dimen/font_small_size"
android:shadowColor="@color/black"
android:shadowDx="5dp"
android:shadowDy="5dp"
android:shadowRadius="10dp"/>

改了只后,还出错,而且,XML中的值被改回去。仔细看错误发现,错误指向的XML不是原始文件:
D:\\work\\videoshare_android.git\\app\\build\\intermediates\\data-binding-layout-out\\_360\\debug\\layout\\activity_camera_record_video_layout.xml

错误 Using the design library requires using Theme.AppCompat or a descendant

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Using the design library requires using Theme.AppCompat or a descendant

Failed to instantiate one or more classes
android.support.design.widget.CoordinatorLayout
android.support.design.widget.AppBarLayout
android.support.design.widget.FloatingActionButton

one or more layouts are missing the layout_width or layout_height attributes

java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:36)
at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:205)
at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:199)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:475)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:262)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:220)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

配置清单
解决方法
删除 PlayerActivity 的 android:theme="@style/AppTheme.NoActionBar"
即使用 <application> 指定的样式 android:theme="@style/AppTheme"
或者给 @style/AppTheme.NoActionBar 增加父样式 Theme.AppCompat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".LansoDemoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PlayerActivity"
android:label="@string/title_activity_player"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>

@style/AppTheme.NoActionBar 和 @style/AppTheme 样式的代码

1
2
3
4
5
6
7
8
9
10
11
12
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

gradle.build 指定的依赖

1
2
3
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'

出错的 Activity 的定义

1
public class PlayerActivity extends AppCompatActivity

出错的布局

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="work.wangxiang.lansodemo.PlayerActivity">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_player" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

  • 修改依赖库的版本 design:26.0.0-alpha1
  • 解决了问题 in manifest add the appcompat theme

把 activity 样式回复成原来的,重新打开 AS,又不出错了。

错误:Layout fidelity warning

1
2
3
4
5
6
7
8
9
10
<TextView
android:id="@+id/iv_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_filter_selector"
android:gravity="center"
android:padding="8dp"
android:text="@string/filter"
android:textSize="@dimen/font_small_size"
android:shadowColor="@color/white" />

accurate
英 [ˈækjərət] 美 [ˈækjərɪt]
adj.精确的,准确的;正确无误的

fidelity
英 [fɪˈdeləti] 美 [fɪˈdɛlɪti,faɪ-]
n.保真度;逼真;忠诚,忠实;尽责

The graphics preview in the layout editor may not be accurate:
Paint.setShadowLayer is not supported
error-the-graphics-preview-in-the-layout-editor-may-not-be-accurate-paint-set
It means the preview doesn’t know how to implement setShadowLayer. This means the preview won’t look exactly like the result rendered on the device. Which is one of many reasons why you shouldn’t trust the preview app- always test your layouts on a physical device before assuming they’re done.

Android 触摸事件分发流程

发表于 2017-09-23 | 分类于 编程 , android , android sdk , touch event

需要整理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
private boolean clickOutsideOf(View v, MotionEvent ev) {
if (v.isShown()) {
Rect rect = new Rect();
v.getGlobalVisibleRect(rect);
if (!rect.contains((int) ev.getRawX(), (int) ev.getRawY())) {
return true;
}
}
return false;
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if (clickOutsideOf(filterListScrollView, ev)) {
mFilterSelectedPresenter.handlerFilterContainer();
return true;

} else if (clickOutsideOf(effectListRecyclerView, ev)) {
viewModel.setEffectVideoMode(false);
return true;
}
}
return super.dispatchTouchEvent(ev);
}

Android Studio Editor 自动补全的模板定义

发表于 2017-09-23 | 分类于 编程 , android , android studio , editor

单词

abbreviation
英 [əˌbri:viˈeɪʃn] 美 [əˌbriviˈeʃən]
n.省略,缩写,简化,缩写词,略语;[数学]约分;[音乐]略号

常用代码片段

hexo markdown header

1
2
3
4
5
6
---
title: $title$
date: $date$
tags: []
categories: []
---

abbr[‘æbr] 缩写: hexo-header 缩写名称前面最好加上点号:.
date 的表达式是 date("yyyy-MM-dd HH:mm:ss")
title 的表达式是 fileNameWithoutExtension()

private final static String TAG

1
private final static String TAG = "$CLASS_NAME$";

abbr: pfsst
变量 className()

参考网页

  • 官方文档
  • 用于计算变量的预定义方法列表
  • Android Studio添加注释模板
  • insert special characters as text in XML editor for Android
  • Live Template Variables

场景描述

编辑适用于 hexo 的 markdown 文档时,需要填写文章的头部信息。
希望能自动插入这些信息(特别是创建日期)

添加自定义的 Live Templates

  • 编辑 Live Templates 的位置

    File | settings | editor | Live Templates`

  • 选中 user 点击对话框右侧的加号按钮,创建新的模板

    也可创建自己的模板组(不使用 user 组)

  • 新建模板对话框中的名词解释
    • Abbreviation: 你敲 指定的单词 加回车,模板就出来了
    • Description: 表示这个模板描述
    • Template text:模板的内容
    • Edit Variables 定义模板中的变量(如:$data$)
    • Applicable in * 这个自动填充模块,应用于什么类型的文档。

applicable contexts 列表中没有对应的文档类型,如: markdown

安装 Markdown Navigator 插件,并带有以下 abbr

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.abbreviation(Abbreviation *[]:)
.codefence
.collapsed
.emoji
.footnote
.image
.link
.reference
.rfootnote
.rimage
.rlink
.table
.task
.toc
.wikilink

安装Windows系统的adb驱动

发表于 2017-09-23 | 分类于 编程 , android , android studio , tools

Markdown 文档 标签说明

发表于 2017-09-23 | 分类于 工具 , 编辑器 , markdown

参考网页

  • Markdown语法
  • Markdown: Basics (快速入门)
  • 献给写作者的 Markdown 新手指南

注意事项

  • 一定要注意空格的使用
    • 两个空格有缩进的意思
    • 嵌套标签时,标签间必须加空格
    • 行中使用的标签,必须与前面的文字之间加个空格
  • 两个换行符 即 增加一个空行的意思

hexo 特殊要求

  • 某些情况下,需要增加空行来隔离后面的段落,否则会出现缩进错误
    • 列表最后需要增加一个空行,来隔离后面的段落
    • 引用块的最后一行,也需要加个空行,来隔离后面的段落

引用中加代码的方法

引用符号 > 后面加上,代码块符号 ``` 。大部分编辑器可正确显示。
但是,hexo,分析错误。

原因:hexo 要求引用块的最后一行,需要增加一个空行来隔离后面的段落

代码引用

需要引用代码时,如果引用的语句只有一段,不分行,可以用 ` 将语句包起来。
如果引用的语句为多行,可以将```置于这段代码的首行和末行。

链接、图片

![图片说明](url 或者 路径)

当前站点的图片,一般放在 source/images 下,对应的路径就是 /images/example.jpg

图文混排问题:没有好的方法,只能在列表里加图片

[链接说明](url 或者 路径)

例子: [参考 git submodule add](../../../../25/工程管理/git/git-cmd-submodule/)

lansosdk 集成方法

发表于 2017-09-23 | 分类于 编程 , android , 3rdParty , lansosdk

添加的库文件

1
2
3
app/src/main/jniLibs/armeabi-v7a/libffmpegeditor.so
app/src/main/jniLibs/armeabi-v7a/liblsdisplay.so
app/src/main/jniLibs/armeabi-v7a/liblsplayer.so
1
2
3
app/libs/PermissionsManager.jar 第三方库
app/libs/lansongeditor_hx.jar
app/libs/textsurface.jar

添加源文件

1
2
com.lansosdk.videoeditor
com.lansosdk.videoplayer

可以从官网DEMO中获取

添加权限

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

6.0 及以上系统,别忘记在运行时请求权限

初始化时,加载 so 库,及验证key

1
2
LoadLanSongSdk.loadLibraries();
LanSoEditor.initSo(getApplicationContext(), 购买的KEY文件名-存储在asset目录下);

如果没有购买,初始化库时这样写
LanSoEditor.initSo(getApplicationContext(),null);
应用的包名必须是 com.lansoeditor.demo 修改 module-gradle.build 中的 applicationId
应用的名字必须是 蓝松视频编辑高级版本DEMO 修改清单文件.application 标签的 label 属性

简单测试代码

1
2
3
4
MeidaInfo mediaInfo = new MediaInfo(测试视频文件路径, );
if (mediaInfo.parse()) {
} else {
}
1…456

wxiang

音视频、Android、C/C++

54 日志
37 分类
43 标签
© 2019 wxiang
由 Hexo 强力驱动
|
主题 — NexT.Gemini v5.1.2