我正在开发一个读取电子书(以epub格式)的Android应用程序,现在我正在使用Paul Siegeman的epublib库,它实际上是一个非常好的epub阅读器,但它有一些限制,例如我需要的那个,你不能水平移动页面(因为你读一本真正的书)所以我需要自己实现它,但我被卡住了.
实际读取epub然后将其放入webview的方法是下一个:
private void openEpub(String bookFilename){
WebView webView = (WebView) findViewById(R.id.webView);
nl.siegmann.epublib.domain.Book book=null;
try {
book = (new EpubReader()).readEpub(new FileInputStream(Environment.getExternalStorageDirectory().getPath() + "/" + bookFilename));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String baseUrl = Environment.getExternalStorageDirectory().getPath() + "/";
String data=null;
try {
data = new String(book.getContents().get(1).getData());
} catch (IOException e) {
e.printStackTrace();
}
webView.loadDataWithBaseURL(baseUrl, data, "text/html", "UTF-8", null);
}
Run Code Online (Sandbox Code Playgroud)
所以当你看到我在webview中显示电子书时,据我所知,webview给出的唯一滚动可能性是上/下.
我正在考虑拆分getData()返回的html字符串,并将webview加载到页面中并使用viewpager逐个显示它们,但是如何根据屏幕大小正确分割html?
你觉得这个想法我是正确的吗?任何其他解决方案显示从左到右/从右到左(分页)或任何其他"免费或廉价"库的epub?(我试过PageTurner,它真的很棒,但商业版对我来说太贵了)
我无法调试我的应用程序,因为在设置断点和调试器停止之后,它会在两三秒后突然停止并且应用程序无缘无故退出。
我已经尝试在不同的位置设置断点以确保没有其他后台进程干扰它,例如在启动活动的 onCreate 开始时,但同样发生,调试器按预期停止,几秒钟后应用程序退出并调试会话意外结束。
我已经尝试将 Android Studio 和 Gradle 更新到最新版本(我的 AS 是 3.6.1)和 Gradle 5.6.4(插件版本是 3.6.1),但无济于事。还尝试卸载/重新安装应用程序也无济于事,最后我在 Android Studio 中尝试了“使缓存无效并重新启动”选项,但它都不起作用。
我无法调试,也不知道还能尝试/做什么。
我的手机是华为 Mate 20 Lite,我也试过重启手机,但没有成功。
这是调试器停止和应用程序退出后的“Logcat”(应用程序数字为 com.mycompany.myapp):
2020-03-06 19:20:39.719 1408-1432/? E/WindowManager: icon is null!!
2020-03-06 19:20:39.722 1408-1432/? E/WindowManager: icon is null!!
2020-03-06 19:20:39.724 1408-1432/? E/WindowManager: icon is null!!
2020-03-06 19:20:39.777 2462-5966/? E/HwNaturalBase: [Binder:2462_10]: clearDataByOwner ignore: Found null values with the given ownerPkgName is[com.mycompany.myapp].
2020-03-06 19:20:39.778 2334-4531/? E/AwareLog: GameSdkConfigReader: GameSdkLog: idNameMap: null
2020-03-06 19:20:39.809 847-861/? E/AwareLog: iawared: GetFileContent open /proc/14267/task/14277/cpuset fail errno(2)! …Run Code Online (Sandbox Code Playgroud) 我正在构建一个将由Angular 6客户端使用的.Net Web Api,但由于任何原因,我无法使其在我的开发环境中工作.
我从一个非常简单的Web Api开始,它只是返回一个字符串(在前端和后端测试目的之间进行通信):
// GET: api/Login
public IEnumerable<string> Get()
{
return new string[] { "Now it works!" };
}
// POST: api/Login
public void Post([FromBody]string value)
{
string strTest = "I'm doing just nothing";
}
Run Code Online (Sandbox Code Playgroud)
然后在我的Angular 6应用程序中,我有一个带有以下帖子请求的方法:
return this.http.post<any>(`http://localhost:9810/api/Login`, { username, password })
.pipe(map(user => {
// login successful if there's a jwt token in the response
if (user && user.token) {
// store user details and jwt token in local storage to keep user logged in …Run Code Online (Sandbox Code Playgroud) 我正在使用一个很好的Bootstrap 4 css主题,它覆盖了一个非常漂亮的颜色的默认主题,但是我无法通过css的根名称"引用"颜色.
让我们更好地解释,Bootstrap有一些根颜色,名称是"成功","危险","黑暗","光"等等(以及自定义主题css模板),当然 - 他们有一个十六进制表示和我想将其中一种颜色应用于链接悬停,通过其根名称而不是其十六进制代码来调用它.
为了更清楚,我希望能够做下一个事情:
.dropdown-menu > a:hover {
color: success; /*or dark or danger or whatever */
}
Run Code Online (Sandbox Code Playgroud)
这样,如果我将来更改模板,所有颜色将自动调整为新模板值,并且所有应用程序外观将与新的常规模板方面保持"和谐".
我不确定使用纯css是否可行,但也许有一种解决方法.
如你所见,我的目标是能够拥有尽可能多的颜色,因为我可以通过名称引用(让我们说动态而不是静态使用十六进制),所以如果我更改bootstrap css模板,所有颜色都会自动调整为新的模板值.
任何帮助/想法?
我正在开发一个应用程序,它使用以下库创建 x264 视频:
com.arthenica:mobile-ffmpeg-full:4.2.2.LTS
Run Code Online (Sandbox Code Playgroud)
但结果 apk 文件太大(~71mb),所以我试过:
com.arthenica:mobile-ffmpeg-min-gpl:4.2.2.LTS
Run Code Online (Sandbox Code Playgroud)
这样,由于库只下载了几个编解码器 - 包括我需要的编解码器 - apk 大小减少到 ~49mb,好得多,但对我来说仍然太大,所以我需要知道是否有任何你知道减少apk大小的更好方法,因为人们通常拒绝下载这么大的应用程序
关于应用程序的其余部分(可绘制、资源等),它们得到了很好的优化,因为如果我删除这个库并重建,应用程序的大小会下降到 10mb
我正在阅读这个问题: FFMPEG Android 库增加大小
用户 SR 建议将所有 cpu 架构模型压缩在一个存档文件中,并根据应用程序目录中的 cpu 模型提取目标 cpu lib 并从那里加载 ffmpeg,但我真的不知道该怎么做。
我正在检查我的应用程序的文件夹结构,并注意到有关于 ffmpeg lib 的下一个文件夹:
arm64-v8a => ~16mb
armeabi-v7a => ~29mb
x86 => ~17mb
x86_64 => ~21mb
Run Code Online (Sandbox Code Playgroud)
但不确定我是否可以删除其中任何一个,正如您所看到的 armeabi-v7a 是最大的。
我在我的应用程序中包含了一个 Bootstrap 主题。我已将文件复制到 src 文件夹(与 style.css 相同级别)并将其添加为 angular.json 中的最后一个 css,如下所示:
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/WFRH-Web",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/web.config"
],
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/bootstrap-select/dist/css/bootstrap-select.min.css",
"src/theme_minco.min.css"
Run Code Online (Sandbox Code Playgroud)
并且样式在开发模式下正常工作,但在部署我的应用程序后它们不起作用。
我用于部署的步骤是:
1) ng build --prod
2) firebase deploy
Run Code Online (Sandbox Code Playgroud)
我也试过在styles.css中使用include,只在angular.json中保留styles.css,如下所示:
@import "theme_minco.min.css";
Run Code Online (Sandbox Code Playgroud)
无济于事,因为它也不起作用(它仅适用于开发人员)。
请问有什么帮助吗?
我的应用程序推送每日通知(这是正常工作),但设备重启后通知不会再次触发。
我正在尝试设置一个 BroadcastReceiver 来监听 BOOT_COMPLETED 无济于事。
AndroidManifest.xml:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
...
<receiver android:name=".helpers.notification.AlarmRebootReceiver"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
广播接收器:
public class AlarmRebootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context oContext, Intent intent) {
try {
Intent notificationIntent = new Intent("android.media.action.DISPLAY_NOTIFICATION");
notificationIntent.addCategory("android.intent.category.DEFAULT");
String notificationMessage = TMLocale.getStringResourceByName("reminder_newthought");
String notificationTitle = TMLocale.getStringResourceByName("app_name");
TMNotification.Notify(notificationTitle, notificationMessage, Enum.ArtAndWordsNotification.NEWTHOUGHT, oContext);
TMNotification.cancelNewThoughtAlarm(oContext);
scheduleNewThoughtAlarm(oContext);
} catch (Exception e) {
ExceptionHandler.logException(e);
}
}
private void scheduleNewThoughtAlarm(Context oContext) {
Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = …Run Code Online (Sandbox Code Playgroud) 我正在开发一个多模块应用程序 - 也有明确的关注点分离 - 使用 Kotlin,我试图在其中实现 Hilt - 也解耦 - 并且我在从模块访问应用程序类时遇到问题。
首先,我的应用程序的结构:
project
|- App
|- Common
|- Core
|- DTO
|- Repository
Run Code Online (Sandbox Code Playgroud)
模块之间的关系(模块可见性):
Project
|
|- App
| |- Common
| |- DTO
| |- Core
|
|- Common
| |- DTO
|
|- Core
| |- Common
|
|- DTO
|
|- Repository
| |- Common
| |- DTO
Run Code Online (Sandbox Code Playgroud)
好吧,所有模块在其相应的 build.gradle 中都有所需的 Hilt 依赖项和插件。
我有一个 AppSettings 类,其中包含表示所有应用程序配置(如颜色)的常量,以及一个上下文和一个单例 SQLite 数据库实例。
到目前为止,我以静态方式访问所有常量和上下文,一切都工作正常,并且我使用 WeakReference 作为上下文以避免内存泄漏,但有人建议使用这种方式的上下文不利于测试,解耦并使用 DI,这就是我开始使用 Hilt 的原因。
我不知道我的实现是否正确,因为我是 Hilt 的新手,这让我很头疼,但让我们开始吧: …
我正在使用 Android Studio 开发 Android 应用程序,几乎每当我尝试检查变量时,调试器都会卡在“评估”上。
我怀疑这是在尝试调试后台任务时发生的(这也是无意义的),但事实是现在我正在尝试调试和检查主线程中的变量,所以现在是我被卡住了。
我尝试了 Stack Overflow 上找到的一些解决方案,但没有成功,如下所示:
正如帖子所建议的那样,我刚刚在设置中禁用了“启用集合类的替代视图”,但什么也没发生。
我怎样才能恢复正确调试和检查变量的能力?
我使用以下非常简单的 Program.cs 创建了一个 AZ 函数项目:
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
host.Run();
public partial class Program { }
Run Code Online (Sandbox Code Playgroud)
以及下一个 -dummy- 函数:
[Function("RabbitMQFunction")]
public void Run
(
[RabbitMQTrigger("EmailQueue", ConnectionStringSetting = "xxx:xxx:services:infraestructure:emailservice:rabbitmq")] string item,
FunctionContext context)
{
var logger2 = context.GetLogger("RabbitMQFunction");
logger2.LogInformation($"Output message created at {DateTime.Now}");
}
Run Code Online (Sandbox Code Playgroud)
本地.settings.json:
{
"ConnectionStrings": {
"xxx:xxx:services:infraestructure:emailservice:rabbitmq": "connection_string"
},
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
Run Code Online (Sandbox Code Playgroud)
主机.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
} …Run Code Online (Sandbox Code Playgroud) 我是 Docker 新手,首先,我试图完成一项基本任务,将 .Net Core 3.1 Web Api 进行 dockerize 并从命令行运行它(而不是从它实际工作的 Visual Studio 运行)。
\n\n我使用以下 Dockerfile 和以下命令创建项目映像:
\n\ndocker build -t concepttest_crud1 .\nRun Code Online (Sandbox Code Playgroud)\n\nDockerfile(由 Visual Studio 创建):
\n\nFROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base\nWORKDIR /app\nEXPOSE 80\nEXPOSE 443\n\nFROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build\nWORKDIR /src\nCOPY ["Gfi_ConceptTest_CRUD1/Gfi_ConceptTest_CRUD1.csproj", "Gfi_ConceptTest_CRUD1/"]\nRUN dotnet restore "Gfi_ConceptTest_CRUD1/Gfi_ConceptTest_CRUD1.csproj"\nCOPY . .\nWORKDIR "/src/Gfi_ConceptTest_CRUD1"\nRUN dotnet build "Gfi_ConceptTest_CRUD1.csproj" -c Release -o /app/build\n\nFROM build AS publish\nRUN dotnet publish "Gfi_ConceptTest_CRUD1.csproj" -c Release -o /app/publish\n\nFROM base AS final\nWORKDIR /app\nCOPY --from=publish /app/publish .\nENTRYPOINT ["dotnet", "Gfi_ConceptTest_CRUD1.dll"]\nRun Code Online (Sandbox Code Playgroud)\n\n4)我使用以下命令运行我的图像:
\n\ndocker run …Run Code Online (Sandbox Code Playgroud) 我试图在视频上重叠动画 gif,但没有成功。
我的目标是:
我在这方面取得的最大成就是 gif 用缩放过滤器覆盖了整个视频,并且循环播放直到视频结束(但我猜这不是最好的方式)。
关于循环,我知道我可以在叠加中使用 -ignore_loop 0 gif 过滤器参数和 shortest=1 但这样它不起作用所以我最终得到了 -frames:v 900(我的视频是 30fps 和 30sec 长所以 900 是帧)。
我最重要的问题是我无法保持 gif 的透明度,我尝试过的一切都没有成功。
这是我的带参数的 ffmpeg 命令,所以我希望任何人都可以提供帮助(我使用的是 ffmpeg 4.1)。
ffmpeg -y
-i videoin.mp4
-i anim01.gif
-filter_complex [1:v]scale=1080:1920[ovrl] [0:v][ovrl]overlay=main_w-overlay_w:main_h-overlay_h
-frames:v 900
-codec:a copy
-codec:v libx264
-preset ultrafast
video.mp4
Run Code Online (Sandbox Code Playgroud) 我在 xml 中有一个 RecyclerView,如下所示:
<LinearLayout
android:id="@+id/llTestMenuMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:id="@+id/rv" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
并使用它来显示动态按钮列表,如下所示:
int buttonFontSize = 20;
RecyclerView rv = findViewById(R.id.rv);
LinearLayoutManager llm = new LinearLayoutManager(this);
rv.setLayoutManager(llm);
adapter = new RVAdapter_ButtonList(tests, null, this, buttonFontSize);
rv.setAdapter(adapter);
rv.setVisibility(View.VISIBLE);
Run Code Online (Sandbox Code Playgroud)
一切都工作正常,但现在所有垂直显示的按钮都将水平显示并分组到类别中,所以我需要动态创建 RecyclerViews,我从一个简单的例子开始,只有一个没有成功,如下显示空白屏幕:
int buttonFontSize = 20;
RecyclerView rv = new RecyclerView(this);
RecyclerView.LayoutParams params = new
RecyclerView.LayoutParams(
RecyclerView.LayoutParams.MATCH_PARENT,
RecyclerView.LayoutParams.WRAP_CONTENT
);
rv.setLayoutParams(params);
LinearLayout llTestMenuMain = findViewById(R.id.llTestMenuMain);
llTestMenuMain.addView(rv);
LinearLayoutManager llm = new LinearLayoutManager(this);rv.setLayoutManager(llm);
adapter = new RVAdapter_ButtonList(tests, null, this, buttonFontSize);
rv.setAdapter(adapter);
rv.setVisibility(View.VISIBLE); …Run Code Online (Sandbox Code Playgroud) android ×7
angular ×2
c# ×2
css ×2
debugging ×2
ffmpeg ×2
.net ×1
.net-core ×1
animated-gif ×1
api ×1
apk ×1
asp.net-core ×1
bootstrap-4 ×1
cors ×1
dagger-2 ×1
dagger-hilt ×1
deployment ×1
docker ×1
dockerfile ×1
epub ×1
html ×1
kotlin ×1
overlap ×1
pagination ×1
reboot ×1
size ×1
transparency ×1
watch ×1
webview ×1
xunit ×1