hotfix/restore_missing #32
|
@ -5,12 +5,12 @@ import java.util.List;
|
||||||
|
|
||||||
public class CreateUUID {
|
public class CreateUUID {
|
||||||
|
|
||||||
public static int generateUUID(List<String> classIdList ){
|
public static int generateUUID(List<Integer> classIdList ){
|
||||||
while (true){
|
while (true){
|
||||||
String uuid = String.valueOf((int)(Math.random() * 1000000));
|
int uuid = (int)(Math.random() * 1000000);
|
||||||
boolean isDuplicate = false;
|
boolean isDuplicate = false;
|
||||||
for(String classId : classIdList){
|
for(int classId : classIdList){
|
||||||
if(classId.equals(uuid)){
|
if(classId==uuid){
|
||||||
//重複があればフラグを立て、ループを抜ける
|
//重複があればフラグを立て、ループを抜ける
|
||||||
isDuplicate = true;
|
isDuplicate = true;
|
||||||
break;
|
break;
|
||||||
|
@ -19,9 +19,11 @@ public class CreateUUID {
|
||||||
//重複がなければ生成したUUIDを返す
|
//重複がなければ生成したUUIDを返す
|
||||||
if (!isDuplicate) {
|
if (!isDuplicate) {
|
||||||
//firestoreに挿入処理
|
//firestoreに挿入処理
|
||||||
|
InsertClassIdforFirebase insertClassIdforFirebase = new InsertClassIdforFirebase();
|
||||||
|
insertClassIdforFirebase.insertClassId(uuid);
|
||||||
//テスト用
|
//テスト用
|
||||||
uuid="100";
|
uuid=100;
|
||||||
return Integer.parseInt(uuid);
|
return uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
public class FirestoreReception_classIdDatabase {
|
public class FirestoreReception_classIdDatabase {
|
||||||
private FirebaseFirestore db;
|
private FirebaseFirestore db;
|
||||||
private List<String> classIdList= new ArrayList<>();
|
private List<Integer> classIdList= new ArrayList<>();
|
||||||
|
|
||||||
public FirestoreReception_classIdDatabase() {
|
public FirestoreReception_classIdDatabase() {
|
||||||
db = FirebaseFirestore.getInstance();
|
db = FirebaseFirestore.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> getAllDocumentsFromClassIdDatabase() {
|
public List<Integer> getAllDocumentsFromClassIdDatabase() {
|
||||||
db.collection("classId_Database")
|
db.collection("classId_Database")
|
||||||
.get()
|
.get()
|
||||||
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
|
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
|
||||||
|
@ -34,7 +34,7 @@ public class FirestoreReception_classIdDatabase {
|
||||||
for (QueryDocumentSnapshot document : task.getResult()) {
|
for (QueryDocumentSnapshot document : task.getResult()) {
|
||||||
Log.d("結果", document.getId() + " => " + document.getData());
|
Log.d("結果", document.getId() + " => " + document.getData());
|
||||||
//データをListに追加
|
//データをListに追加
|
||||||
classIdList.add((String) document.get("classId"));
|
classIdList.add(((Long) document.get("classId")).intValue());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d("結果", "Error getting documents: ", task.getException());
|
Log.d("結果", "Error getting documents: ", task.getException());
|
||||||
|
@ -45,7 +45,7 @@ public class FirestoreReception_classIdDatabase {
|
||||||
return classIdList;
|
return classIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getClassIdList() {
|
public List<Integer> getClassIdList() {
|
||||||
return classIdList;
|
return classIdList;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.example.oplogy;
|
||||||
|
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class InsertClassIdforFirebase {
|
||||||
|
public void insertClassId(int classId) {
|
||||||
|
FirebaseFirestore db = FirebaseFirestore.getInstance();
|
||||||
|
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put("classId", classId); // classId is inserted as a number
|
||||||
|
|
||||||
|
db.collection("classId_Database").add(data)
|
||||||
|
.addOnSuccessListener(documentReference -> System.out.println("DocumentSnapshot added with ID: " + documentReference.getId()))
|
||||||
|
.addOnFailureListener(e -> System.err.println("Error adding document: " + e));
|
||||||
|
}
|
||||||
|
}
|
|
@ -162,7 +162,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
//UUIDを表示するかのダイアログ
|
//UUIDを表示するかのダイアログ
|
||||||
private void showUUIDYesNoDialog() {
|
private void showUUIDYesNoDialog() {
|
||||||
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
|
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
|
||||||
List<String> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
|
List<Integer> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
|
||||||
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
|
|
@ -1,120 +1,75 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.media.Image;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
|
||||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
|
||||||
import com.google.android.gms.maps.SupportMapFragment;
|
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
|
||||||
import com.google.android.gms.maps.model.Marker;
|
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
|
||||||
import com.example.oplogy.databinding.MapsBinding;
|
import com.example.oplogy.databinding.MapsBinding;
|
||||||
import com.google.android.gms.maps.model.Polyline;
|
|
||||||
import com.google.android.gms.maps.model.PolylineOptions;
|
|
||||||
import com.google.maps.DirectionsApi;
|
|
||||||
import com.google.maps.DirectionsApiRequest;
|
|
||||||
import com.google.maps.GeoApiContext;
|
|
||||||
import com.google.maps.model.DirectionsResult;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
public class Maps extends FragmentActivity implements View.OnClickListener {
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Maps extends FragmentActivity implements OnMapReadyCallback,View.OnClickListener{
|
private WebView webView;
|
||||||
|
|
||||||
// ボタンの戻る処理
|
|
||||||
ImageView backMain;
|
ImageView backMain;
|
||||||
private GoogleMap mMap;
|
|
||||||
private MapsBinding binding;
|
private MapsBinding binding;
|
||||||
|
|
||||||
private LatLng loc;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
binding = MapsBinding.inflate(getLayoutInflater());
|
binding = MapsBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
|
|
||||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
|
||||||
.findFragmentById(R.id.map);
|
|
||||||
mapFragment.getMapAsync(this);
|
|
||||||
|
|
||||||
backMain = findViewById(R.id.BackMain);
|
backMain = findViewById(R.id.BackMain);
|
||||||
backMain.setOnClickListener(this);
|
backMain.setOnClickListener(this);
|
||||||
|
|
||||||
|
webView = findViewById(R.id.webView);
|
||||||
|
WebSettings webSettings = webView.getSettings();
|
||||||
|
webSettings.setJavaScriptEnabled(true);
|
||||||
|
webView.setWebViewClient(new WebViewClient());
|
||||||
|
|
||||||
|
// ここにデータを入れておいてください、処理は[/]で区切っています
|
||||||
|
loadMapInWebView("35.09050879999539,136.87845379325216/35.09284820618655,136.88165119390393/35.09364708442631,136.88171563326418");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WebViewの処理です(Mapの中の処理をやっています)
|
||||||
|
private void loadMapInWebView(String locations) {
|
||||||
|
// 区切ることで、追加の地点を入れて、最終地点にピンを打ってある状態です
|
||||||
|
String[] locArray = locations.split("/");
|
||||||
|
// ↓URLで経路案内(車)での表示をしています
|
||||||
|
StringBuilder urlBuilder = new StringBuilder("https://www.google.com/maps/dir/?api=1&travelmode=driving");
|
||||||
|
|
||||||
|
if (locArray.length > 0) {
|
||||||
|
urlBuilder.append("&origin=").append(locArray[0]);
|
||||||
|
|
||||||
/**
|
if (locArray.length > 1) {
|
||||||
* Manipulates the map once available.
|
urlBuilder.append("&destination=").append(locArray[locArray.length - 1]);
|
||||||
* This callback is triggered when the map is ready to be used.
|
|
||||||
* This is where we can add markers or lines, add listeners or move the camera. In this case,
|
|
||||||
* we just add a marker near Sydney, Australia.
|
|
||||||
* If Google Play services is not installed on the device, the user will be prompted to install
|
|
||||||
* it inside the SupportMapFragment. This method will only be triggered once the user has
|
|
||||||
* installed Google Play services and returned to the app.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onMapReady(GoogleMap googleMap) {
|
|
||||||
mMap = googleMap;
|
|
||||||
|
|
||||||
/// 地図の倍率を指定
|
if (locArray.length > 2) {
|
||||||
|
urlBuilder.append("&waypoints=");
|
||||||
|
for (int i = 1; i < locArray.length - 1; i++) {
|
||||||
|
urlBuilder.append(locArray[i]);
|
||||||
|
if (i < locArray.length - 2) {
|
||||||
|
urlBuilder.append("|");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ↓ここに地点の処理を書いておく↓
|
webView.loadUrl(urlBuilder.toString());
|
||||||
// Add a marker in Sydney and move the camera
|
|
||||||
loc = new LatLng(35.09050879999539, 136.87845379325216);
|
|
||||||
mMap.addMarker(new MarkerOptions().position(loc).title("名古屋港水族館"));
|
|
||||||
/// 表示位置を地図に指定
|
|
||||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(loc));
|
|
||||||
|
|
||||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 17));
|
|
||||||
|
|
||||||
LatLng startLatLng = new LatLng(35.09050879999539, 136.87845379325216);
|
|
||||||
LatLng secandLatLng = new LatLng(35.09284820618655, 136.88165119390393);
|
|
||||||
LatLng thirdLatLng = new LatLng(35.09364708442631, 136.88171563326418);
|
|
||||||
|
|
||||||
|
|
||||||
Marker startMaker = mMap.addMarker(new MarkerOptions()
|
|
||||||
.position(startLatLng)
|
|
||||||
.title("名古屋港水族館")
|
|
||||||
);
|
|
||||||
|
|
||||||
Marker secondMaker = mMap.addMarker(new MarkerOptions()
|
|
||||||
.position(secandLatLng)
|
|
||||||
.title("2番目")
|
|
||||||
);
|
|
||||||
|
|
||||||
Marker thirdMaker = mMap.addMarker(new MarkerOptions()
|
|
||||||
.position(thirdLatLng)
|
|
||||||
.title("3番目")
|
|
||||||
);
|
|
||||||
|
|
||||||
drowRoute(startLatLng,secandLatLng,thirdLatLng);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drowRoute(LatLng startLatLng,LatLng secondLatLung,LatLng thirdLatLng){
|
|
||||||
GeoApiContext context = new GeoApiContext.Builder()
|
|
||||||
.apiKey("AIzaSyBQ1Ak-I2NL5TP4K59ZI0VgzKk6HNZuusw")
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(view == backMain){
|
if (view == backMain) {
|
||||||
Intent backMain = new Intent(Maps.this,MainActivity.class);
|
Intent backMain = new Intent(Maps.this, MainActivity.class);
|
||||||
startActivity(backMain);
|
startActivity(backMain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
app/src/main/res/drawable/all_ok.png
Normal file
BIN
app/src/main/res/drawable/all_ok.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
|
@ -1,20 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:weightSum="10"
|
android:weightSum="10"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".Maps">
|
tools:context=".Maps">
|
||||||
|
|
||||||
<!-- <fragment xmlns:android="http://schemas.android.com/apk/res/android"-->
|
|
||||||
<!-- xmlns:tools="http://schemas.android.com/tools"-->
|
|
||||||
<!-- xmlns:map="http://schemas.android.com/apk/res-auto"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- android:id="@+id/map"-->
|
|
||||||
<!-- android:name="com.google.android.gms.maps.SupportMapFragment"/>-->
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -28,34 +20,28 @@
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="90dp"
|
android:layout_height="90dp"
|
||||||
android:src="@drawable/back_button"
|
android:src="@drawable/back_button"
|
||||||
android:layout_weight="5"
|
android:layout_weight="5" />
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/date"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="4"
|
android:layout_weight="4"
|
||||||
android:id="@+id/date"
|
|
||||||
android:hint="今日の日付"
|
android:hint="今日の日付"
|
||||||
android:textSize="40dp"
|
android:textSize="40dp" />
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<fragment
|
<!-- Webの処理 -->
|
||||||
android:id="@+id/map"
|
<WebView
|
||||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
android:id="@+id/webView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="6"
|
android:layout_weight="6" />
|
||||||
tools:context=".Maps" />
|
|
||||||
|
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/scrollable"
|
android:id="@+id/scrollable"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="3"
|
android:layout_weight="3" />
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user