Android Open Source - Gloggr Abstract Service






From Project

Back to project page Gloggr.

License

The source code is released under:

GNU General Public License

If you think the Android project Gloggr 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

package com.JordHan.Gloggr.Services;
//  ww w .  j  a v a2s. co  m
import java.io.Serializable;
import java.util.ArrayList;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public abstract class AbstractService implements Serializable, Runnable {

    private ArrayList<IServiceListener> listeners;
    private boolean error;

    public AbstractService() {
        listeners = new ArrayList<IServiceListener>();
    }

    public void addListener(IServiceListener listener) {
        listeners.add(listener);
    }

    public void removeListener(IServiceListener listener) {
        listeners.remove(listener);
    }

    public boolean hasError() {
        return error;
    }

    public void serviceComplete(boolean error) {
        this.error = error;

        Message m = _handler.obtainMessage();
        Bundle b = new Bundle();
        b.putSerializable("service", this);
        m.setData(b);
        _handler.sendMessage(m);
    }

    final Handler _handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            AbstractService service
                    = (AbstractService) msg.getData().getSerializable("service");

            for (IServiceListener listener : service.listeners) {
                listener.ServiceComplete(service);
            }
        }
    };
}




Java Source Code List

com.JordHan.Gloggr.Activities.CurrentlyPlayingActivity.java
com.JordHan.Gloggr.Activities.GameListActivity.java
com.JordHan.Gloggr.Activities.MainActivity.java
com.JordHan.Gloggr.Activities.PreferencesActivity.java
com.JordHan.Gloggr.Activities.SearchActivity.java
com.JordHan.Gloggr.Activities.Notification.AboutAppActivity.java
com.JordHan.Gloggr.Activities.Notification.AboutDeveloperActivity.java
com.JordHan.Gloggr.Helper.MenuHelper.java
com.JordHan.Gloggr.Model.Game.java
com.JordHan.Gloggr.Services.AbstractService.java
com.JordHan.Gloggr.Services.GameSearchService.java
com.JordHan.Gloggr.Services.IServiceListener.java
com.JordHan.Gloggr.db.DatabaseHelper.java
com.JordHan.Gloggr.db.DatabaseManager.java