@@ -0,0 +1,2922 @@
+/*%0A * Copyright (c) 2015 Ushahidi Inc%0A *%0A * This program is free software: you can redistribute it and/or modify it under%0A *  the terms of the GNU Affero General Public License as published by the Free%0A *  Software Foundation, either version 3 of the License, or (at your option)%0A *  any later version.%0A *%0A *  This program is distributed in the hope that it will be useful, but WITHOUT%0A *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS%0A *  FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.%0A *%0A *  You should have received a copy of the GNU Affero General Public License%0A *  along with this program in the file LICENSE-AGPL. If not, see%0A *  https://www.gnu.org/licenses/agpl-3.0.html%0A */%0A%0Apackage com.ushahidi.android.data.api;%0A%0Aimport com.google.gson.JsonElement;%0A%0Aimport com.ushahidi.android.data.api.model.Tags;%0Aimport com.ushahidi.android.data.api.service.TagService;%0Aimport com.ushahidi.android.data.entity.GeoJsonEntity;%0Aimport com.ushahidi.android.data.entity.TagEntity;%0Aimport com.ushahidi.android.data.exception.NetworkConnectionException;%0A%0Aimport android.content.Context;%0Aimport android.support.annotation.NonNull;%0A%0Aimport java.util.List;%0A%0Aimport javax.inject.Inject;%0A%0Aimport rx.Observable;%0A%0A/**%0A * @author Ushahidi Team %3Cteam@ushahidi.com%3E%0A */%0Apublic class TagApi %7B%0A%0A    private final Context mContext;%0A%0A    private final TagService mTagService;%0A%0A    @Inject%0A    public TagApi(@NonNull Context context, @NonNull TagService tagService) %7B%0A        mContext = context;%0A        mTagService = tagService;%0A    %7D%0A%0A    /**%0A     * Retrieves an %7B@link rx.Observable%7D which will emit a %7B@link GeoJsonEntity%7D.%0A     *%0A     * @param deploymentId The ID of the deployment the GeoJson is fetched from.%0A     */%0A    public Observable%3CGeoJsonEntity%3E getGeoJson(Long deploymentId) %7B%0A        return Observable.create((subscriber) -%3E %7B%0A            if (isDeviceConnectedToInternet(mContext)) %7B%0A                mTagService.getTags()%0A                        .map((tags) -%3E setTags(tags, deploymentId));%0A            %7D else %7B%0A                subscriber.onError(new NetworkConnectionException());%0A            %7D%0A        %7D);%0A    %7D%0A%0A    /**%0A     * Sets the %7B@link GeoJsonEntity%7D entity properties from the %7B@link JsonElement%7D%0A     *%0A     * @param deploymentId The ID of the deployment the GeoJson is fetched from.%0A     * @param tags         The jsonElement to retrieve the raw JSON string from.%0A     */%0A    private Observable%3CList%3CTagEntity%3E%3E setTags(Tags tags, Long deploymentId) %7B%0A        return Observable.create(subscriber -%3E %7B%0A            subscriber.onNext(tags.getTags());%0A            subscriber.onCompleted();%0A        %7D);%0A    %7D%0A%0A    // Workaround for testing static method for checking status of data%0A    // connection on the device.%0A    public boolean isDeviceConnectedToInternet(Context context) %7B%0A        return ApiUtil.isDeviceConnectedToInternet(context);%0A    %7D%0A%7D%0A

Implement Tag api service