Working detail from list!
This commit is contained in:
		| @@ -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 | ||||
|         } | ||||
|  | ||||
|     } | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -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()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user