我使用XWalkView加载网页,如下所示:
private boolean isCacheAvailable(){
File dir = getApplicationContext().getCacheDir();
if (dir.exists())
return dir.listFiles().length > 0;
else
return false;
};
活动
<org.xwalk.core.XWalkView android:id="@+id/webview"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</org.xwalk.core.XWalkView>
有关实现XWalkView的详细信息,请参阅我的post。
但是现在,由于页面内容太多,它会调用4~5秒进行finshing加载。这将导致应用页面空白。我想为XWalkView添加加载进度。对于XWalkView只有很少的演示,我真的不知道从哪里开始。
任何帮助将不胜感激。 Thansk!
编辑:在我尝试按照@Srihari的回答后,又出现了另一个问题。 进展表现良好,当它完成100%时,它就会消失。但它在页面完成加载后很快再次以100%跳出,并且从未消失。
活动:
XWalkView mXWalkView = (XWalkView) findViewById(R.id.webview);
mXWalkView.load("http://xxxxxxxx", null);
xml
class ResourceClient extends XWalkResourceClient {
public ResourceClient(XWalkView xwalkView) {
super(xwalkView);
}
public void onLoadStarted(XWalkView view, String url) {
mProgress = (ProgressBar) findViewById(R.id.progressBar);
mProgress.setVisibility(View.VISIBLE);
super.onLoadStarted(view, url);
Log.d("INFO", "Load Started:" + url);
}
public void onLoadFinished(XWalkView view, String url) {
super.onLoadFinished(view, url);
Log.d("INFO", "Load Finished:" + url);
bottomBar = (BottomBar) findViewById(R.id.bottomBar);
mProgress = (ProgressBar) findViewById(R.id.progressBar);
mProgress.setVisibility(View.GONE);
}
public void onProgressChanged(XWalkView view, int progressInPercent) {
super.onProgressChanged(view, progressInPercent);
Log.d("INFO", "Loading Progress:" + progressInPercent);
mProgress = (ProgressBar) findViewById(R.id.progressBar);
mProgress.setProgress(progressInPercent);
}
答案 0 :(得分:3)
在我修复我的问题之前我去makkah做umrah我尝试2天解决问题后umrah我需要2分钟并解决我的问题我的上帝帮助我
请不要删除我们从上帝那里得到的所有话题
你需要向上帝祷告,你会得到你想要的一切吗
这是我的MainActivity
__kernel void unprimed_grid_int(your_arguments, int test) {
if (get_global_id(0) == 734207) {
test = 10; // or any other value
}
}
我跳这个帮助你
答案 1 :(得分:1)
显示该活动或片段的创建进度条。
xWalkView.setResourceClient(new XWalkResourceClient(xWalkView){
@Override
public void onLoadFinished(XWalkView view, String url) {
super.onLoadFinished(view, url);
// Stop your progress bar here
}
});
希望这可以帮到你..
答案 2 :(得分:1)
我解决了我的问题,这是在activity_main:
<org.xwalk.core.XWalkView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/framelayout"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="@android:color/transparent"
android:visibility="visible"></FrameLayout>
<ProgressBar
android:id="@+id/ProgressBar"
style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Large"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_gravity="top"
android:layout_marginTop="3dp"
android:background="@android:color/transparent"
android:progress="10"
android:progressDrawable="@drawable/custom_progress" />
</org.xwalk.core.XWalkView>
答案 3 :(得分:0)
我发现在我的问题中,我所讨论的behivour是由我页面中的动态内容引起的。因为我的页面有stlloader,所以我实现了xwalkview加载进度和stlloader加载进度。
Xwalkview加载进度:
class ResourceClient extends XWalkResourceClient {
public ResourceClient(XWalkView xwalkView) {
super(xwalkView);
}
public void onLoadStarted(XWalkView view, String url) {
mProgress = (ProgressBar) findViewById(R.id.progressBar);
mProgress.setVisibility(View.VISIBLE);
super.onLoadStarted(view, url);
Log.d("INFO", "Load Started:" + url);
}
public void onLoadFinished(XWalkView view, String url) {
super.onLoadFinished(view, url);
Log.d("INFO", "Load Finished:" + url);
bottomBar = (BottomBar) findViewById(R.id.bottomBar);
mProgress = (ProgressBar) findViewById(R.id.progressBar);
mProgress.setVisibility(View.GONE);
}
public void onProgressChanged(XWalkView view, int progressInPercent) {
super.onProgressChanged(view, progressInPercent);
Log.d("INFO", "Loading Progress:" + progressInPercent);
mProgress = (ProgressBar) findViewById(R.id.progressBar);
mProgress.setProgress(progressInPercent);
}
stlloader加载进度:
var loader = new THREE.STLLoader(manager);
loader.load( "{{ $modelfilepath }}", function ( geometry ) {
var meshMaterial = new THREE.MeshPhongMaterial( { color: 0xAAAAAA, specular: 0x111111, shininess: 200 } );
if (geometry.hasColors) {
meshMaterial = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors });
}
centerOffset = geometry.center();
var mesh = new THREE.Mesh( geometry, meshMaterial );
tV.z = (-geometry.boundingBox.min.z + geometry.boundingBox.max.z)/2;
mesh.matrix.elements[14] = tV.z;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.matrixAutoUpdate = false;
boundBox.setFromObject(mesh);
if(!isFillin(boundBox.min, boundBox.max, machineLength))
{
mesh.material.color.setHex(0xff0000);
}
stlMesh = mesh;
scene.add( mesh );
objects.push(mesh);
showPosition(0, 0, tV.z);
}, function(progressItem) {
$('#loaderstatus').html("Loading... " + (Math.round(progressItem.loaded / progressItem.total *100)) + "%");
}, function(){
});