From: gu.martinm@gmail.com Date: Tue, 22 Apr 2014 01:58:43 +0000 (+0200) Subject: WeatherInformation: latest changes for tabs X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=ab042560bd6d8f4dbeb1548891a41c4d5bd5883a;p=JavaForFun WeatherInformation: latest changes for tabs --- diff --git a/Android/WeatherInformation/res/layout/fragment_pager_list.xml b/Android/WeatherInformation/res/layout/fragment_pager_list.xml deleted file mode 100644 index e4a1c55..0000000 --- a/Android/WeatherInformation/res/layout/fragment_pager_list.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Android/WeatherInformation/res/layout/weather_current_data_entry_fourth.xml b/Android/WeatherInformation/res/layout/weather_current_data_entry_fourth.xml index d5a3207..da2d94e 100644 --- a/Android/WeatherInformation/res/layout/weather_current_data_entry_fourth.xml +++ b/Android/WeatherInformation/res/layout/weather_current_data_entry_fourth.xml @@ -2,7 +2,7 @@ + android:layout_height="140dp" > (getActivity(), - android.R.layout.simple_list_item_1, chesses)); - } - - @Override - public void onListItemClick(final ListView l, final View v, final int position, final long id) { - Log.i("FragmentList", "Item clicked: " + id); - } - } - - } diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/ErrorDialogFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/ErrorDialogFragment.java index 76cb89a..33876e2 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/ErrorDialogFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/ErrorDialogFragment.java @@ -2,9 +2,9 @@ package de.example.exampletdd.fragment; import android.app.AlertDialog; import android.app.Dialog; -import android.app.DialogFragment; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import de.example.exampletdd.R; public class ErrorDialogFragment extends DialogFragment { diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/ProgressDialogFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/ProgressDialogFragment.java index a21f321..7ff9960 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/ProgressDialogFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/ProgressDialogFragment.java @@ -1,10 +1,10 @@ package de.example.exampletdd.fragment; import android.app.Dialog; -import android.app.DialogFragment; import android.app.ProgressDialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.KeyEvent; public class ProgressDialogFragment extends DialogFragment { diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/WeatherInformationCurrentDataFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/WeatherInformationCurrentDataFragment.java index 00a03a1..0a04dc0 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/WeatherInformationCurrentDataFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/WeatherInformationCurrentDataFragment.java @@ -14,7 +14,6 @@ import java.util.Locale; import org.apache.http.client.ClientProtocolException; -import android.app.DialogFragment; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -22,6 +21,7 @@ import android.net.http.AndroidHttpClient; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v4.app.DialogFragment; import android.support.v4.app.ListFragment; import android.util.Log; import android.widget.ListView; @@ -29,6 +29,7 @@ import android.widget.ListView; import com.fasterxml.jackson.core.JsonParseException; import de.example.exampletdd.R; +import de.example.exampletdd.fragment.ErrorDialogFragment; import de.example.exampletdd.fragment.ProgressDialogFragment; import de.example.exampletdd.fragment.overview.IconsList; import de.example.exampletdd.httpclient.CustomHTTPClient; @@ -67,9 +68,9 @@ public class WeatherInformationCurrentDataFragment extends ListFragment { try { this.mWeatherServicePersistenceFile.storeCurrentWeatherData(currentWeatherData); } catch (final IOException e) { - // final DialogFragment newFragment = ErrorDialogFragment - // .newInstance(R.string.error_dialog_generic_error); - // newFragment.show(this.getFragmentManager(), "errorDialog"); + final DialogFragment newFragment = ErrorDialogFragment + .newInstance(R.string.error_dialog_generic_error); + newFragment.show(this.getFragmentManager(), "errorDialog"); } } } @@ -258,8 +259,8 @@ public class WeatherInformationCurrentDataFragment extends ListFragment { @Override protected void onPreExecute() { - this.newFragment.show(WeatherInformationCurrentDataFragment.this.getActivity() - .getFragmentManager(), "progressDialog"); + this.newFragment.show(WeatherInformationCurrentDataFragment.this.getFragmentManager(), + "progressDialog"); } @Override @@ -298,18 +299,18 @@ public class WeatherInformationCurrentDataFragment extends ListFragment { } catch (final IOException e) { WeatherInformationCurrentDataFragment.this.setListShown(true); Log.e(TAG, "WeatherTask onPostExecute exception: ", e); - // final DialogFragment newFragment = ErrorDialogFragment - // .newInstance(R.string.error_dialog_generic_error); - // newFragment.show( - // WeatherInformationCurrentDataFragment.this.getFragmentManager(), - // "errorDialog"); + final DialogFragment newFragment = ErrorDialogFragment + .newInstance(R.string.error_dialog_generic_error); + newFragment.show( + WeatherInformationCurrentDataFragment.this.getFragmentManager(), + "errorDialog"); } } else { WeatherInformationCurrentDataFragment.this.setListShown(true); - // final DialogFragment newFragment = ErrorDialogFragment - // .newInstance(R.string.error_dialog_generic_error); - // newFragment.show(WeatherInformationCurrentDataFragment.this.getFragmentManager(), - // "errorDialog"); + final DialogFragment newFragment = ErrorDialogFragment + .newInstance(R.string.error_dialog_generic_error); + newFragment.show(WeatherInformationCurrentDataFragment.this.getFragmentManager(), + "errorDialog"); } } @@ -317,10 +318,10 @@ public class WeatherInformationCurrentDataFragment extends ListFragment { protected void onCancelled(final CurrentWeatherData currentWeatherData) { this.weatherHTTPClient.close(); - // final DialogFragment newFragment = ErrorDialogFragment - // .newInstance(R.string.error_dialog_connection_tiemout); - // newFragment.show(WeatherInformationCurrentDataFragment.this.getFragmentManager(), - // "errorDialog"); + final DialogFragment newFragment = ErrorDialogFragment + .newInstance(R.string.error_dialog_connection_tiemout); + newFragment.show(WeatherInformationCurrentDataFragment.this.getFragmentManager(), + "errorDialog"); } private CurrentWeatherData doInBackgroundThrowable(final Object... params) diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java index 8168e23..9256c61 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/WeatherInformationOverviewFragment.java @@ -16,7 +16,8 @@ import java.util.Locale; import org.apache.http.client.ClientProtocolException; -import android.app.DialogFragment; +import android.content.ComponentName; +import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -25,6 +26,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Parcelable; import android.preference.PreferenceManager; +import android.support.v4.app.DialogFragment; import android.support.v4.app.ListFragment; import android.util.Log; import android.view.View; @@ -34,7 +36,9 @@ import com.fasterxml.jackson.core.JsonParseException; import de.example.exampletdd.R; import de.example.exampletdd.activityinterface.GetWeather; +import de.example.exampletdd.fragment.ErrorDialogFragment; import de.example.exampletdd.fragment.ProgressDialogFragment; +import de.example.exampletdd.fragment.specific.WeatherInformationSpecificDataFragment; import de.example.exampletdd.httpclient.CustomHTTPClient; import de.example.exampletdd.model.GeocodingData; import de.example.exampletdd.model.forecastweather.ForecastWeatherData; @@ -80,9 +84,9 @@ public class WeatherInformationOverviewFragment extends ListFragment implements this.mWeatherServicePersistenceFile .storeForecastWeatherData(forecastWeatherData); } catch (final IOException e) { - // final DialogFragment newFragment = ErrorDialogFragment - // .newInstance(R.string.error_dialog_generic_error); - // newFragment.show(this.getFragmentManager(), "errorDialog"); + final DialogFragment newFragment = ErrorDialogFragment + .newInstance(R.string.error_dialog_generic_error); + newFragment.show(this.getFragmentManager(), "errorDialog"); } } @@ -104,19 +108,19 @@ public class WeatherInformationOverviewFragment extends ListFragment implements @Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { - // final WeatherInformationSpecificDataFragment fragment = (WeatherInformationSpecificDataFragment) this.getFragmentManager() - // .findFragmentById(R.id.weather_specific_data__fragment); - // if (fragment == null) { - // // handset layout - // final Intent intent = new Intent("de.example.exampletdd.WEATHERINFO"). - // setComponent(new ComponentName("de.example.exampletdd", - // "de.example.exampletdd.WeatherInformationSpecificDataActivity")); - // intent.putExtra("CHOSEN_DAY", (int) id); - // WeatherInformationOverviewFragment.this.getActivity().startActivity(intent); - // } else { - // // tablet layout - // fragment.getWeatherByDay((int) id); - // } + final WeatherInformationSpecificDataFragment fragment = (WeatherInformationSpecificDataFragment) this + .getFragmentManager().findFragmentById(R.id.weather_specific_data__fragment); + if (fragment == null) { + // handset layout + final Intent intent = new Intent("de.example.exampletdd.WEATHERINFO") + .setComponent(new ComponentName("de.example.exampletdd", + "de.example.exampletdd.WeatherInformationSpecificDataActivity")); + intent.putExtra("CHOSEN_DAY", (int) id); + WeatherInformationOverviewFragment.this.getActivity().startActivity(intent); + } else { + // tablet layout + fragment.getWeatherByDay((int) id); + } } @Override @@ -279,8 +283,8 @@ public class WeatherInformationOverviewFragment extends ListFragment implements @Override protected void onPreExecute() { - this.newFragment.show(WeatherInformationOverviewFragment.this.getActivity() - .getFragmentManager(), "progressDialog"); + this.newFragment.show(WeatherInformationOverviewFragment.this.getFragmentManager(), + "progressDialog"); } @Override diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java index 089146f..85b4d1e 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/WeatherInformationSpecificDataFragment.java @@ -8,13 +8,13 @@ import java.util.Calendar; import java.util.Date; import java.util.Locale; -import android.app.DialogFragment; -import android.app.ListFragment; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v4.app.DialogFragment; +import android.support.v4.app.ListFragment; import android.widget.ListView; import de.example.exampletdd.R; import de.example.exampletdd.activityinterface.GetWeather;