我有30多个单位图(320x240像素),我想在Android设备上一个接一个地全屏显示,从而产生一个动画.目前,我使用ImageView和Timer实现动画,设置下一帧,然后发送将应用下一帧的消息.得到的帧速率非常低:<2 fps.
计时器:
animationTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
Drawable frame = getNextFrame();
if (frame != null) {
Message message = animationFrameHandler.obtainMessage(1, frame);
animationFrameHandler.sendMessage(message);
}
}
}, 0, (int) (1000.0d / fps));
Run Code Online (Sandbox Code Playgroud)
处理程序:
final Handler animationFrameHandler = new Handler() {
@Override
public void handleMessage(Message message) {
setImageDrawable((Drawable) message.obj);
}
};
Run Code Online (Sandbox Code Playgroud)
由于我想要实现高达30 fps的帧速率,我必须使用另一种机制并听说Canvas.drawBitmapMesh()和OpenGL.
如果可能的话我想避免使用OpenGL.
非常感谢您分享您的经验!
在JSF支持的bean中,我得到了一个IllegalStateException以编程方式添加的动作监听器,它以编程方式添加了Primefaces菜单项.我尝试了两个request和session范围,但两者都导致了同样的错误.显然需要 - 根据堆栈跟踪 - 在执行动作侦听器时恢复视图,并且让我的ToolbarBean工具Serializable没有任何不同的效果.为了让这个工作,我应该考虑什么?
用户界面定义
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>TITLE</title>
</h:head>
<h:body>
<h:form>
<p:menu model="#{toolbarBean.model}" type="tiered" />
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
支持菜单的支持豆
@Named
@Scope("request")
public class ToolbarBean implements Serializable {
private static final long serialVersionUID = -8556751897482662530L;
public ToolbarBean() {
model = new DefaultMenuModel();
MenuItem item;
// Direct menu item
item = new MenuItem();
item.setValue("Menuitem 1"); …Run Code Online (Sandbox Code Playgroud) 为了替换默认的Spring安全登录表单,我提出了这个解决方案:
<form name="f" action="../j_spring_security_check" method="POST" >
<h:panelGrid columns="2">
<h:outputText value="Username" />
<h:inputText id="j_username" />
<h:outputText value="Password" />
<h:inputText id="j_password" />
</h:panelGrid>
<h:commandButton value="Login" />
</form>
Run Code Online (Sandbox Code Playgroud)
但是<form>我想使用普通标签而不是普通标签,<h:form>因为Primefaces组件只能在其中工作<h:form>.使用<h:form>表单操作将由JSF自动设置到当前页面,而不是上面示例中我设置的值."../j_spring_security_check"现在我必须在哪里编写动作?我尝试将其放入<h:commandButton>如下,但这不起作用:
<h:form name="f">
<h:panelGrid columns="2">
<h:outputText value="Username" />
<h:inputText id="j_username" />
<h:outputText value="Password" />
<h:inputText id="j_password" />
</h:panelGrid>
<h:commandButton value="Click here" action="../j_spring_security_check" />
</form>
Run Code Online (Sandbox Code Playgroud)
它会导致错误消息Unable to find matching navigation case with from-view-id '/login.xhtml' for action '../j_spring_security_check' with outcome '../j_spring_security_check'.
这是定义导航案例的唯一方法faces-config.xml …
我意识到,WebView与内置浏览器是一回事吗?对?
我面临的问题是,包含一些绝对定位的div元素的页面都堆叠在彼此之上而不是找到它们的正确位置,并且背景图像被完全忽略.
这说,在我的手机上的浏览器(HTC Incredible S - 2.3.3,股票浏览器)正确地呈现它,并且除此之外,使用嵌入式webview的应用程序,我可以将其指向页面,正确呈现.这使我感到相信我的应用程序中的webview以某种方式变成了bjorking.
import android.app.Activity;
import android.content.Intent;
import android.graphics.Rect;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;
import java.util.*;
public class ShowWebView extends Activity {
public WebView web;
public String baseURL = "http://test.dev/";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webpage);
web = (WebView) findViewById(R.id.webpage);
home = (Button) findViewById(R.id.tool_Home);
back = (ImageButton) findViewById(R.id.tool_Back);
forward = (ImageButton) findViewById(R.id.tool_Forward);
refresh = (ImageButton) findViewById(R.id.tool_Refresh);
ajax …Run Code Online (Sandbox Code Playgroud) 我试图使用值动画师一个接一个地动画3个图像,但是我无法决定如何在定期间隔后调用三个处理程序.假设有3个图像并且我正在制作三个处理程序来动画它们.但我能够一次带三个图像,但不是一个接一个地定期播放.请帮助
这是我从我的处理程序调用的UpdateListener
public void startAnimation_image(final ImageView aniView) {
animator = ValueAnimator.ofFloat(0, .8f);
animator.setDuration(Constants.ANIM_DURATION);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
int Low = 10;
int High = width-150;
int R = (int) ((Math.random() * (High - Low)) + Low);
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = ((Float) (animation.getAnimatedValue())).floatValue();
aniView.setTranslationX(R);
Log.e("mscale",150*mScale +"");
Log.e("value is", value+"");
aniView.setTranslationY((mDisplaySize.bottom + (150*mScale))*value);
x_point = aniView.getTranslationX();
y_point = aniView.getTranslationY();
}
});
animator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator arg0) {
}
@Override
public void onAnimationRepeat(Animator arg0) {
} …Run Code Online (Sandbox Code Playgroud) 我对 React 数组有点迷失了。我想要做的是拥有组件(文章)数组,并且在该数组中我想要拥有标题和内容。
我想要对该数组执行的操作是添加、删除并将其显示在我的页面上。
那么我做错了什么?另外这个动作到底叫什么?
代码来自ReactJS 演示并由我修改了一些。
var ReactDOM = require('react-dom');
var React = require('react');
// Articles page
const Articles = React.createClass({
getInitialState() {
return {article: [
{'title': 'hello', 'content': 'hello hello'},
{'title': 'hello1', 'content': 'hello hello1'},
{'title': 'hello2', 'content': 'hello hello2'},
{'title': 'hello3', 'content': 'hello hello3'}
]};
},
onAdd() {
const newArticle =
this.state.article.concat([window.prompt('Enter article')]);
this.setState({article: newArticle});
},
onRemove(i) {
const newArticle = this.state.article;
newArticle.splice(i, 1);
this.setState({article: newArticle});
},
render() {
const article = this.state.article.map((article, i) => …Run Code Online (Sandbox Code Playgroud) 我的应用程序使用UIBackgroundMode,即当应用程序未处于活动状态时蓝牙事件发生时,它会被iOS重新启动.因此,iOS会将蓝牙事件分派到后台队列(队列由我指定).
但是我可以将代码发送回主队列,即
DispatchQueue.main.async { } (迅速)
dispatch_async(dispatch_get_main_queue(), ^{ }) (目标C)
并假设其运行循环正在运行,这是我的块被调度?或者主队列是否以后台模式挂起,因此我应该避免向其添加调度块?
我正在WatchOS上构建一个非常简单的锻炼应用程序:其中一个功能是在训练期间提供音频反馈.我可以在显示器打开时播放文件,但是当显示器很暗时,手表不会播放我的文件.
有人可以查看我的快速代码并帮助我弄清楚我错过了什么吗?
这是我的extensionDelegate.swift:
var audioPlayer = AVAudioPlayer()
class ExtensionDelegate: NSObject, WKExtensionDelegate {
func applicationDidFinishLaunching() {
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(AVAudioSessionCategoryAmbient, with: .duckOthers)
} catch {
print("audiosession cannot be set")
}
do { try audioSession.setActive(true) }
catch {
print ("audiosession cannot be activated")
}
let test = URL(fileURLWithPath: Bundle.main.path(forResource: "1", ofType: "m4a")!)
try! audioPlayer = AVAudioPlayer(contentsOf: test)
audioPlayer.prepareToPlay()
audioPlayer.play()
}
func applicationDidBecomeActive() {
// Restart any tasks that were paused (or not yet started) while the application was …Run Code Online (Sandbox Code Playgroud) 当我跑步
gcloud app deploy app.yaml
Run Code Online (Sandbox Code Playgroud)
实际上传了哪些文件?
项目文件夹包含文件夹和文件,如.git,.git_ignore,Makefile或venv不相关的部署的应用程序。
如何gcloud app deploy确定上传哪些文件?
在ORMLite文档中,建议OrmLiteSqliteOpenHelper为每个活动创建.因为获取帮助程序只需要一个Context对象,为什么不为整个Application对象创建一次数据库帮助程序?这样就可以使用Dagger(或其他注入框架)将数据库助手注入需要它的类中.
有没有理由不创建一个单一的应用程序范围的数据库帮助程序?是否最好让每个活动都有自己的数据库助手?我可以想象这会使助手的缓存大小变小,因为缓存只包含与其活动相关的对象.