diff --git a/app/build.gradle b/app/build.gradle index 8feda43..4f8dfd2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -40,4 +40,11 @@ testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + + // Retrofit + implementation "com.squareup.retrofit2:retrofit:2.9.0" + implementation "com.squareup.retrofit2:converter-moshi:2.9.0" + + implementation 'com.squareup.retrofit2:converter-jackson:2.5.0' + implementation 'com.squareup.retrofit2:converter-scalars:2.1.0' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bbea84c..f68ab2f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,7 +30,7 @@ android:value="YOUR_API_KEY" /> diff --git a/app/src/main/java/com/example/nemophila/MainActivity.java b/app/src/main/java/com/example/nemophila/MainActivity.java new file mode 100644 index 0000000..a01b35d --- /dev/null +++ b/app/src/main/java/com/example/nemophila/MainActivity.java @@ -0,0 +1,51 @@ +package com.example.nemophila; + +import androidx.fragment.app.FragmentActivity; + +import android.os.Bundle; + +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.LatLng; +import com.google.android.gms.maps.model.MarkerOptions; +import com.example.nemophila.databinding.ActivityMainBinding; + +public class MainActivity extends FragmentActivity implements OnMapReadyCallback { + + private GoogleMap mMap; + private ActivityMainBinding binding; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + binding = ActivityMainBinding.inflate(getLayoutInflater()); + 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); + } + + /** + * Manipulates the map once available. + * 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; + + // Add a marker in Sydney and move the camera + LatLng sydney = new LatLng(-34, 151); + mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); + mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/nemophila/MapsActivity.java b/app/src/main/java/com/example/nemophila/MapsActivity.java deleted file mode 100644 index e53633c..0000000 --- a/app/src/main/java/com/example/nemophila/MapsActivity.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.example.nemophila; - -import androidx.fragment.app.FragmentActivity; - -import android.os.Bundle; - -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.LatLng; -import com.google.android.gms.maps.model.MarkerOptions; -import com.example.nemophila.databinding.ActivityMapsBinding; - -public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { - - private GoogleMap mMap; - private ActivityMapsBinding binding; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - binding = ActivityMapsBinding.inflate(getLayoutInflater()); - 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); - } - - /** - * Manipulates the map once available. - * 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; - - // Add a marker in Sydney and move the camera - LatLng sydney = new LatLng(-34, 151); - mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); - mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..cfbceaa --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,9 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_maps.xml b/app/src/main/res/layout/activity_maps.xml deleted file mode 100644 index ec352fc..0000000 --- a/app/src/main/res/layout/activity_maps.xml +++ /dev/null @@ -1,9 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bf26a7a..9b0bb0e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ Nemophila - MapsActivity + MainActivity PostActivity \ No newline at end of file