From b8551cbb13d73cade7d3a05a489e44b9c496e817 Mon Sep 17 00:00:00 2001 From: Daniele Date: Wed, 8 Sep 2021 08:20:21 +0200 Subject: [PATCH] Working detail from list! --- .../activity/detail/GeofavoriteDetailActivity.java | 11 ++++++----- .../nextcloudmaps/activity/main/MainActivity.java | 10 +++++++--- .../nextcloudmaps/api/ApiProvider.java | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java index 1e90d78..b420126 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/detail/GeofavoriteDetailActivity.java @@ -44,7 +44,7 @@ import retrofit2.Response; public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback { public static final String TAG = "GeofavDetail"; - public static final String ARG_GEOFAVORITE_ID = "geofavid"; + public static final String ARG_GEOFAVORITE = "geofav"; private static final int PERMISSION_REQUEST_CODE = 9999; private ActivityGeofavoriteDetailBinding binding; @@ -56,8 +56,11 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca binding = ActivityGeofavoriteDetailBinding.inflate(getLayoutInflater()); setContentView(binding.root); - int id = getIntent().getIntExtra(ARG_GEOFAVORITE_ID, 0); - if (id == 0) { + if (getIntent().hasExtra(ARG_GEOFAVORITE)) { + // Opening geofavorite from list + Geofavorite gfFromList = (Geofavorite) getIntent().getSerializableExtra(ARG_GEOFAVORITE); + binding.setGeofavorite(gfFromList); + } else { // New geofavorite Geofavorite gf = new Geofavorite(); gf.setDateCreated(System.currentTimeMillis()); @@ -65,8 +68,6 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca binding.setGeofavorite(gf); // Precompile location getLocation(); - } else { - // TODO: Load geofavorite from cache for edit } } diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java index 3468418..9435985 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/activity/main/MainActivity.java @@ -22,8 +22,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.text.TextUtils; -import android.util.Log; -import android.view.View; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; @@ -127,7 +125,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti @Override public void onItemDetailsClick(Geofavorite item) { - Log.d("MENU", "Details "+item.getName()); + showGeofavoriteDetailActivity(item); } @Override @@ -338,4 +336,10 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti builder.create(); } + private void showGeofavoriteDetailActivity(Geofavorite item) { + Intent i = new Intent(this, GeofavoriteDetailActivity.class); + i.putExtra(GeofavoriteDetailActivity.ARG_GEOFAVORITE, item); + startActivity(i); + } + } \ No newline at end of file diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/api/ApiProvider.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/api/ApiProvider.java index c40d264..9dcb03b 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/api/ApiProvider.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/api/ApiProvider.java @@ -48,12 +48,12 @@ public class ApiProvider { initSsoApi(new NextcloudAPI.ApiConnectedListener() { @Override public void onConnected() { - // Ignore.. + Log.d(TAG, "Connected to Nextcloud instance"); } @Override public void onError(Exception ex) { - // Ignore... + Log.d(TAG, "Unable to connect to Nextcloud instance: " + ex.toString()); } }); }