Compare commits
No commits in common. "88101f58ca1eca0d522ab3d9d87dac58eddf4883" and "39779040ad1ad1786fd9f1b8fd9f61ed30698cdb" have entirely different histories.
88101f58ca
...
39779040ad
@ -1,19 +1,9 @@
|
|||||||
package fr.romanet.vj.apps.myweather;
|
package fr.romanet.vj.apps.myweather;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import fr.romanet.vj.apps.myweather.bo.City;
|
|
||||||
import fr.romanet.vj.apps.myweather.repository.CityRepository;
|
|
||||||
|
|
||||||
public class ShowTemparature extends AppCompatActivity {
|
public class ShowTemparature extends AppCompatActivity {
|
||||||
|
|
||||||
@ -33,36 +23,4 @@ public class ShowTemparature extends AppCompatActivity {
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.menu_items, menu);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item)
|
|
||||||
{
|
|
||||||
//We handle the click on a menu item
|
|
||||||
if (item.getItemId() == R.id.item_delete)
|
|
||||||
{
|
|
||||||
cityToDelete();
|
|
||||||
Intent intent = new Intent(ShowTemparature.this, MainActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cityToDelete()
|
|
||||||
{
|
|
||||||
final List<City> city = CityRepository.getInstance(this).getCity();
|
|
||||||
for(int i = 0; i < city.size(); i++)
|
|
||||||
{
|
|
||||||
if(city.get(i).nameCity.equals(currentCityName))
|
|
||||||
{
|
|
||||||
CityRepository.getInstance(this).deleteCity(city.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/item_delete"
|
|
||||||
android:title="@string/deleteItem"
|
|
||||||
app:showAsAction="never"/>
|
|
||||||
</menu>
|
|
||||||
@ -13,6 +13,5 @@
|
|||||||
<string name="title_activity_test_constraint_layout">TestConstraintLayout</string>
|
<string name="title_activity_test_constraint_layout">TestConstraintLayout</string>
|
||||||
|
|
||||||
<string name="firstAction">Please click on the Add button in order to add a city</string>
|
<string name="firstAction">Please click on the Add button in order to add a city</string>
|
||||||
<string name="deleteItem">Delete</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue
Block a user