Android Open Source - worldwondersproject Place Manager






From Project

Back to project page worldwondersproject.

License

The source code is released under:

MIT License

If you think the Android project worldwondersproject 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.ciandt.cursoandroid.worldwondersapp.manager;
/* w  w  w  .j  av a2s.co  m*/
import android.os.AsyncTask;

import com.ciandt.cursoandroid.worldwondersapp.entity.Place;
import com.ciandt.cursoandroid.worldwondersapp.infrastructure.Constants;
import com.ciandt.cursoandroid.worldwondersapp.integrator.PlaceIntegrator;
import com.ciandt.cursoandroid.worldwondersapp.listener.IntegratorOperatorCallback;

import org.json.JSONArray;
import org.json.JSONObject;

import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

public class PlaceManager {
    public void getAllPlaces(final IntegratorOperatorCallback<List<Place>> listIntegratorOperatorCallback) throws URISyntaxException {
        new AsyncTask<Void, Void, List<Place>>() {

            @Override
            protected List<Place> doInBackground(Void... params) {
                JSONObject jsonObject = new JSONObject();
                try {
                    jsonObject = (JSONObject) new PlaceIntegrator().doGetRequest(Constants.Integrator.WorldWondersApi.PROTOCOL, Constants.Integrator.WorldWondersApi.HOST, Constants.Integrator.WorldWondersApi.WORLD_WONDERS_LIST);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }

                List<Place> places = new ArrayList<Place>();
                try {
                    JSONArray jsonArray = jsonObject.getJSONArray("data");
                    for (int i = 0; i < jsonArray.length(); i++) {
                        Place place = new Place(jsonArray.getJSONObject(i));
                        places.add(place);
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }

                return places;
            }

            @Override
            protected void onPostExecute(List<Place> places) {
                super.onPostExecute(places);
                if (places != null) {
                    listIntegratorOperatorCallback.onOperationCompleteSuccess(places);
                } else {
                    listIntegratorOperatorCallback.onOperationCompleteError();
                }
            }
        }.execute();
    }
}




Java Source Code List

com.ciandt.cursoandroid.worldwondersapp.ApplicationTest.java
com.ciandt.cursoandroid.worldwondersapp.activity.LoginActivity.java
com.ciandt.cursoandroid.worldwondersapp.activity.MainActivity.java
com.ciandt.cursoandroid.worldwondersapp.activity.PlaceDetailActivity.java
com.ciandt.cursoandroid.worldwondersapp.activity.RegisterActivity.java
com.ciandt.cursoandroid.worldwondersapp.adapter.PlaceCursorAdapter.java
com.ciandt.cursoandroid.worldwondersapp.businesscoordinator.PlaceBusinessCoordinator.java
com.ciandt.cursoandroid.worldwondersapp.contentprovider.WorldWondersContentProvider.java
com.ciandt.cursoandroid.worldwondersapp.database.Database.java
com.ciandt.cursoandroid.worldwondersapp.database.table.PlaceTable.java
com.ciandt.cursoandroid.worldwondersapp.entity.BaseEntity.java
com.ciandt.cursoandroid.worldwondersapp.entity.Place.java
com.ciandt.cursoandroid.worldwondersapp.entity.User.java
com.ciandt.cursoandroid.worldwondersapp.fragment.PlaceDetailFragment.java
com.ciandt.cursoandroid.worldwondersapp.fragment.PlaceListFragment.java
com.ciandt.cursoandroid.worldwondersapp.infrastructure.Constants.java
com.ciandt.cursoandroid.worldwondersapp.infrastructure.NetworkUtil.java
com.ciandt.cursoandroid.worldwondersapp.integrator.BaseIntegrator.java
com.ciandt.cursoandroid.worldwondersapp.integrator.GeneralIntegrator.java
com.ciandt.cursoandroid.worldwondersapp.integrator.PlaceIntegrator.java
com.ciandt.cursoandroid.worldwondersapp.listener.DatabaseOperatorCallback.java
com.ciandt.cursoandroid.worldwondersapp.listener.IntegratorOperatorCallback.java
com.ciandt.cursoandroid.worldwondersapp.manager.DatabaseManager.java
com.ciandt.cursoandroid.worldwondersapp.manager.LoginManager.java
com.ciandt.cursoandroid.worldwondersapp.manager.PlaceManager.java
com.ciandt.cursoandroid.worldwondersapp.manager.RegisterManager.java
com.ciandt.cursoandroid.worldwondersapp.service.SyncService.java
com.ciandt.cursoandroid.worldwondersapp.service.syncer.PlaceSyncer.java
com.ciandt.cursoandroid.worldwondersapp.service.syncer.Syncer.java