clean
This commit is contained in:
parent
6fee719c3b
commit
65b45bc19c
@ -12,6 +12,7 @@ import android.widget.Toast;
|
|||||||
import com.amine.myterio.app.adapters.ForecastAdapter;
|
import com.amine.myterio.app.adapters.ForecastAdapter;
|
||||||
import com.amine.myterio.app.api.WeatherAdapters;
|
import com.amine.myterio.app.api.WeatherAdapters;
|
||||||
import com.amine.myterio.app.api.WeatherApis;
|
import com.amine.myterio.app.api.WeatherApis;
|
||||||
|
import com.amine.myterio.app.config.Config;
|
||||||
import com.amine.myterio.app.model.City;
|
import com.amine.myterio.app.model.City;
|
||||||
import com.amine.myterio.app.model.Forecast;
|
import com.amine.myterio.app.model.Forecast;
|
||||||
import retrofit.Callback;
|
import retrofit.Callback;
|
||||||
@ -39,7 +40,7 @@ public class DetailsActivity extends AppCompatActivity {
|
|||||||
if (cityName != null) {
|
if (cityName != null) {
|
||||||
WeatherApis.WeatherDailyForecastLocationApi s = adapters.getWeatherForecastLocationAdapter();
|
WeatherApis.WeatherDailyForecastLocationApi s = adapters.getWeatherForecastLocationAdapter();
|
||||||
|
|
||||||
s.cityForecast(cityName, new Callback<Forecast>() {
|
s.cityForecast(cityName, Config.country, new Callback<Forecast>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(Forecast forecast, Response response) {
|
public void success(Forecast forecast, Response response) {
|
||||||
f[0] = forecast;
|
f[0] = forecast;
|
||||||
@ -49,12 +50,12 @@ public class DetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(RetrofitError error) {
|
public void failure(RetrofitError error) {
|
||||||
Toast.makeText(getApplicationContext(), "Pas de pr<70>visions pour cette ville.", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), getString(R.string.weather_not_available), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
WeatherApis.WeatherLocationApi sWeather = adapters.getWeatherLocationAdapter();
|
WeatherApis.WeatherLocationApi sWeather = adapters.getWeatherLocationAdapter();
|
||||||
sWeather.locationWeather(cityName, new Callback<City>() {
|
sWeather.locationWeather(cityName, Config.country, new Callback<City>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(City c, Response response) {
|
public void success(City c, Response response) {
|
||||||
ImageView image = (ImageView) findViewById(R.id.weatherImage);
|
ImageView image = (ImageView) findViewById(R.id.weatherImage);
|
||||||
@ -63,7 +64,7 @@ public class DetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(RetrofitError error) {
|
public void failure(RetrofitError error) {
|
||||||
Toast.makeText(DetailsActivity.this, "Hello toast!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(DetailsActivity.this, getString(R.string.weather_get_error), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -71,7 +72,7 @@ public class DetailsActivity extends AppCompatActivity {
|
|||||||
cityName = city.getName();
|
cityName = city.getName();
|
||||||
WeatherApis.WeatherDailyForecastApi s = adapters.getWeatherForecastAdapter();
|
WeatherApis.WeatherDailyForecastApi s = adapters.getWeatherForecastAdapter();
|
||||||
|
|
||||||
s.cityForecast(city.getCityIdentifier(), new Callback<Forecast>() {
|
s.cityForecast(city.getCityIdentifier(), Config.country, new Callback<Forecast>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(Forecast forecast, Response response) {
|
public void success(Forecast forecast, Response response) {
|
||||||
f[0] = forecast;
|
f[0] = forecast;
|
||||||
@ -80,7 +81,7 @@ public class DetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(RetrofitError error) {
|
public void failure(RetrofitError error) {
|
||||||
Toast.makeText(getApplicationContext(), "Pas de pr<70>visions pour cette ville.", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), getString(R.string.weather_not_available), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ public class DetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(RetrofitError error) {
|
public void failure(RetrofitError error) {
|
||||||
Toast.makeText(DetailsActivity.this, "Hello toast!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(DetailsActivity.this, getString(R.string.weather_get_error), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.amine.myterio.app;
|
package com.amine.myterio.app;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -7,10 +8,12 @@ import android.support.v7.app.AppCompatActivity;
|
|||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import com.amine.myterio.app.adapters.CitiesAdapter;
|
import com.amine.myterio.app.adapters.CitiesAdapter;
|
||||||
|
import com.amine.myterio.app.config.Config;
|
||||||
import com.amine.myterio.app.db.CityDAO;
|
import com.amine.myterio.app.db.CityDAO;
|
||||||
import com.amine.myterio.app.model.City;
|
import com.amine.myterio.app.model.City;
|
||||||
import com.melnykov.fab.FloatingActionButton;
|
import com.melnykov.fab.FloatingActionButton;
|
||||||
@ -20,33 +23,23 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private RecyclerView mRecyclerView;
|
|
||||||
private RecyclerView.Adapter mAdapter;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
handleView();
|
handleView();
|
||||||
|
|
||||||
/* WeatherAdapters adapters = new WeatherAdapters();
|
|
||||||
WeatherApis.WeatherDailyForecastApi s = adapters.getWeatherForecastAdapter();
|
|
||||||
s.cityForecast(1851632, new Callback<Forecast>() {
|
|
||||||
@Override
|
|
||||||
public void success(Forecast forecast, Response response) {
|
|
||||||
Toast.makeText(getApplicationContext(), "Hello toast!", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void saveUserCountry() {
|
||||||
public void failure(RetrofitError error) {
|
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
Toast.makeText(getApplicationContext(), "Hello toast!", Toast.LENGTH_SHORT).show();
|
Config.country = tm.getSimCountryIso().toLowerCase();
|
||||||
}
|
if (Config.country == null || Config.country.equals("") || Config.country.isEmpty())
|
||||||
});*/
|
Config.country = MainActivity.this.getResources().getConfiguration().locale.getCountry().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleView() {
|
private void handleView() {
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
mRecyclerView = (RecyclerView) findViewById(R.id.list);
|
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.list);
|
||||||
|
saveUserCountry();
|
||||||
|
|
||||||
// Google way to test is tablet
|
// Google way to test is tablet
|
||||||
boolean isTablet = ((this.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);
|
boolean isTablet = ((this.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);
|
||||||
@ -62,18 +55,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
mRecyclerView.setLayoutManager(layoutManager);
|
mRecyclerView.setLayoutManager(layoutManager);
|
||||||
mRecyclerView.setHasFixedSize(true);
|
mRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
ArrayList<City> cities = new ArrayList<City>();
|
ArrayList<City> cities;
|
||||||
|
|
||||||
CityDAO dao = CityDAO.getInstance(this);
|
CityDAO dao = CityDAO.getInstance(this);
|
||||||
|
|
||||||
City c = new City("Cairns", 2172797);
|
|
||||||
City c1 = new City("Moscow", 524901);
|
|
||||||
|
|
||||||
dao.insertCity(c);
|
|
||||||
dao.insertCity(c1);
|
|
||||||
cities = dao.getAllCities();
|
cities = dao.getAllCities();
|
||||||
|
|
||||||
mAdapter = new CitiesAdapter(cities, this);
|
RecyclerView.Adapter mAdapter = new CitiesAdapter(cities, this);
|
||||||
mRecyclerView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||||
|
@ -9,9 +9,9 @@ import android.view.View;
|
|||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import com.amine.myterio.app.api.CitiesAdapters;
|
import com.amine.myterio.app.api.CitiesAdapters;
|
||||||
import com.amine.myterio.app.api.CitiesApi;
|
import com.amine.myterio.app.api.CitiesApi;
|
||||||
import com.amine.myterio.app.api.Predictions;
|
|
||||||
import com.amine.myterio.app.config.Config;
|
import com.amine.myterio.app.config.Config;
|
||||||
import com.amine.myterio.app.model.Countries;
|
import com.amine.myterio.app.model.Countries;
|
||||||
|
import com.amine.myterio.app.model.Predictions;
|
||||||
import retrofit.Callback;
|
import retrofit.Callback;
|
||||||
import retrofit.RetrofitError;
|
import retrofit.RetrofitError;
|
||||||
import retrofit.client.Response;
|
import retrofit.client.Response;
|
||||||
|
@ -13,6 +13,7 @@ import com.amine.myterio.app.DetailsActivity;
|
|||||||
import com.amine.myterio.app.R;
|
import com.amine.myterio.app.R;
|
||||||
import com.amine.myterio.app.api.WeatherAdapters;
|
import com.amine.myterio.app.api.WeatherAdapters;
|
||||||
import com.amine.myterio.app.api.WeatherApis;
|
import com.amine.myterio.app.api.WeatherApis;
|
||||||
|
import com.amine.myterio.app.config.Config;
|
||||||
import com.amine.myterio.app.model.City;
|
import com.amine.myterio.app.model.City;
|
||||||
import retrofit.Callback;
|
import retrofit.Callback;
|
||||||
import retrofit.RetrofitError;
|
import retrofit.RetrofitError;
|
||||||
@ -21,19 +22,18 @@ import retrofit.client.Response;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CitiesAdapter extends RecyclerView.Adapter<CitiesAdapter.ViewHolder> {
|
public class CitiesAdapter extends RecyclerView.Adapter<CitiesAdapter.ViewHolder> {
|
||||||
private static ArrayList<City> mDataset;
|
private ArrayList<City> mDataset;
|
||||||
private static Context c;
|
private Context c;
|
||||||
|
|
||||||
public CitiesAdapter(ArrayList<City> cities, Context c) {
|
public CitiesAdapter(ArrayList<City> cities, Context c) {
|
||||||
mDataset = cities;
|
this.mDataset = cities;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.city_card_view, parent, false);
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.city_card_view, parent, false);
|
||||||
ViewHolder vh = new ViewHolder(v);
|
return new ViewHolder(v);
|
||||||
return vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +44,7 @@ public class CitiesAdapter extends RecyclerView.Adapter<CitiesAdapter.ViewHolder
|
|||||||
|
|
||||||
WeatherAdapters adapters = new WeatherAdapters();
|
WeatherAdapters adapters = new WeatherAdapters();
|
||||||
WeatherApis.WeatherCityApi s = adapters.getWeatherCityAdapter();
|
WeatherApis.WeatherCityApi s = adapters.getWeatherCityAdapter();
|
||||||
s.cityWeather(currentCity[0].getCityIdentifier(), new Callback<City>() {
|
s.cityWeather(currentCity[0].getCityIdentifier(), Config.country, new Callback<City>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(City city, Response response) {
|
public void success(City city, Response response) {
|
||||||
currentCity[0] = city;
|
currentCity[0] = city;
|
||||||
@ -71,7 +71,7 @@ public class CitiesAdapter extends RecyclerView.Adapter<CitiesAdapter.ViewHolder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(RetrofitError error) {
|
public void failure(RetrofitError error) {
|
||||||
Toast.makeText(c, "Hello toast!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(c, c.getString(R.string.weather_get_error), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ public class CitiesAdapter extends RecyclerView.Adapter<CitiesAdapter.ViewHolder
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements RecyclerView.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements RecyclerView.OnClickListener {
|
||||||
public View mCardView;
|
public final View mCardView;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -15,9 +15,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class ForecastAdapter extends RecyclerView.Adapter<ForecastAdapter.ViewHolder> {
|
public class ForecastAdapter extends RecyclerView.Adapter<ForecastAdapter.ViewHolder> {
|
||||||
private static Forecast forecast;
|
private Forecast forecast;
|
||||||
private static Context c;
|
private Context c;
|
||||||
|
|
||||||
public ForecastAdapter(Context c, Forecast forecast) {
|
public ForecastAdapter(Context c, Forecast forecast) {
|
||||||
this.forecast = forecast;
|
this.forecast = forecast;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
@ -27,8 +26,7 @@ public class ForecastAdapter extends RecyclerView.Adapter<ForecastAdapter.ViewHo
|
|||||||
@Override
|
@Override
|
||||||
public ForecastAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ForecastAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.detail_item, parent, false);
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.detail_item, parent, false);
|
||||||
ViewHolder vh = new ViewHolder(v);
|
return new ViewHolder(v);
|
||||||
return vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -52,7 +50,7 @@ public class ForecastAdapter extends RecyclerView.Adapter<ForecastAdapter.ViewHo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
public View itemView;
|
public final View itemView;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -3,7 +3,7 @@ package com.amine.myterio.app.api;
|
|||||||
import retrofit.RestAdapter;
|
import retrofit.RestAdapter;
|
||||||
|
|
||||||
public class CitiesAdapters {
|
public class CitiesAdapters {
|
||||||
RestAdapter restAdapter;
|
private final RestAdapter restAdapter;
|
||||||
|
|
||||||
public CitiesAdapters() {
|
public CitiesAdapters() {
|
||||||
this.restAdapter = new RestAdapter.Builder()
|
this.restAdapter = new RestAdapter.Builder()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.amine.myterio.app.api;
|
package com.amine.myterio.app.api;
|
||||||
|
|
||||||
|
import com.amine.myterio.app.model.Predictions;
|
||||||
import retrofit.Callback;
|
import retrofit.Callback;
|
||||||
import retrofit.http.GET;
|
import retrofit.http.GET;
|
||||||
import retrofit.http.Query;
|
import retrofit.http.Query;
|
||||||
|
@ -3,7 +3,7 @@ package com.amine.myterio.app.api;
|
|||||||
import retrofit.RestAdapter;
|
import retrofit.RestAdapter;
|
||||||
|
|
||||||
public class WeatherAdapters {
|
public class WeatherAdapters {
|
||||||
RestAdapter restAdapter;
|
private final RestAdapter restAdapter;
|
||||||
|
|
||||||
|
|
||||||
public WeatherAdapters() {
|
public WeatherAdapters() {
|
||||||
|
@ -9,19 +9,19 @@ import retrofit.http.Query;
|
|||||||
public class WeatherApis {
|
public class WeatherApis {
|
||||||
public interface WeatherLocationApi {
|
public interface WeatherLocationApi {
|
||||||
@GET("/data/2.5/weather")
|
@GET("/data/2.5/weather")
|
||||||
void locationWeather(@Query("q") String location, Callback<City> cb);
|
void locationWeather(@Query("q") String location, @Query("lang") String lang, Callback<City> cb);
|
||||||
}
|
}
|
||||||
public interface WeatherCityApi {
|
public interface WeatherCityApi {
|
||||||
@GET("/data/2.5/weather")
|
@GET("/data/2.5/weather")
|
||||||
void cityWeather(@Query("id") int city, Callback<City> cb);
|
void cityWeather(@Query("id") int city, @Query("lang") String lang, Callback<City> cb);
|
||||||
}
|
}
|
||||||
public interface WeatherDailyForecastApi {
|
public interface WeatherDailyForecastApi {
|
||||||
@GET("/data/2.5/forecast/daily?units=metric&cnt=7")
|
@GET("/data/2.5/forecast/daily?units=metric&cnt=7")
|
||||||
void cityForecast(@Query("id") int city, Callback<Forecast> cb);
|
void cityForecast(@Query("id") int city, @Query("lang") String lang, Callback<Forecast> cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface WeatherDailyForecastLocationApi {
|
public interface WeatherDailyForecastLocationApi {
|
||||||
@GET("/data/2.5/forecast/daily?units=metric&cnt=7")
|
@GET("/data/2.5/forecast/daily?units=metric&cnt=7")
|
||||||
void cityForecast(@Query("q") String location, Callback<Forecast> cb);
|
void cityForecast(@Query("q") String location, @Query("lang") String lang, Callback<Forecast> cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.amine.myterio.app.config;
|
package com.amine.myterio.app.config;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
public static String placesApiKey = "AIzaSyDxSXMcZK1Ybjkz-IuN2EhhFCwRSbaianE";
|
public static final String placesApiKey = "AIzaSyDxSXMcZK1Ybjkz-IuN2EhhFCwRSbaianE";
|
||||||
|
public static String country = "FR";
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,11 @@ public class CityDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open() {
|
private void open() {
|
||||||
bdd = maBaseSQLite.getWritableDatabase();
|
bdd = maBaseSQLite.getWritableDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
private void close() {
|
||||||
bdd.close();
|
bdd.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
public class CityDB extends SQLiteOpenHelper {
|
class CityDB extends SQLiteOpenHelper {
|
||||||
|
|
||||||
private static final String TABLE_CITIES = "cities";
|
private static final String TABLE_CITIES = "cities";
|
||||||
private static final String COL_ID = "ID";
|
private static final String COL_ID = "ID";
|
||||||
|
@ -18,11 +18,11 @@ public class City implements Parcelable {
|
|||||||
return new City[size];
|
return new City[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public String name;
|
private String name;
|
||||||
public int id;
|
private int id;
|
||||||
public MainInfo main;
|
private MainInfo main;
|
||||||
public List<Weather> weather;
|
private List<Weather> weather;
|
||||||
public Wind wind;
|
private Wind wind;
|
||||||
|
|
||||||
public City(String name, int id) {
|
public City(String name, int id) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -38,7 +38,7 @@ public class City implements Parcelable {
|
|||||||
this.name = description;
|
this.name = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public City(Parcel source) {
|
private City(Parcel source) {
|
||||||
this.name = source.readString();
|
this.name = source.readString();
|
||||||
this.id = source.readInt();
|
this.id = source.readInt();
|
||||||
this.main = source.readParcelable(MainInfo.class.getClassLoader());
|
this.main = source.readParcelable(MainInfo.class.getClassLoader());
|
||||||
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Countries {
|
public class Countries {
|
||||||
public List<Country> countries;
|
private List<Country> countries;
|
||||||
|
|
||||||
public Countries() {
|
public Countries() {
|
||||||
countries = new ArrayList<Country>();
|
countries = new ArrayList<Country>();
|
||||||
|
@ -3,9 +3,9 @@ package com.amine.myterio.app.model;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Country {
|
class Country {
|
||||||
public String name;
|
private String name;
|
||||||
public List<City> cities;
|
private List<City> cities;
|
||||||
|
|
||||||
public Country() {
|
public Country() {
|
||||||
cities = new ArrayList<City>();
|
cities = new ArrayList<City>();
|
||||||
|
@ -3,8 +3,8 @@ package com.amine.myterio.app.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Forecast {
|
public class Forecast {
|
||||||
public City city;
|
private City city;
|
||||||
public List<ForecastWeather> list;
|
private List<ForecastWeather> list;
|
||||||
|
|
||||||
public City getCity() {
|
public City getCity() {
|
||||||
return city;
|
return city;
|
||||||
|
@ -3,10 +3,10 @@ package com.amine.myterio.app.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ForecastWeather {
|
public class ForecastWeather {
|
||||||
public TempInfo temp;
|
private TempInfo temp;
|
||||||
public List<Weather> weather;
|
private List<Weather> weather;
|
||||||
public float speed;
|
private float speed;
|
||||||
public int dt;
|
private int dt;
|
||||||
|
|
||||||
public TempInfo getTemp() {
|
public TempInfo getTemp() {
|
||||||
return temp;
|
return temp;
|
||||||
|
@ -15,9 +15,9 @@ public class MainInfo implements Parcelable {
|
|||||||
return new MainInfo[size];
|
return new MainInfo[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public float temp;
|
private float temp;
|
||||||
public float temp_max;
|
private float temp_max;
|
||||||
public float temp_min;
|
private float temp_min;
|
||||||
|
|
||||||
public MainInfo(Parcel source) {
|
public MainInfo(Parcel source) {
|
||||||
this.temp = source.readFloat();
|
this.temp = source.readFloat();
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.amine.myterio.app.api;
|
package com.amine.myterio.app.model;
|
||||||
|
|
||||||
import com.amine.myterio.app.model.City;
|
|
||||||
|
|
||||||
public class PredictionCities {
|
public class PredictionCities {
|
||||||
public String description;
|
private String description;
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
@ -1,10 +1,10 @@
|
|||||||
package com.amine.myterio.app.api;
|
package com.amine.myterio.app.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Predictions {
|
public class Predictions {
|
||||||
public List<PredictionCities> predictions;
|
private List<PredictionCities> predictions;
|
||||||
|
|
||||||
public List<PredictionCities> getPredictions() {
|
public List<PredictionCities> getPredictions() {
|
||||||
return predictions;
|
return predictions;
|
@ -1,12 +1,12 @@
|
|||||||
package com.amine.myterio.app.model;
|
package com.amine.myterio.app.model;
|
||||||
|
|
||||||
public class TempInfo {
|
public class TempInfo {
|
||||||
public float day;
|
private float day;
|
||||||
public float min;
|
private float min;
|
||||||
public float max;
|
private float max;
|
||||||
public float night;
|
private float night;
|
||||||
public float eve;
|
private float eve;
|
||||||
public float morn;
|
private float morn;
|
||||||
|
|
||||||
public float getDay() {
|
public float getDay() {
|
||||||
return day;
|
return day;
|
||||||
|
@ -4,10 +4,10 @@ import android.content.Context;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
public class Weather {
|
public class Weather {
|
||||||
public String description;
|
private String description;
|
||||||
public String icon;
|
private String icon;
|
||||||
public int id;
|
private int id;
|
||||||
public String main;
|
private String main;
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
@ -17,10 +17,14 @@ public class Weather {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIcon() {
|
private String getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIcon(String icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
public Drawable getIconDrawable(Context c, String packageName) {
|
public Drawable getIconDrawable(Context c, String packageName) {
|
||||||
String uri = "@mipmap/";
|
String uri = "@mipmap/";
|
||||||
|
|
||||||
@ -77,10 +81,6 @@ public class Weather {
|
|||||||
return c.getResources().getDrawable(imageResource);
|
return c.getResources().getDrawable(imageResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIcon(String icon) {
|
|
||||||
this.icon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.amine.myterio.app.model;
|
package com.amine.myterio.app.model;
|
||||||
|
|
||||||
public class Wind {
|
public class Wind {
|
||||||
public float deg;
|
private float deg;
|
||||||
public float speed;
|
private float speed;
|
||||||
|
|
||||||
public float getDeg() {
|
public float getDeg() {
|
||||||
return deg;
|
return deg;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:baselineAligned="false"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@ -35,7 +36,6 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
android:text="Large Text"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -45,7 +45,6 @@
|
|||||||
android:layout_alignLeft="@+id/max_temp"
|
android:layout_alignLeft="@+id/max_temp"
|
||||||
android:layout_alignStart="@+id/max_temp"
|
android:layout_alignStart="@+id/max_temp"
|
||||||
android:layout_alignTop="@+id/imageView2"
|
android:layout_alignTop="@+id/imageView2"
|
||||||
android:text="Medium Text"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -55,7 +54,6 @@
|
|||||||
android:layout_alignTop="@+id/imageView"
|
android:layout_alignTop="@+id/imageView"
|
||||||
android:layout_toEndOf="@+id/imageView"
|
android:layout_toEndOf="@+id/imageView"
|
||||||
android:layout_toRightOf="@+id/imageView"
|
android:layout_toRightOf="@+id/imageView"
|
||||||
android:text="Medium Text"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -86,7 +84,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:text="Medium Text"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -118,7 +115,6 @@
|
|||||||
android:layout_below="@+id/weather_image"
|
android:layout_below="@+id/weather_image"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
android:text="Small Text"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -128,7 +124,6 @@
|
|||||||
android:layout_above="@+id/weather_image"
|
android:layout_above="@+id/weather_image"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginBottom="25dp"
|
android:layout_marginBottom="25dp"
|
||||||
android:text="Medium Text"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
9
app/src/main/res/values-en/strings.xml
Normal file
9
app/src/main/res/values-en/strings.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Myterio</string>
|
||||||
|
<string name="hello_world">Hello world!</string>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
<string name="title_activity_search">SearchActivity</string>
|
||||||
|
<string name="title_activity_details">DetailsActivity</string>
|
||||||
|
<string name="weather_not_available">This location dosn\'t have any weather.</string>
|
||||||
|
<string name="weather_get_error">Can\'t get the weather from the API.</string>
|
||||||
|
</resources>
|
@ -1,6 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
|
||||||
(such as screen margins) for screens with more than 820dp of available width. This
|
|
||||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
|
||||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
|
||||||
</resources>
|
|
@ -1,7 +1,9 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Myterio</string>
|
<string name="app_name" translatable="false">Myterio</string>
|
||||||
<string name="hello_world">Hello world!</string>
|
<string name="hello_world">Hello world!</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="title_activity_search">SearchActivity</string>
|
<string name="title_activity_search" translatable="false">SearchActivity</string>
|
||||||
<string name="title_activity_details">DetailsActivity</string>
|
<string name="title_activity_details" translatable="false">DetailsActivity</string>
|
||||||
|
<string name="weather_not_available">Pas de prévisions pour cette ville.</string>
|
||||||
|
<string name="weather_get_error">Erreur lors de la récupération des prévisions</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user