Skip to content

Commit

Permalink
add to resarch user place
Browse files Browse the repository at this point in the history
  • Loading branch information
yuichi10 committed Aug 24, 2015
1 parent e1426c0 commit 9927d3a
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 13 deletions.
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
<activity android:name=".ThumbnailImage" android:label="ThumbnailImage"/>
<activity android:name=".MakeGroup" android:label="MakeGroup"/>
</application>

<!-- 位置情報 GPSから -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 位置情報 ネットワークから -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package pmv02.ppr.yuichi10.github.com.joinevents;

import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

/**
* Created by yuichi on 8/24/15.
*/
public class Gps implements LocationListener {

//location manager
private LocationManager mLocationManager;
//Criteria
private Criteria mCriteria;
//provider
private String mProvider;
//Context
Context mContext;
//Longitude Latitude
private double mLongitude = 0;
private double mLatitude = 0;
//get the place or not
boolean isGetPlace = false;

public interface GetPlaceCallBack{
public void isGetPlaceCB();
}
private GetPlaceCallBack _mGetPlaceCallBack;

public void setCallbacks(GetPlaceCallBack getPlaceCallBack){
_mGetPlaceCallBack = getPlaceCallBack;
}

public Gps(Context context){
this.mContext = context;
mCriteria = new Criteria();
}

//setProvider
public void setProvider(){
mCriteria.setPowerRequirement(Criteria.POWER_LOW);
mCriteria.setAccuracy(Criteria.ACCURACY_COARSE);
mProvider = mLocationManager.getBestProvider(mCriteria, true);
}

public void setProvider(String accuracy, String power){
//later
}

//start gps
public void startGps(){
mLocationManager = (LocationManager)mContext.getSystemService(Context.LOCATION_SERVICE);
setProvider();
mLocationManager.requestLocationUpdates(mProvider, 0, 0, this);
Log.d("aaa","start");
}

//stop to get place
public void stopGps(){
mLocationManager.removeUpdates(this);
}

@Override
public void onLocationChanged(Location location) {
mLongitude = location.getLongitude();
mLatitude = location.getLatitude();
Log.d("aaa","changed");
_mGetPlaceCallBack.isGetPlaceCB();
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {

}

@Override
public void onProviderEnabled(String provider) {

}

@Override
public void onProviderDisabled(String provider) {

}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package pmv02.ppr.yuichi10.github.com.joinevents;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.location.Criteria;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
Expand All @@ -11,31 +11,51 @@
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.List;

/**
* Created by yuichi on 8/20/15.
*/
public class Home extends Activity implements View.OnClickListener{
public class Home extends Activity implements View.OnClickListener, Gps.GetPlaceCallBack{
ArrayAdapter<String> adapter;
//gps
private Gps mGps;
//criteria
private Criteria mCriteria;
//does get place
private boolean isGetplace = false;
//list view to show groups
ListView mListView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
Log.d("Intent", "success");

Intent intent = getIntent();
//get gps
mGps = new Gps(this.getApplicationContext());
//set callback
mGps.setCallbacks(this);
//get current place
mGps.startGps();
//grope name adapter
adapter = new ArrayAdapter<String>(this, R.layout.colmun_home_list);
//get group list
getGroups();
ListView listView = (ListView)this.findViewById(R.id.homeList);
getListMountHeight(listView);
listView.setAdapter(adapter);
//set List view
this.mListView = (ListView)this.findViewById(R.id.homeList);
getListMountHeight(mListView);

//make group button
Button makeGroupButton = (Button)findViewById(R.id.homeMakeGrope);
makeGroupButton.setOnClickListener(this);
//show group list when the place is found
}

//show groups list
public void showList(){
adapter = new ArrayAdapter<String>(this, R.layout.colmun_home_list);
//get group list
getGroups();
//set groups to list
this.mListView.setAdapter(adapter);
}

public void getListMountHeight(ListView lv){
Expand Down Expand Up @@ -64,6 +84,14 @@ public void getGroups(){
}
}

//call back when the place was found
public void isGetPlaceCB(){
isGetplace = true;
mGps.stopGps();
Log.d("aaa", "success");
showList();
}

@Override
public void onClick(View v) {
switch (v.getId()){
Expand Down

0 comments on commit 9927d3a

Please sign in to comment.