commit 14a788c79be20ea24a8f4437df3e8189a792b568 Author: UESTCsecurity Date: Wed Mar 27 11:19:08 2024 +0800 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aacae44 --- /dev/null +++ b/.gitignore @@ -0,0 +1,378 @@ +## +## PROJECT: Mouri Internal Library Essentials +## FILE: .gitignore +## PURPOSE: The root .gitignore file for Mile.Project Project +## +## LICENSE: The MIT License +## +## DEVELOPER: Mouri_Naruto (Mouri_Naruto AT Outlook.com) +## + +## +## Ignore Mile.Project specific temporary files, build results, +## and files generated by popular Visual Studio add-ons. +## +Output/ + +## +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd diff --git a/3D建模笔记/Fusion360使用教程.md b/3D建模笔记/Fusion360使用教程.md new file mode 100644 index 0000000..8ca001d --- /dev/null +++ b/3D建模笔记/Fusion360使用教程.md @@ -0,0 +1,25 @@ +**Fusion360 使用教程** + +## **一、场景基本的控制** + +**1.1 场景的旋转:**Shift + 鼠标左键 + +## 二、工具的基本使用 + +**2.1 曲面工具:** + +通过二维的轮廓,然后360°旋转所生成的实体。需要指定1)旋转轴 2)轮廓 两个信息实现曲面的生成。 + +## **三、模型的导出** + +fusion360采用的是项目管理的方式,在下图中我们可以看到有Admin Project和BalanceCar两个项目,这些项目默认是云端同步的。 + +image-20220917192141176 + +在项目中选择模型,右键选择导出可以导出Fusion360的文件格式。 + +image-20220917192224716 + +在导出对话框中可以将模型导出到本地文件夹 + +image-20220917192246893 \ No newline at end of file diff --git a/3D建模笔记/Image/Model_Export.png b/3D建模笔记/Image/Model_Export.png new file mode 100644 index 0000000..8f657a9 Binary files /dev/null and b/3D建模笔记/Image/Model_Export.png differ diff --git a/3D建模笔记/Image/Project_All.png b/3D建模笔记/Image/Project_All.png new file mode 100644 index 0000000..1d3ac5c Binary files /dev/null and b/3D建模笔记/Image/Project_All.png differ diff --git a/3D建模笔记/Image/Project_BalanceCar.png b/3D建模笔记/Image/Project_BalanceCar.png new file mode 100644 index 0000000..4683a7e Binary files /dev/null and b/3D建模笔记/Image/Project_BalanceCar.png differ diff --git a/Android开发笔记/Android Kotlin调用JNI.md b/Android开发笔记/Android Kotlin调用JNI.md new file mode 100644 index 0000000..5112203 --- /dev/null +++ b/Android开发笔记/Android Kotlin调用JNI.md @@ -0,0 +1,176 @@ +# Kotlin调用Jni的写法 + +## 一、安装CMake和NDK + +​ 在android studio的设置中安装Cmake,安装Cmake的时候注意cmake的版本。如果忘记CMake的版本,那么可以通过Android SDK Locatio目录中查看CMake的版本。如下图所示的CMake和NDK。 + +![image-20230221221558825](E:\技术武器库\技术开发笔记\Android开发笔记\Image\image-20230221221558825.png) + +## 二、创建工程 + +选择一个带 Native C++ 支持的工程,如下图所示: + +![image-20230221223742943](E:\技术武器库\技术开发笔记\Android开发笔记\Image\image-20230221223742943.png) + +## 三、配置 ndk 目录 + +​ 在文件 local.properties 中加入 ndk 的配置 + +## 四、目录结构 + +​ 以下文件都是自动生成的 + +![image-20230221223834839](E:\技术武器库\技术开发笔记\Android开发笔记\Image\image-20230221223834839.png) + +## 五、配置模块 build.gradle + +```shell +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.2" + + defaultConfig { + applicationId "com.lujianfei.androidjnicall" + minSdkVersion 26 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + externalNativeBuild { + cmake { + cppFlags "" + } + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + externalNativeBuild { + cmake { + path "src/main/cpp/CMakeLists.txt" + version "3.10.2" + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + + + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} +``` + +## 六、配置CMakeLists.txt和native-lib.cpp + +``` +# For more information about using CMake with Android Studio, read the +# documentation: https://d.android.com/studio/projects/add-native-code.html + +# Sets the minimum version of CMake required to build the native library. + +cmake_minimum_required(VERSION 3.4.1) + +# Creates and names a library, sets it as either STATIC +# or SHARED, and provides the relative paths to its source code. +# You can define multiple libraries, and CMake builds them for you. +# Gradle automatically packages shared libraries with your APK. + +add_library( # Sets the name of the library. + native-lib + + # Sets the library as a shared library. + SHARED + + # Provides a relative path to your source file(s). + native-lib.cpp ) + +# Searches for a specified prebuilt library and stores the path as a +# variable. Because CMake includes system libraries in the search path by +# default, you only need to specify the name of the public NDK library +# you want to add. CMake verifies that the library exists before +# completing its build. + +find_library( # Sets the name of the path variable. + log-lib + + # Specifies the name of the NDK library that + # you want CMake to locate. + log ) + +# Specifies libraries CMake should link to your target library. You +# can link multiple libraries, such as libraries you define in this +# build script, prebuilt third-party libraries, or system libraries. + +target_link_libraries( # Specifies the target library. + native-lib + + # Links the target library to the log library + # included in the NDK. + ${log-lib} ) +``` + +```C++ +#include +#include + +extern "C" JNIEXPORT jstring JNICALL +Java_com_lujianfei_androidjnicall_MainActivity_stringFromJNI( + JNIEnv* env, + jobject /* this */) { + std::string hello = "Hello from C++"; + return env->NewStringUTF(hello.c_str()); +} +``` + +## 七、Activity调用 + +```kotlin +package com.lujianfei.androidjnicall + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + // Example of a call to a native method + sample_text.text = stringFromJNI() + } + + /** + * A native method that is implemented by the 'native-lib' native library, + * which is packaged with this application. + */ + external fun stringFromJNI(): String + + companion object { + // Used to load the 'native-lib' library on application startup. + init { + System.loadLibrary("native-lib") + } + } +} +``` + diff --git a/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132205455.png b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132205455.png new file mode 100644 index 0000000..f7fa84e Binary files /dev/null and b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132205455.png differ diff --git a/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132430205.png b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132430205.png new file mode 100644 index 0000000..6381f32 Binary files /dev/null and b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132430205.png differ diff --git a/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132703141.png b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132703141.png new file mode 100644 index 0000000..3d236da Binary files /dev/null and b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124132703141.png differ diff --git a/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124133122986.png b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124133122986.png new file mode 100644 index 0000000..ee2c0ca Binary files /dev/null and b/Android开发笔记/AndroidStudio环境和依赖问题笔记/Image/image-20231124133122986.png differ diff --git a/Android开发笔记/AndroidStudio环境和依赖问题笔记/安卓开发环境配置问题.md b/Android开发笔记/AndroidStudio环境和依赖问题笔记/安卓开发环境配置问题.md new file mode 100644 index 0000000..3a7e12e --- /dev/null +++ b/Android开发笔记/AndroidStudio环境和依赖问题笔记/安卓开发环境配置问题.md @@ -0,0 +1,103 @@ +# 安卓开发环境配置问题 + +## 一、gradle的问题 + +​ 由于国内网络环境的问题,导致gradle经常没有办法正常下载,从而难以正常构建Android程序。 + +## 1.1 gradle下载失败的问题 + +​ Android Studio首次创建项目或其他操作时,会更新Gradle,由于一些原因会导致下载失败,就会提示ERROR:Gradle project sync failed。解决办法如下: +​ 1.根据报错提示的链接直接下载gradle-xxxxx.zip,可以通过浏览器在 https://services.gradle.org/distributions/ 下载对应的版本。 + +![image-20231124132205455](./Image/image-20231124132205455.png) + +​ 如上图所示,可以看到Android Studio正在下载gradle-8.0-bin.zip, 如果反复失败,可以通过上面的网址直接通过浏览器下载(如果不能访问可能需要使用科学上网),在网页中,我们可以找到对应的下载链接。: + +image-20231124132430205 + +​ 2.虽然AndroidStudio Gradle下载失败,但是会在你的C盘创建一个文件夹,如 C:\Users(你的用户名).gradle\wrapper\dists\gradle-6.5-bin\xxxxxxx(最后一级目录,每个人的文件名可能不一样) + +​ image-20231124132703141 + +​ 我们将步骤1中下载号的gradle-8.0-bin.zip复制到存在gradle-8.0-bin.zip.lck和gradle-8.0-bin.zip.part文件的文件夹中。 + +​ 3.修改Android Studio的gradle-wrapper文件 + +
+ image-20231124133122986 +
+ +​ 修改的方式如下,不同环境下路径存在不同,根据实际情况调整即可,重要的是要正确映射gradle的位置。 + +```shell +# Fri Nov 24 11:56:39 CST 2023 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +# 这是修改后的distributionUrl,把原先的网络地址映射为本地地址,程序通过本地地址下载 +distributionUrl=file:///C:/Users/admin/.gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0-bin.zip +# 下面是原地址 +#distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +``` + +​ 4.最后,重启AndroidStudio或者点击Sync Now就可以了。 + +## 二、Maven仓库配置问题 + +​ 目前最新版本的Android Studio的依赖配置和旧版本不太一样。一般来说,如果采用默认的仓库配置,下载速度过慢同时容易失败。 + +```shell +# 旧版 +pluginManagement { + repositories { + //新增这 4 个 + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://maven.aliyun.com/repository/google/' } + maven { url 'https://maven.aliyun.com/repository/jcenter/' } + maven { url 'https://maven.aliyun.com/repository/central/' } + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { +//新增这 4 个 + maven { url 'https://maven.aliyun.com/repository/public/' } + maven { url 'https://maven.aliyun.com/repository/google/' } + maven { url 'https://maven.aliyun.com/repository/jcenter/' } + maven { url 'https://maven.aliyun.com/repository/central/' } + google() + mavenCentral() + } +} + +rootProject.name = "helloworld" +include ':app' +# 最新版 maven写法发生了改变 maven { url 'https://jitpack.io' } => maven { url = uri("https://jitpack.io") } +pluginManagement { + repositories { + maven { url = uri("https://maven.aliyun.com/repository/public/") } + maven { url = uri("https://maven.aliyun.com/repository/google/") } + maven { url = uri("https://maven.aliyun.com/repository/jcenter/") } + maven { url = uri("https://maven.aliyun.com/repository/central/") } + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + maven { url = uri("https://maven.aliyun.com/repository/public/") } + maven { url = uri("https://maven.aliyun.com/repository/google/") } + maven { url = uri("https://maven.aliyun.com/repository/jcenter/") } + maven { url = uri("https://maven.aliyun.com/repository/central/") } + google() + mavenCentral() + } +} +``` + diff --git a/Android开发笔记/Android引入其他工程.md b/Android开发笔记/Android引入其他工程.md new file mode 100644 index 0000000..bd04c3b --- /dev/null +++ b/Android开发笔记/Android引入其他工程.md @@ -0,0 +1,19 @@ +## Android引入其他工程 + +​ 在安卓开发中,我们为了开发方便,所以需要引入其他的已经封装好的模块。如下所示: + +image-20230211150717050 + +​ 在app工程中,需要用到libsmb库提供的smb管理和访问的功能。需要在两个地方进行配置。首先是app工程目录下的settings.gradle中配置。 + +```shell +# settings.gradle的配置,是编译器包含libsmb +rootProject.name = "My Application" +include ':app' +include ':libsmb' +# 在build.gradle中添加依赖选项 +implementation fileTree(include: ['*.jar'], dir: 'libs') +... +implementation project(':libsmb') +``` + diff --git a/Android开发笔记/Android播放调用.md b/Android开发笔记/Android播放调用.md new file mode 100644 index 0000000..0ba9eac --- /dev/null +++ b/Android开发笔记/Android播放调用.md @@ -0,0 +1,16 @@ +## Android 播放器使用 + +### 一、调用第三方视频播放器 + +Android通过Intent调用第三方播放器,通过Url播放视频。 + +```java +// 启动第三方播放器 +Intent intent = new Intent(); +intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); +intent.setAction(android.content.Intent.ACTION_VIEW); +intent.setDataAndType(Uri.parse(http), "video/*"); +startActivity(intent); +``` + +### 二、Exo播放器的使用 diff --git a/Android开发笔记/Android线程池.md b/Android开发笔记/Android线程池.md new file mode 100644 index 0000000..28ee96c --- /dev/null +++ b/Android开发笔记/Android线程池.md @@ -0,0 +1,173 @@ +# Android 线程池ThreadPoolExecutor 的使用和封装(kotlin) + +```java +// 传统开启线程方式 +Thread(Runnable { + //to do异步请求 + +}).start() +``` + +**1.使用new Thread()创建线程存在的问题** + +1. 如果在一个list每一个item都创建一个Thread,list量大的话会大量创建Thread,导致内存抖动,GC频繁的回收。要知道,GC的回收是在主线程的,这样会导致卡顿。 + +2. 线程过多,导致各个线程竞争抢夺CPU执行权,线程的频繁切换导致效率的降低。 + +3. ListView的每一个item滑出窗口,线程无法停止也无法控制。 + + +**2.使用线程池的好处** + +1. 重用已经创建的好的线程,避免频繁创建进而导致的频繁GC +2. 控制线程并发数,合理使用系统资源,提高应用性能 +3. 可以有效的控制线程的执行,比如定时执行,取消执行等 + +**3.创建线程池 ThreadPoolExecutor 7个参数** + +- corePoolSize 线程池中核心线程的数量 + +- maximumPoolSize 线程池中最大线程数量,等待队列的任务塞满了之后,才会触发开启非核心线程,直到总线程数达到 maximumPoolSize + +- keepAliveTime 非核心线程的超时时长,当系统中非核心线程闲置时间超过keepAliveTime之后,则会被回收。如果ThreadPoolExecutor的allowCoreThreadTimeOut属性设置为true,则该参数也作用于核心线程的超时时长 + +- unit 第三个参数的单位,有纳秒、微秒、毫秒、秒、分、时、天等 + +- workQueue 线程池中的任务队列,该队列主要用来存储已经被提交但是尚未执行的任务。存储在这里的任务是由ThreadPoolExecutor的execute方法提交来的。这个队列任务塞满了之后,才会触发开启非核心线程 + +- threadFactory 为线程池提供创建新线程的功能,这个我们一般使用默认即可 + +- handler 拒绝策略,当线程无法执行新任务时(一般是由于线程池中的线程数量已经达到最大数或者线程池关闭导致的),默认情况下,当线程池无法处理新线程时,会抛出一个RejectedExecutionException。 + +**4.线程池 ThreadPoolExecutor 的方法** + +1. shutDown() 关闭线程池,不影响已经提交的任务 + +2. shutDownNow() 关闭线程池,并尝试去终止正在执行的线程 + +3. allowCoreThreadTimeOut(boolean value) 允许核心线程闲置超时时被回收 + + +```java + + +import com.orhanobut.logger.Logger +import java.util.concurrent.* + +/*** + * Created by LiangJingJie on 2019/5/16. + * 线程池封装类 + * */ +class ThreadPoolManager private constructor() { + + private var threadPoolMap = hashMapOf() + + /** + * cpu数量 + * */ + private val CPU_COUNT = Runtime.getRuntime().availableProcessors() + + /** + * 核心线程数为手机CPU数量+1 + * */ + private val CORE_POOL_SIZE = CPU_COUNT + 1 + + /** + * 最大线程数为手机CPU数量×2+1 + * */ + private val MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1 + + /** + * 线程活跃时间 秒,超时线程会被回收 + * */ + private val KEEP_ALIVE_TIME: Long = 3 + + /** + * 等待队列大小 + * */ + private val QUEUE_SIZE = 128 + + companion object { + fun getInstance() = SingleHolder.SINGLE_HOLDER + } + + object SingleHolder { + val SINGLE_HOLDER = ThreadPoolManager() + } + + + /** + * @param tag 针对每个TAG 获取对应的线程池 + * @param corePoolSize 线程池中核心线程的数量 + * @param maximumPoolSize 线程池中最大线程数量 + * @param keepAliveTime 非核心线程的超时时长, + * 当系统中非核心线程闲置时间超过keepAliveTime之后,则会被回收 + * 如果ThreadPoolExecutor的allowCoreThreadTimeOut属性设置为true, + 则该参数也作用于核心线程的超时时长 + * @param unit 第三个参数的单位,有纳秒、微秒、毫秒、秒、分、时、天等 + * @param queueSize 等待队列的长度 一般128 (参考 AsyncTask) + * workQueue 线程池中的任务队列, + 该队列主要用来存储已经被提交但是尚未执行的任务。 + 存储在这里的任务是由ThreadPoolExecutor的execute方法提交来的。 + * threadFactory 为线程池提供创建新线程的功能,这个我们一般使用默认即可 + * + * 1.ArrayBlockingQueue:这个表示一个规定了大小的BlockingQueue,ArrayBlockingQueue的构造函数接受一个int类型的数据, + * 该数据表示BlockingQueue的大小,存储在ArrayBlockingQueue中的元素按照FIFO(先进先出)的方式来进行存取。 + * 2.LinkedBlockingQueue:这个表示一个大小不确定的BlockingQueue,在LinkedBlockingQueue的构造方法中可以传 + * 一个int类型的数据,这样创建出来的LinkedBlockingQueue是有大小的,也可以不传,不传的话, + * LinkedBlockingQueue的大小就为Integer.MAX_VALUE + * */ + private fun getThreadPool(tag: String): ThreadPoolExecutor { + var threadPoolExecutor = threadPoolMap[tag] + if (threadPoolExecutor == null) { + threadPoolExecutor = ThreadPoolExecutor( + CORE_POOL_SIZE, + MAXIMUM_POOL_SIZE, + KEEP_ALIVE_TIME, + TimeUnit.SECONDS, + ArrayBlockingQueue(QUEUE_SIZE), + Executors.defaultThreadFactory(), + RejectedExecutionHandler { _, _ -> + Logger.d("$ThreadPoolManager RejectedExecutionHandler----") + } + ) + //允许核心线程闲置超时时被回收 + threadPoolExecutor.allowCoreThreadTimeOut(true) + threadPoolMap[tag] = threadPoolExecutor + } + return threadPoolExecutor + } + + /** + * @param tag 针对每个TAG 获取对应的线程池 + * @param runnable 对应的 runnable 任务 + * */ + fun removeTask(tag: String, runnable: Runnable) { + getThreadPool(tag)?.queue?.remove(runnable) + } + + /** + * @param tag 针对每个TAG 获取对应的线程池 + * @param runnable 对应的 runnable 任务 + * */ + fun addTask(tag: String, runnable: Runnable) { + getThreadPool(tag).execute(runnable) + } + + /** + * @param tag 针对每个TAG 获取对应的线程池 + * 取消 移除线程池 + * */ + + //shutDown():关闭线程池后不影响已经提交的任务 + //shutDownNow():关闭线程池后会尝试去终止正在执行任务的线程 + fun exitThreadPool(tag: String) { + var threadPoolExecutor = threadPoolMap[tag] + if (threadPoolExecutor != null) { + threadPoolExecutor.shutdownNow() + threadPoolMap.remove(tag) + } + } +} +``` + diff --git a/Android开发笔记/Android获取视频封面.md b/Android开发笔记/Android获取视频封面.md new file mode 100644 index 0000000..5adb066 --- /dev/null +++ b/Android开发笔记/Android获取视频封面.md @@ -0,0 +1,27 @@ +```java +// 给定视频的URL +final String url = videoUrl; +// 调用Android的MediaMetadataRetriever获取视频封面 +final MediaMetadataRetriever mmr = new MediaMetadataRetriever(); +new Thread(() -> { + Map headers = new HashMap<>() ; + // 指定header和url + mmr.setDataSource(url, headers); + // 设置截取视频第10秒钟内容 + Long sec = 10L; + // sec转us单位 + Long msec = sec * 1000L; + Long us = msec * 1000L; + + final Bitmap image = mmr.getFrameAtTime(us, MediaMetadataRetriever.OPTION_CLOSEST_SYNC); + // 更新imageview显示图片 + runOnUiThread(() -> { + ImageView tv = findViewById(R.id.imageView); + tv.setImageBitmap(image); + }); + // 释放mmr,断开连接 + mmr.release(); +}).start(); +``` + +HTTP视频请求Range的计算方法 diff --git a/Android开发笔记/DanDanPlay.md b/Android开发笔记/DanDanPlay.md new file mode 100644 index 0000000..9913b9a --- /dev/null +++ b/Android开发笔记/DanDanPlay.md @@ -0,0 +1,16 @@ +app : 程序的主页面(MainActivity),程序的启动页面(SplashActivity) + +AppConfig模块 :负责App的功能设置 + +**播放器显示控制器逻辑:** + +DanDanVideoPlayer -> onKeyDown检测KeyEvent事件类型 -> {1、音量加 2、音量减 3、其他 : 触发控制View} + +DanDanVideoPlayer -> 触摸检测 检测TouchEvent事件类型 -> {左上下滑动:亮度 右上下滑动:音量 横向滑动:视频进度} + +自动更新功能:BaseApplication(应用启动时的单例) => EMASHelper(阿里巴巴EMAS应用研发平台) => 发起弹窗和下载 + +**SMB文件浏览逻辑:** + +位置:local_component/ui/fragment/media/MediaFragment + diff --git a/Android开发笔记/DanDanPlay主页显示.md b/Android开发笔记/DanDanPlay主页显示.md new file mode 100644 index 0000000..88706d2 --- /dev/null +++ b/Android开发笔记/DanDanPlay主页显示.md @@ -0,0 +1,13 @@ +# DanDanPlay主页显示 + +## HomeFragmentViewModel + +**位置:**anime_component/ui/fragment/home/HomeFragment + +**核心:** 首页的显示Fragement + +# MediaFragment + +**位置:**local_component/ui/fragment/meda/MediaFragment + +核心:主页媒体的显示Fragement \ No newline at end of file diff --git a/Android开发笔记/Image/image-20230221221558825.png b/Android开发笔记/Image/image-20230221221558825.png new file mode 100644 index 0000000..b74ec9b Binary files /dev/null and b/Android开发笔记/Image/image-20230221221558825.png differ diff --git a/Android开发笔记/Image/image-20230221223742943.png b/Android开发笔记/Image/image-20230221223742943.png new file mode 100644 index 0000000..ee0fc2a Binary files /dev/null and b/Android开发笔记/Image/image-20230221223742943.png differ diff --git a/Android开发笔记/Image/image-20230221223834839.png b/Android开发笔记/Image/image-20230221223834839.png new file mode 100644 index 0000000..af731db Binary files /dev/null and b/Android开发笔记/Image/image-20230221223834839.png differ diff --git a/Android开发笔记/Kotlin findViewById用法和省略方法.md b/Android开发笔记/Kotlin findViewById用法和省略方法.md new file mode 100644 index 0000000..799d421 --- /dev/null +++ b/Android开发笔记/Kotlin findViewById用法和省略方法.md @@ -0,0 +1,61 @@ +# Kotlin 操作Layout控件 + +在Android Acitivity开发中,传统的java开发中findviewbyid。在kotlin中,有两种写法都可以操作layout控件。 + +## 一、传统写法(不推荐) + +​ 不推荐的原因主要是麻烦,满屏幕都是findViewById,非常的繁琐。 + +```kotlin +package com.geek.motion + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.TextView + +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + var textView = findViewById(R.id.textView) + textView.setText("Hello Kotlin") + } +} +``` + +## 二、省略写法(推荐) + +​ 下面采用的是省略写法,注意需要引入import kotlinx.android.synthetic.main.activity_main.* + +```kotlin +package com.geek.motion + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + textView.text = "Hello kotlin" + } +} +``` + +​ 如果在引用import kotlinx.android.synthetic.main.activity_main.*时报错,注意在build.gradle中,添加:**'kotlin-android-extensions'** + +```shell +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' + // 添加 + id 'kotlin-android-extensions' +} +android { + compileSdk 32 + ... +``` + diff --git a/Android开发笔记/Kotlin基本语法笔记.md b/Android开发笔记/Kotlin基本语法笔记.md new file mode 100644 index 0000000..cc83e7f --- /dev/null +++ b/Android开发笔记/Kotlin基本语法笔记.md @@ -0,0 +1,26 @@ +```kotlin +Unit : 相当于JAVA的void +``` + +kotlin中when的用法 + +```kotlin +fun foo(value: Int): String { + return when (value) { + 0 -> { + "Zero" + } + 1 -> { + "One" + } + 2 -> { + "Two" + } + else -> { + "Other" + } + } +} + +``` + diff --git a/Android开发笔记/Kotlin测量经过的时间.md b/Android开发笔记/Kotlin测量经过的时间.md new file mode 100644 index 0000000..6a03a88 --- /dev/null +++ b/Android开发笔记/Kotlin测量经过的时间.md @@ -0,0 +1,66 @@ +# Kotlin测量经过的时间 + +## 一、使用 `System.nanoTime()` 功能 + +在 Kotlin 中测量程序运行时间的推荐方法是 `System.nanoTime()`,它以纳秒精度返回 JVM 时间源的当前值。 + +```kotlin +fun main() { + val begin = System.nanoTime() + /* 代码开始 */ + // 休眠 2 秒 + Thread.sleep(2000) + /* 代码结束 */ + val end = System.nanoTime() + println("Elapsed time in nanoseconds: ${end-begin}") +} +``` + +## 二、使用 `System.currentTimeMillis()` 功能 + +您还可以使用 `System.currentTimeMillis()`,但结果可能不是那么准确。 + +```kotlin + +fun main() { + val begin = System.currentTimeMillis() + /* 代码开始 */ + // 休眠 2 秒 + Thread.sleep(2000) + /* 代码结束 */ + val end = System.currentTimeMillis() + println("Elapsed time in milliseconds: ${end-begin}") +} +``` + +这是使用的替代解决方案 `Instant.now()` 内部使用 `System.currentTimeMillis()`. + +```kotlin +import java.time.Instant + +fun main() { + val begin = Instant.now().toEpochMilli() + /* 代码开始 */ + // 休眠 2 秒 + Thread.sleep(2000) + /* 代码结束 */ + val end = Instant.now().toEpochMilli() + println("Elapsed time in milliseconds: ${end-begin}") +} +``` + +## 三.使用 `Date.getTime()` 功能 + +```kotlin +import java.util.Date + +fun main() { + val begin = Date().time + /* 代码开始 */ + // 休眠 2 秒 + Thread.sleep(2000) + /* 代码结束 */ + val end = Date().time + println("Elapsed time in milliseconds: ${end-begin}") +``` + diff --git a/Android开发笔记/Smb开发笔记.md b/Android开发笔记/Smb开发笔记.md new file mode 100644 index 0000000..6d509d1 --- /dev/null +++ b/Android开发笔记/Smb开发笔记.md @@ -0,0 +1,122 @@ +## Android Smb开发笔记 + +### 一、SMB的基本操作 + +Android的SMB开发会用到jcifs这个库。这个库提供了SMB的底层操作功能。 + +根据URI打开一个SMB。 + +```java +// 指定SMB的路径 +String uri = "smb://administrator:351002@192.168.31.52/H/琅琊榜 全54集 1080P/"; +// 网络的相关操作必须通过新线程的方式启动,否则会触发Android的错误 +new Thread(new Runnable() { + @Override + public void run() { + try { + // 根据uri打开SmbFile + SmbFile smbFile = new SmbFile(uri); + String fileName = smbFile.getName(); + Log.d("Test", fileName); + // 控制台打印SMB路径下的文件 + try{ + String[] FileList = smbFile.list(); + for (String s : FileList) { + Log.d("Test", s); + } + }catch (SmbException e){ + e.printStackTrace(); + } + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } +}).start(); +``` + +### 二、SMB转HTTP + +当我们把SMB的Uri提供给播放器后,播放器会请求GET视频。对于一个完整的视频,Http的请求如下所示。 + +如果我们在解析请求头的时候没有收到请求的范围信息,那么默认就是返回全部的内容。 + +```shell +GET /smb/192.168.31.52/I/XXX.mp4 HTTP/1.1 +User-Agent: ExoPlayerTime/1.0 (Linux;Android 12) ExoPlayerLib/2.7.1 +Accept-Encoding:identity +Host: 127.0.0.1:2222 +Connection: Keep-Alive +``` + +当我们拖动进度条的时候,此时视频不是从0开始播放,所以视频播放器会请求包含Range的信息: + +```Shell +GET /smb/192.168.31.52/I/XXX.mp4 HTTP/1.1 +User-Agent: ExoPlayerTime/1.0 (Linux;Android 12) ExoPlayerLib/2.7.1 +Range: bytes=1207598076- +Accept-Encoding:identity +Host: 127.0.0.1:2222 +Connection: Keep-Alive +``` + +上述情况下,如果我们收到包含Range信息的请求时,返回的时候就需要额外指定一些信息。HTTP的返回有如下的规则: + +```Java +// 如果用户拖动了进度条,那么HttpRequest就会包含Range信息 +// 1.此时contentLength = end - st, 需要返回Content-Length:头 +"Content-Length: " + contentLength + "\r\n" +// 2.此时请求的是部分的信息,所以返回的Responce的类型是206,表示部分内容 +HttpStatus.PARTIAL_CONTENT = 206 +``` + + + +```Java +// 获取文件长度bytes +long contentLen = file.length(); +// 从文件获得输入流 +InputStream contentIn = file.getInputStream(); +// 检查输入数据流是否正常 +if (contentLen <= 0 || contentIn == null) { + httpReq.returnBadRequest(); + return; +} +// 创建Http返回请求 +HTTPResponse httpRes = new HTTPResponse(); +// 指定视频数据格式 +httpRes.setContentType("video/mpeg4"); + +if(startFrom == 0 && endAt == 0){ + // 请求没有范围信息则返回全部内容,状态OK(200)表示全部内容 + httpRes.setStatusCode(HTTPStatus.OK); +}else if(startFrom > 0){ + // 如果是包含RangeCotent,则需要返回PARTIAL_CONTENT(206) + httpRes.setStatusCode(HTTPStatus.PARTIAL_CONTENT); + httpRes.setContentRange(startFrom,endAt, contentLen); +} +// 设置内容总长度 +httpRes.setContentLength(contentLen); +// 指定内容数据流 +httpRes.setContentInputStream(contentIn); +// HttpReq提交数据 +httpReq.post(httpRes); +contentIn.close(); +``` + +HTTP 视频请求 + +```Java +// 已知信息 +File_length = 2794939639 +File_Range_st = bytes=2792308814 +// 分析 +st = 2792308814 +// 由于文件长度是2794939639,所以换算的索引是0~2794939639-1 +ed = 2794939639 - 1 +content_lenght = ( ed - st + 1 )= File_length - 1 - st + 1 += ed - st + + + +``` + diff --git a/Flutter/Flutter-pubspec.yaml.md b/Flutter/Flutter-pubspec.yaml.md new file mode 100644 index 0000000..ac73596 --- /dev/null +++ b/Flutter/Flutter-pubspec.yaml.md @@ -0,0 +1,16 @@ +#### 依赖 git repository + +依赖 Github 上的一个插件: + +```text +dependencies: + bloc: + git: + url: https://github.com/felangel/bloc.git + ref: bloc_fixes_issue_110 + path: packages/bloc +``` + +- url:github 地址 +- ref:表示git引用,可以是 **commit hash, tag** 或者 **branch** +- path:如果 git 仓库中有多个软件包,则可以使用此属性指定软件包 \ No newline at end of file diff --git a/Flutter/Flutter常见细节问题.md b/Flutter/Flutter常见细节问题.md new file mode 100644 index 0000000..6d6f9f8 --- /dev/null +++ b/Flutter/Flutter常见细节问题.md @@ -0,0 +1,22 @@ +# Flutter常见问题 + +基本上flutter安装官方教程进行环境安装即可,但是有些细节会导致安装出现问题。常见问题如下: + +## 一、flutter doctor长时间等待问题 + +​ 产生的原因:1) Powershell没有采用管理员权限运行 2) 没有采用国内镜像源 + +​ 1、先配置国内镜像仓库源: + +```shell +# 参考网址:https://flutter.cn/community/china +# 下面命令不一定生效,可以采用手动的方式在环境变量中增加变量名和变量值 +# 配置默认国内镜像源 +$env:PUB_HOSTED_URL="https://pub.flutter-io.cn"; +$env:FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn" +# 配置清华源 +$env:PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub"; +$env:FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter" +``` + +​ 2、采用管理员身份运行Powershell或者cmd \ No newline at end of file diff --git a/Markdown高级用法/Markdown高级用法.md b/Markdown高级用法/Markdown高级用法.md new file mode 100644 index 0000000..59c3235 --- /dev/null +++ b/Markdown高级用法/Markdown高级用法.md @@ -0,0 +1,6 @@ +我是逐浪新宋我是逐浪圆体我是逐浪花体我是逐浪像素字我是逐浪立楷我是红色我是绿色我是黄色我是蓝色我是紫色我是浅灰色我是尺寸我是尺寸我是逐浪立楷,绿色,尺寸为5 作者:字库大师程序员发哥 https://www.bilibili.com/read/cv5975926/ 出处:bilibili我是逐浪新宋我是逐浪圆体我是逐浪花体我是逐浪像素字我是逐浪立楷我是红色我是绿色我是黄色我是蓝色我是紫色我是浅灰色我是尺寸我是尺寸我是逐浪立楷,绿色,尺寸为5 作者:字库大师程序员发哥 https://www.bilibili.com/read/cv5975926/ 出处:bilibili + + + +字体大小size=10 + diff --git a/Markdown高级用法/example.md b/Markdown高级用法/example.md new file mode 100644 index 0000000..76e1541 --- /dev/null +++ b/Markdown高级用法/example.md @@ -0,0 +1,422 @@ +--- + +--- + +# Example for OneDark Theme + +[toc] + +## Headers + +### h3 + +Markdown is a lightweight markup language with plain-text-formatting syntax. Its design allows it to be converted to many output formats, but the original tool by the same name only supports HTML. Markdown is often used to format readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor. + +#### h4 + +Since the initial description of Markdown contained ambiguities and unanswered questions, the implementations that appeared over the years have subtle differences and many come with syntax extensions. + +##### h5 + +In MediaWiki, it is implemented in the currently unmaintained MarkdownExtraParser parser function extension + +###### h6 + +Implementations of Markdown are available for over a dozen programming languages. + +## Quote + +> Most UI components including tooltip, dialog and buttons are painted by HTML. And you only need to change those part when you find the UI components are incompatible with your editor theme after finishing steps above. HTML files from the toolkit includes most common UI components for you to easily debug. + +## Font Style + +**Bold**, *italic*, ~~delete~~ + +underline, [Link](typora.io) + +H~2~O, E=mc^2^ + +colored text, ==highlight== + +emoji: :smile: + +- [ ] checkbox + +## Codeblock + +```python +# hello_world.py +class HelloWorld(): + def __init__(self): + self.text='hello world!' + + def show(self,word): + print(f'{word}, {self.text}') + +test=HelloWorld() +test.show() +``` + +Run terminal then enter: `python hello_world.py` + +## KBD + +* bold:Ctrl/Command + B + +* italic:Ctrl/Command + I + +## MathJax + +Given two populations, $x_1$ and $x_2$ , with logistic dynamics, the Lotka–Volterra formulation adds an additional term to account for the species' interactions. Thus the competitive Lotka–Volterra equations are: +$$ +\begin{cases} +\cfrac{dx_1}{dt}=r_1x_1\bigg(1-\cfrac{x_1+\alpha_{12} x_2}{K_1}\bigg)\\ +\cfrac{dx_2}{dt}=r_2x_2\bigg(1-\cfrac{x_2+\alpha_{21} x_1}{K_2}\bigg) +\end{cases} +$$ +Here, $\alpha_{12}$ represents the effect species 2 has on the population of species 1 and $\alpha_{21}$represents the effect species 1 has on the population of species 2. + +## Order + +1. first item +2. second item + 1. first item + 2. second item +3. third item + +--- + +* first item +* second item + * first item + * first item +* fourth item + +## Table + +| Cinderella | 11 | glass | transparent | +| :----------- | ---: | :---------- | :---------- | +| Name | Size | Material | Color | +| All Business | 9 | leather | brown | +| Roundabout | 10 | hemp canvas | natural | + +## Footnote + +You can create footnotes like this[^fn1] and this[^fn2]. + +[^fn1]: Here is the **text** of the first ***\*footnote\****. +[^fn2]: Here is the **text** of the second ***\*footnote\****. + +## Image, Video + +Cosmos08 + +