Android Open Source - trip-chain-android Trip Fragment






From Project

Back to project page trip-chain-android.

License

The source code is released under:

MIT License

If you think the Android project trip-chain-android 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 fi.aalto.tripchain;
/*from  w  w w  . j  a  v  a2 s.  c  om*/
import java.util.List;
import java.util.Map;

import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;

import fi.aalto.tripchain.route.TripRecorder;

import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Shows trip on a map.
 */
public class TripFragment extends SupportMapFragment {
  private final static String TAG = TripFragment.class.getSimpleName();

  private MainActivity main;

  private Polyline polyline;

  private Handler handler;

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.handler = new Handler();

    View rootView = super.onCreateView(inflater, container, savedInstanceState);

    GoogleMap map = getMap();
    map.setMyLocationEnabled(true);

    this.main = (MainActivity) getActivity();
    this.main.subscribe(clientConnection);

    return rootView;
  }

  Client.Stub clientConnection = new Client.Stub() {
    @Override
    public void onLocation(final List<Location> locations) throws RemoteException {
      handler.post(new Runnable() {
        public void run() {
          if (polyline != null) {
            polyline.remove();
          }

          Log.d(TAG, "onLocation");

          PolylineOptions rectOptions = new PolylineOptions();
          for (Location l : locations) {
            rectOptions.add(new LatLng(l.getLatitude(), l.getLongitude()));
          }

          polyline = getMap().addPolyline(rectOptions);
        }
      });
    }
  };
}




Java Source Code List

fi.aalto.tripchain.BackgroundService.java
fi.aalto.tripchain.Configuration.java
fi.aalto.tripchain.LoginActivity.java
fi.aalto.tripchain.MainActivity.java
fi.aalto.tripchain.StartFragment.java
fi.aalto.tripchain.TripFragment.java
fi.aalto.tripchain.receivers.ActivityReceiver.java
fi.aalto.tripchain.receivers.EventDispatcher.java
fi.aalto.tripchain.receivers.EventListener.java
fi.aalto.tripchain.receivers.LocationReceiver.java
fi.aalto.tripchain.receivers.Receiver.java
fi.aalto.tripchain.route.ActivityListener.java
fi.aalto.tripchain.route.Activity.java
fi.aalto.tripchain.route.LocationListener.java
fi.aalto.tripchain.route.RoadSegment.java
fi.aalto.tripchain.route.Roads.java
fi.aalto.tripchain.route.RouteSegment.java
fi.aalto.tripchain.route.Route.java
fi.aalto.tripchain.route.TripRecorder.java
fi.aalto.tripchain.route.Trip.java