Android Open Source - GPS_Receiver Bus Provider






From Project

Back to project page GPS_Receiver.

License

The source code is released under:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute v...

If you think the Android project GPS_Receiver listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Intellectual properties of Supun Lakshan Wanigarathna Dissanayake
 * Copyright (c) 2014, Supun Lakshan Wanigarathna Dissanayake. All rights reserved.
 * Created on : Oct 17, 2014, 8:51 PM/*from   www .  j a  v  a 2s.  c o m*/
 */
package org.xfinity.gps_receiver.util;

import android.os.Handler;
import android.os.Looper;
import com.squareup.otto.Bus;
import org.jetbrains.annotations.NotNull;

/**
 * @author Supun Lakshan Wanigarathna Dissanayake
 * @mobile +94711290392
 * @email supunlakshan.xfinity@gmail.com
 */
public class BusProvider {

  private final static Bus BUS = new Bus() {
    private final Handler handler = new Handler(Looper.getMainLooper());

    @Override
    public void post(@NotNull final Object event) {
      if (Looper.myLooper() != Looper.getMainLooper()) {
        handler.post(new Runnable() {
          @Override
          public void run() {
            postInMainThread(event);
          }
        });
      } else {
        postInMainThread(event);
      }
    }

    private void postInMainThread(Object event) {
      super.post(event);
    }
  };

  private BusProvider() {
  }

  public static Bus getInstance() {
    return BUS;
  }
}




Java Source Code List

org.xfinity.gps_receiver.activity.StartingPoint.java
org.xfinity.gps_receiver.service.LocationProviderService.java
org.xfinity.gps_receiver.util.BusProvider.java