标签: handler

Handler.sendMessageDelayed(msg,delay)无法正常工作

我已经定义了一个在加载过程中显示的启动画面.但根据互联网连接,加载时间仅为600毫秒,有时甚至需要5000毫秒.所以我定义了启动画面至少显示了3000毫秒,这样用户就不会被浮雕屏幕激怒.

我通过以下方式定义启动画面的开始:

 private void splashScreen() {
        setContentView(R.layout.splashscreen);
        splash = (ImageView) findViewById(R.id.splashscreenLayer);
        startSplashTime = new Date();
        new LoadingThread().start(); 
    }
Run Code Online (Sandbox Code Playgroud)

在LoadingThread中,我检查网络并从Internet加载数据:

private class LoadingThread extends Thread {

        @Override
        public void run() {
            checkNetwork();
        }

    }
Run Code Online (Sandbox Code Playgroud)

加载完成后,我将消息发送到MainActivity中定义的处理程序:

public void stopSplash() {
        Message msg = new Message();
        msg.what = STOPSPLASH;

        Date endSplashTime = new Date();
        long time = endSplashTime.getTime() - startSplashTime.getTime();
        System.out.println("Time Splashscreen was displayed: " + time);
        if (time < SPLASH_MIN_TIME) {
            long delay = SPLASH_MIN_TIME - time;
            System.out.println("Delay Splashscreen for: " + …
Run Code Online (Sandbox Code Playgroud)

multithreading android handler android-handler

6
推荐指数
1
解决办法
5436
查看次数

AppleScript:在tell语句中调用处理程序

每次运行此脚本时都会出现此错误:系统事件出错:"Test123"无法理解通知消息.

码:

--more code...
tell application "System Events"
    if some_system_events_property then
         my notify of "Test123" thru "Test"
    end if
end tell
--more code...
to notify of message thru level
    display dialog message with titel level
end notify
Run Code Online (Sandbox Code Playgroud)

我试图替换

my notify of "Test123" thru "Test"
Run Code Online (Sandbox Code Playgroud)

以下,没有任何成功:

notify of "Test123" thru "Test" of me
(notify of "Test123" thru "Test") of me
Run Code Online (Sandbox Code Playgroud)

applescript handler tell

6
推荐指数
2
解决办法
4383
查看次数

在非200响应的情况下,javascript图像onError

我必须计算图像加载时间.onLoadHandler对此负责.

<img onError="onErrorHandler(this);" onLoad="onLoadHandler(this);" alt="" border='0' width='1' height='1'   src='http://exmaple.com/02.jpg'/>
Run Code Online (Sandbox Code Playgroud)

如果图像是具有200个服务器响应的普通文件,则它工作正常.

但是合作伙伴提供了302个重定向链,并且onError会在第一次重定向时触发.所以我永远不会真正加载图像时间.

有一些解决方法吗?

谢谢

javascript handler onload onerror http-status-code-302

6
推荐指数
1
解决办法
1373
查看次数

在每个函数调用php上执行一些操作

每当在PHP中发生任何函数调用时,我想记录函数名称,其参数和调用时间.有没有办法实现这一目标.我有一个记录函数,如何设置此函数每次执行任何函数调用时执行?

php function handler

6
推荐指数
1
解决办法
388
查看次数

Nginx gzip过滤器无法使用我的自定义处理程序

我写了一个非常简单的nginx处理程序,只输出一些文本(大小100B到10KB).

代码适用于nginx(版本1.0.6)

但我发现gzip过滤器无法与处理程序一起使用.

当我在nginx.conf(在http部分下)打开gzip时,gzip使用静态html文件工作.

但是,处理程序的响应不是用gzip压缩的.

经过大量的搜索工作,我仍然找不到答案.

任何意见 ?非常感谢.:-)

//my code :
static ngx_int_t ngx_http_test_handler(ngx_http_request_t *r){

    ngx_chain_t out;
    ngx_buf_t *b;

    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));

    ......
    //writing text to buffer
    ......
    r->headers_out.status = NGX_HTTP_OK;
    r->headers_out.content_length_n = len;
    r->headers_out.content_type.len = sizeof("text/html")-1;
    r->headers_out.content_type.data = (u_char *) "text/html";

    out.buf = b;
    out.next = NULL;
    return ngx_http_output_filter(r, &out);
}
Run Code Online (Sandbox Code Playgroud)

gzip module nginx handler

6
推荐指数
1
解决办法
863
查看次数

Android - 希望应用程序每秒执行一次任务

我正在尝试让我的倒计时应用程序执行其更新我当前时间和日期TextView的功能,并每秒触发其MyOnItemSelectedListener,以便应用程序动态倒计时而不是仅在启动onCreate时.如果有一个更有效的方法然后快速解雇MyOnItemSelectedListener我会很感激批评.

public class TheCount extends Activity {
TextView description=null;
TextView dates=null;
TextView times=null;
TextView output=null;
TextView cDateDisplay=null;
TextView cTimeDisplay=null;
private int mYear;
private int mMonth;
private int mDay;
private int mHour;
private int mMinute;
private int mSecond;
CountdownHelper helper=null;
String countdownId=null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.thecount);
    helper=new CountdownHelper(this);
    cTimeDisplay = (TextView)findViewById(R.id.lblCurTime);
    cDateDisplay = (TextView)findViewById(R.id.lblCurDate);

    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);
    mHour = c.get(Calendar.HOUR_OF_DAY);
    mMinute = c.get(Calendar.MINUTE);
    mSecond = c.get(Calendar.SECOND); …
Run Code Online (Sandbox Code Playgroud)

android action timer handler

6
推荐指数
1
解决办法
2万
查看次数

如何在VB.NET中删除事件处理程序

可能重复:
VB.NET RemoveHandler和匿名方法

如果我添加这样的事件处理程序:

AddHandler s.Click, AddressOf Panel1_Click
Run Code Online (Sandbox Code Playgroud)

我怎样才能删除事件处理程序?

Private Sub Panel1_click(ByVal sender As Object, ByVal e As System.EventArgs)
    ' Remove code
End Sub
Run Code Online (Sandbox Code Playgroud)

vb.net handler winforms

6
推荐指数
2
解决办法
2万
查看次数

线程/处理程序错误 - 尚未发布指定的消息队列同步屏障标记

我收到此错误 -

java.lang.IllegalStateException:指定的消息队列同步障碍标记尚未发布或已被删除.

作为Java/Android的相对新手,毫无疑问我错过了一些东西,但我正在做的是这个 -

我有一个项目使用Exif数据根据拍摄日期显示照片,目的是在每个舞台上使用类似的模型......

工作线程 - > UI线程 - >自定义显示适配器.然后单击GridView中的一个"单元格"将触发下一个活动.第一个活动搜索所有照片文件,创建"年"列表,然后每个后续活动将其过滤到几个月,几天等.

但是,启动第二个活动会直接启动上述错误,并通过基本的线程/处理程序设置处理消息.

这是将消息传递给线程的类 -

public class MonthSort {
Handler handler;
int imageWidth;
List<PhotoData> photoList;
public MonthSort(Handler handler2, int width, List<PhotoData> pList) {
    photoList = new ArrayList<PhotoData>();
    photoList = pList;
    imageWidth = width;
    handler = handler2;
}

public void sortFiles()
{
    int month, photoCount;
    File fileName = new File("");
    Message msg = handler.obtainMessage();
    //Message msg = Message.obtain();
    //Bundle bundle = new Bundle();
    try {
        for (int i = 0; i …
Run Code Online (Sandbox Code Playgroud)

java multithreading android handler

6
推荐指数
2
解决办法
7224
查看次数

从网站启动Chrome打包的Web应用程序

我有一个Chrome Packaged Web应用程序(这是访问串行端口所必需的),我希望能够在我点击其上的链接/按钮时从我的网站(包含一些数据)启动它网站.

如果它可以检测用户是否没有运行chrome或者没有安装Web应用程序并且可以将它们引导到正确的位置,那就更好了......

有什么例子吗?这似乎是一个显而易见的事情,但我真的很难找到任何东西......

google-chrome web-applications protocols handler google-chrome-app

6
推荐指数
1
解决办法
2426
查看次数

javafx多个按钮到同一个处理程序

我尝试用20个按钮和一个处理程序制作一个简单的计算器.在java中,我可以在ActionPerformed中使用带有event.getSource()的'if'语句来检查按下了哪个按钮,但它不适用于javafx中的处理程序.在javafx中,所有按钮都有一个处理程序吗?(我不想使用java 8 Lambdas.)上次我尝试使用setId/getId,但同样不起作用(对我而言).

public class Calculator extends Application {

    public Button b0, b1;

    @Override
    public void start(Stage primaryStage) {

        GridPane grid = new GridPane();

        b0 = new Button("0");
        b0.setId("0");
        b0.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        grid.add(b0, 0, 1);
        b0.setOnAction(myHandler);

        b1 = new Button("1");
        b1.setId("1");
        b1.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        grid.add(b1, 0, 0);
        b1.setOnAction(myHandler);

        Scene scene = new Scene(grid, 365, 300);
        scene.getStylesheets().add
            (Calculator.class.getResource("calculator.css").toExternalForm());

        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.show();
    }

    final EventHandler<ActionEvent> myHandler = new EventHandler<ActionEvent>(){

        @Override
        public void handle(final ActionEvent event) {
            Button x = (Button) event.getSource();
            if (x.getId().equals(b0.getId()))
                System.out.println("0"); …
Run Code Online (Sandbox Code Playgroud)

javafx button handler

6
推荐指数
1
解决办法
2万
查看次数