1. Download our Official Android App: Forums for Android!

Apps Asynchronous event mechanism

Discussion in 'Android Development' started by cleopart, Nov 1, 2011.

  1. cleopart

    cleopart Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Nov 1, 2011

    Nov 1, 2011
    2
    0
    5
    Hi all,
    I am sorry if this question is duplicated, I did search and found nothing before posting this thread.

    I do not know how to create a customize event listener. I do some example like:

    Create interface InterfaceA

    interface InterfaceA {
    event1();
    event2();
    ...

    }

    create a class that can trigger event, this class has a method to set listener.

    class trigger
    {
    set onInterfaceA(InterfaceA client) { this.client=client}
    .....
    // code to trigger some where
    {
    if (client!=null) client.event1();
    ..............
    taskA();
    }
    ..............
    {
    if (client!=null) client.event2();
    ..............
    taskB();
    }
    ....

    }

    create class that can handle event
    class handlerCustomerEvent() implement InterfaceA{
    trigger mytrigger;
    /////set its self as listener some where
    ......
    {
    mytrigger.onInterfaceA(this)
    }
    ...
    //An implement event1 & event1
    public void event1() {
    taskC();
    }
    public void event1() {
    taskD();
    }

    }

    Well, this way to reach the event is okie, but if taskA can not be performed until taskC is finish because all of event handle is function calling, not real trigger, that make me mad.
    So, how to make a real trigger, in that, I trigger the event, and do the taskC without waiting for the completion of event handler method ?
    Any help are appreciated.
    Thank for reading this confused code :p
     

    Advertisement

  2. El Presidente

    El Presidente Beware The Milky Pirate!
    Moderator
    Rank:
     #4
    Points:
    3,118
    Posts:
    32,116
    Joined:
    Jan 3, 2011

    Jan 3, 2011
    32,116
    24,060
    3,118
    Scotland
    Welcome to AF cleopart! :)

    I've moved your thread to the App Dev section (where it sounds like it belongs), hopefully you'll get the response you need here.
     
  3. cleopart

    cleopart Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Nov 1, 2011

    Nov 1, 2011
    2
    0
    5
    Any help are appreciated.
     

Share This Page

Loading...