TimeUnit.DAYS.convert(
Math.abs(
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").parse("30-03-2020 00:00:00").getTime() -
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").parse("1-03-2020 00:00:00").getTime()
),
TimeUnit.MILLISECONDS)
Run Code Online (Sandbox Code Playgroud)
结果是 28,而它应该是 29。
时区/位置可能是问题吗?
我有一个加载.epub文件的阅读器应用程序,通常我对选择没有任何问题,最近我已经集成了固定布局.epub文件,但我遇到了一个问题:当我有一个包含一行的框时,选择工作正常,但是当框中包含几行,意思是几行<p></p>,我无法从框中选择单个单词.在选择时,整个框被选中,如屏幕截图所示.当我.epub在iBooks上尝试相同的文件时,选择在所有文本上都能正常工作.知道如何解决这个问题吗?
这是加载文件的代码UiWebView.
NSString *contents = [NSString stringWithContentsOfFile:itemPath encoding:NSUTF8StringEncoding error:nil];
if (!contents) {
contents = [NSString stringWithContentsOfFile:itemPath encoding:NSASCIIStringEncoding error:nil];
}
[readingWebView loadHTMLString:contents baseURL:baseURL];
Run Code Online (Sandbox Code Playgroud)


Hy,我有一个音频,我需要使用Web服务和其他输入发送.在做了一些搜索后,我明白我无法使用xml soap消息发送nsdata,所以我下载了AFHTTPRequest类并在互联网上关注了示例,但它无法正常工作.这是我正在使用的Web服务:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<addlocation2 xmlns="http://tempuri.org/">
<userid>int</userid>
<name>string</name>
<voicemsg>base64Binary</voicemsg>
</addlocation2>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
这是我用来发送数据和其他参数的代码:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4a"];
NSData *audio = [NSData dataWithContentsOfFile:filePath];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSString *URLString = @"http://host.com/Websr/Service.asmx?op=addlocation2";//[WebService getAudioURL];
NSDictionary *parameters = @{@"userid": @2,
@"name": @"usertest",
};
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", @"audio/m4a", nil];
[manager POST:URLString parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
if (audio) {
[formData appendPartWithFileData:audio name:@"voicemsg" fileName:[NSString stringWithFormat:@"test.m4a"] mimeType:@"audio/m4a"];
}
} …Run Code Online (Sandbox Code Playgroud) 我能够使用以下方法获取所选文本:
webview.evaluateJavascript("(function(){return window.getSelection().toString()})()",
new ValueCallback<String>()
{
@Override
public void onReceiveValue(String value)
{
selected = value;
Log.v(TAG, "SELECTION:" + value);
}
}
);
Run Code Online (Sandbox Code Playgroud)
我检测用当由所述检测到的运动事件的第一选择onTouchEvent是ACTION_UP.
webview.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if(event.getAction() == MotionEvent.ACTION_UP)
{
//webview started selection a word
}
}
});
Run Code Online (Sandbox Code Playgroud)
我的问题是能够使用处理程序检测选择何时更改.不幸的是ACTION_MOVE,ACTION_DOWN在使用默认选择处理程序更改选择时未调用.
请注意,当我使用该ActionMode CallBack功能时,默认选择停止工作.
那里,
我的epub阅读器有问题,它正确显示所有内容,但它没有捕获css文件中的嵌入字体.
当我在其他阅读器上运行相同的文件时,显示嵌入的字体,但是当我在其中一个浏览器上运行html文件时,如firefox,它显示与我的应用程序相同的结果,并且它不显示嵌入的字体.
这是一个示例html内容:
<html dir="rtl" xml:lang="ar" lang="ar" xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=1332,height=794" />
<title>the-title-3</title>
<link href="css/idGeneratedStyles.css" rel="stylesheet" type="text/css" />
</head>
<body id="the-title-3" lang="en-GB" xml:lang="en-GB" style="width:1332px;height:794px">
<div id="_idContainer003">
<img class="_idGenObjectAttribute-1 _idGenObjectAttribute-2" src="image/inner_cover_and_credits_page.jpg" alt="" />
</div>
<div id="_idContainer004">
<div style="width:11599.37px;height:2993.39px;position:absolute;top:0px;left:0px;-webkit-transform-origin: 0% 0%; -webkit-transform: translate(0px,3.93px) rotate(0deg) scale(0.05);transform-origin: 0% 0%; transform: translate(0px,3.93px) rotate(0deg) scale(0.05);">
<p class="Basic-Paragraph ParaOverride-1"><span id="_idTextSpan000" class="CharOverride-1" style="position:absolute;top:13.65px;left:3168.24px;">?????? ???????? ?? ???? </span></p>
<p class="Basic-Paragraph ParaOverride-1"><span id="_idTextSpan001" class="CharOverride-1" style="position:absolute;top:733.65px;left:831.71px;">											???????</span></p>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是相应的css文件:
@font-face {
font-family:"Futura Lt …Run Code Online (Sandbox Code Playgroud) Hy,我在longClick上的webview选择有问题.我已经有了一个在longClick上启动的自定义菜单的实现.但默认菜单也会启动.我正在尝试自定义默认菜单,但我不知道如何捕获项目上的用户点击.我尝试过以下操作,但菜单正在变为垂直并隐藏选择,因此我无法选择更多单词或更改选择.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
/*
public void inflate (int menuRes, Menu menu)
Inflate a menu hierarchy from the specified XML resource. Throws InflateException if there is an error.
Parameters
menuRes : Resource ID for an XML layout resource to load (e.g., R.menu.main_activity)
menu : The Menu to inflate into. The items and submenus will be added to this Menu.
*/
inflater.inflate(R.menu.menu, menu);
}
@Override
public boolean …Run Code Online (Sandbox Code Playgroud) 我使用以下代码加载电子书的html内容,其中templateString包含连接到主文件中的样式表和图像的html内容。
String itemURL = "file://" + itemPath;
testWV.loadDataWithBaseURL(itemURL, templateString, "text/html", "UTF-8", "about:blank");
Run Code Online (Sandbox Code Playgroud)
我面临的问题是锚链接根本没有响应。
我注意到itemURL为null还是使用loadData而不是loadDataWithBaseURL,这些链接都可以工作,但是我松开了图像的连接以及通过itemURL连接的样式。
请注意,Webview可见性始终设置为可见。
这是为Webview初始化的onTouch方法:
this.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
System.out.println("getExtra: "+hr.getExtra());
// getExtra always gives null when webview loaded with loadDataWithBaseURL while it should give the url of the link pressed when the user touches a link
return false;
}
});
Run Code Online (Sandbox Code Playgroud) 我最近将 Android Studio 更新到最新版本,因为我一直面临连接到它的库的问题。
最近遇到的问题如下:
Cause 1: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzsr found in modules classes.jar (com.google.android.gms:play-services-measurement-base:16.3.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.1)
Duplicate class com.google.android.gms.internal.measurement.zzss found in modules classes.jar (com.google.android.gms:play-services-measurement-base:16.3.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.1)
Duplicate class com.google.android.gms.internal.measurement.zzst found in modules classes.jar (com.google.android.gms:play-services-measurement-base:16.3.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.1)
Duplicate class com.google.android.gms.internal.measurement.zzsu found in modules classes.jar (com.google.android.gms:play-services-measurement-base:16.3.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.1)
Duplicate class com.google.android.gms.internal.measurement.zzsv found in modules classes.jar (com.google.android.gms:play-services-measurement-base:16.3.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.1)
Duplicate class com.google.android.gms.measurement.internal.zzcu found in modules classes.jar (com.google.android.gms:play-services-measurement-base:16.3.0) and classes.jar (com.google.firebase:firebase-analytics-impl:16.2.1)
Duplicate class com.google.android.gms.measurement.internal.zzcv found in …Run Code Online (Sandbox Code Playgroud) android ×4
epub ×2
java ×2
objective-c ×2
selection ×2
uiwebview ×2
webview ×2
afnetworking ×1
css ×1
date ×1
datediff ×1
html ×1
hyperlink ×1
java-7 ×1
libraries ×1
loaddata ×1
long-click ×1
nsdata ×1
web-services ×1