Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
11ea004d30 | |||
9dec1476e1 | |||
7e9b9eb751 |
|
@ -5,8 +5,9 @@
|
|||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="gradleJvm" value="JDK" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -168,12 +168,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
classId = CreateUUID.generateUUID(classIdList);
|
||||
imageUuid.setImageResource(R.drawable.checked_image);
|
||||
Toast.makeText(MainActivity.this, "クラスID: " + classId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
imageUuid.setImageResource(R.drawable.checked_image);
|
||||
Log.d("DialogNO", "DialogでNoが選ばれました");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
package com.example.oplogy;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.example.oplogy.databinding.MapsBinding;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Maps extends FragmentActivity implements View.OnClickListener {
|
||||
|
||||
private WebView webView;
|
||||
private LinearLayout locationsName;
|
||||
ImageView backMain;
|
||||
private MapsBinding binding;
|
||||
|
||||
|
@ -29,19 +36,20 @@ public class Maps extends FragmentActivity implements View.OnClickListener {
|
|||
backMain.setOnClickListener(this);
|
||||
|
||||
webView = findViewById(R.id.webView);
|
||||
locationsName = findViewById(R.id.locationsName);
|
||||
WebSettings webSettings = webView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webView.setWebViewClient(new WebViewClient());
|
||||
|
||||
// ここにデータを入れておいてください、処理は[/]で区切っています
|
||||
loadMapInWebView("35.09050879999539,136.87845379325216/35.09284820618655,136.88165119390393/35.09364708442631,136.88171563326418");
|
||||
// 初期の緯度経度と名前のセットをロード
|
||||
loadMapInWebView("35.09050879999539,136.87845379325216/35.091950716938875,136.8826598363985/35.09273643623442,136.88154941341296");
|
||||
loadName("名古屋港水族館/2番目/3番目");
|
||||
}
|
||||
|
||||
// WebViewの処理です(Mapの中の処理をやっています)
|
||||
private void loadMapInWebView(String locations) {
|
||||
// 区切ることで、追加の地点を入れて、最終地点にピンを打ってある状態です
|
||||
try {
|
||||
String[] locArray = locations.split("/");
|
||||
// ↓URLで経路案内(車)での表示をしています
|
||||
StringBuilder urlBuilder = new StringBuilder("https://www.google.com/maps/dir/?api=1&travelmode=driving");
|
||||
|
||||
if (locArray.length > 0) {
|
||||
|
@ -62,7 +70,56 @@ public class Maps extends FragmentActivity implements View.OnClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
webView.loadUrl(urlBuilder.toString());
|
||||
runOnUiThread(() -> webView.loadUrl(urlBuilder.toString()));
|
||||
} catch (Exception e) {
|
||||
Log.e("Maps", "Error loading map in WebView", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 新しい名前を追加するメソッドです
|
||||
private void loadName(String locNames) {
|
||||
try {
|
||||
String[] locArray = locNames.split("/");
|
||||
|
||||
for (String loc : locArray) {
|
||||
runOnUiThread(() -> addLocationToScrollView(loc));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("Maps", "Error loading names", e);
|
||||
}
|
||||
}
|
||||
|
||||
// ScrollViewに新しい場所の名前を追加するメソッドです
|
||||
private void addLocationToScrollView(String locationName) {
|
||||
runOnUiThread(() -> {
|
||||
try {
|
||||
TextView textView = new TextView(this);
|
||||
textView.setText(locationName);
|
||||
textView.setTextSize(16);
|
||||
textView.setPadding(16, 16, 16, 16);
|
||||
|
||||
// ランダムな背景色を設定
|
||||
Random random = new Random();
|
||||
int color = Color.rgb(random.nextInt(256), random.nextInt(256), random.nextInt(256));
|
||||
textView.setBackgroundColor(color);
|
||||
|
||||
// 下線のViewを追加
|
||||
View underline = new View(this);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
2 // 下線の高さをピクセル単位で設定
|
||||
);
|
||||
params.setMargins(0, 0, 0, 16); // 下線の上下のマージンを設定
|
||||
underline.setLayoutParams(params);
|
||||
underline.setBackgroundColor(Color.BLACK); // 下線の色を設定
|
||||
|
||||
// TextViewと下線のViewを追加
|
||||
locationsName.addView(textView);
|
||||
locationsName.addView(underline);
|
||||
} catch (Exception e) {
|
||||
Log.e("Maps", "Error adding location to ScrollView", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
android:textSize="40dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Webの処理 -->
|
||||
<WebView
|
||||
android:id="@+id/webView"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -42,6 +41,11 @@
|
|||
android:id="@+id/scrollable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3" />
|
||||
|
||||
android:layout_weight="3">
|
||||
<LinearLayout
|
||||
android:id="@+id/locationsName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue
Block a user