Working detail from list!

This commit is contained in:
Daniele 2021-09-08 08:20:21 +02:00
parent 9161b61b6e
commit b8551cbb13
3 changed files with 15 additions and 10 deletions

View File

@ -44,7 +44,7 @@ import retrofit2.Response;
public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback { public class GeofavoriteDetailActivity extends AppCompatActivity implements LocationListener, ActivityCompat.OnRequestPermissionsResultCallback {
public static final String TAG = "GeofavDetail"; 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 static final int PERMISSION_REQUEST_CODE = 9999;
private ActivityGeofavoriteDetailBinding binding; private ActivityGeofavoriteDetailBinding binding;
@ -56,8 +56,11 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
binding = ActivityGeofavoriteDetailBinding.inflate(getLayoutInflater()); binding = ActivityGeofavoriteDetailBinding.inflate(getLayoutInflater());
setContentView(binding.root); setContentView(binding.root);
int id = getIntent().getIntExtra(ARG_GEOFAVORITE_ID, 0); if (getIntent().hasExtra(ARG_GEOFAVORITE)) {
if (id == 0) { // Opening geofavorite from list
Geofavorite gfFromList = (Geofavorite) getIntent().getSerializableExtra(ARG_GEOFAVORITE);
binding.setGeofavorite(gfFromList);
} else {
// New geofavorite // New geofavorite
Geofavorite gf = new Geofavorite(); Geofavorite gf = new Geofavorite();
gf.setDateCreated(System.currentTimeMillis()); gf.setDateCreated(System.currentTimeMillis());
@ -65,8 +68,6 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
binding.setGeofavorite(gf); binding.setGeofavorite(gf);
// Precompile location // Precompile location
getLocation(); getLocation();
} else {
// TODO: Load geofavorite from cache for edit
} }
} }

View File

@ -22,8 +22,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@ -127,7 +125,7 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
@Override @Override
public void onItemDetailsClick(Geofavorite item) { public void onItemDetailsClick(Geofavorite item) {
Log.d("MENU", "Details "+item.getName()); showGeofavoriteDetailActivity(item);
} }
@Override @Override
@ -338,4 +336,10 @@ public class MainActivity extends AppCompatActivity implements MainView, OnSorti
builder.create(); builder.create();
} }
private void showGeofavoriteDetailActivity(Geofavorite item) {
Intent i = new Intent(this, GeofavoriteDetailActivity.class);
i.putExtra(GeofavoriteDetailActivity.ARG_GEOFAVORITE, item);
startActivity(i);
}
} }

View File

@ -48,12 +48,12 @@ public class ApiProvider {
initSsoApi(new NextcloudAPI.ApiConnectedListener() { initSsoApi(new NextcloudAPI.ApiConnectedListener() {
@Override @Override
public void onConnected() { public void onConnected() {
// Ignore.. Log.d(TAG, "Connected to Nextcloud instance");
} }
@Override @Override
public void onError(Exception ex) { public void onError(Exception ex) {
// Ignore... Log.d(TAG, "Unable to connect to Nextcloud instance: " + ex.toString());
} }
}); });
} }