+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@android:drawable/gallery_thumb">
-
- <TextView android:id="@+id/text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical|center_horizontal"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="HOLA GUS TABS"/>
-
- <!-- The frame layout is here since we will be showing either
- the empty view or the list view. -->
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1" >
- <!-- Here is the list. Since we are using a ListActivity, we
- have to call it "@android:id/list" so ListActivity will
- find it -->
- <ListView android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:drawSelectorOnTop="false"/>
-
- <!-- Here is the view to show if the list is emtpy -->
- <TextView android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="No items."/>
-
- </FrameLayout>
-
-</LinearLayout>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_gravity="center"
- android:layout_height="80dp" >
+ android:layout_height="140dp" >
<LinearLayout
android:layout_width="wrap_content"
"de.example.exampletdd.WeatherInformationMapActivity"));
this.startActivity(intent);
return true;
- // } else if (itemId == R.id.weather_menu_current) {
- // intent = new Intent("de.example.exampletdd.WEATHERINFO")
- // .setComponent(new ComponentName("de.example.exampletdd",
- // "de.example.exampletdd.WeatherInformationCurrentDataActivity"));
- // this.startActivity(intent);
- // return true;
} else {
}
import java.util.Locale;
import android.app.ActionBar;
-import android.app.Activity;
-import android.app.DialogFragment;
import android.location.Address;
import android.location.Geocoder;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.widget.TextView;
import de.example.exampletdd.model.GeocodingData;
import de.example.exampletdd.service.WeatherServicePersistenceFile;
-public class WeatherInformationMapActivity extends Activity {
+public class WeatherInformationMapActivity extends FragmentActivity {
private GoogleMap mMap;
private Marker mMarker;
private WeatherServicePersistenceFile mWeatherServicePersistenceFile;
@Override
protected void onPreExecute() {
- this.newFragment.show(WeatherInformationMapActivity.this.getFragmentManager(), "progressDialog");
+ this.newFragment.show(WeatherInformationMapActivity.this.getSupportFragmentManager(),
+ "progressDialog");
}
@Override
if (geocodingData == null) {
final DialogFragment newFragment = ErrorDialogFragment.newInstance(R.string.error_dialog_location_error);
- newFragment.show(WeatherInformationMapActivity.this.getFragmentManager(), "errorDialog");
+ newFragment.show(WeatherInformationMapActivity.this.getSupportFragmentManager(),
+ "errorDialog");
return;
}
} catch (final FileNotFoundException e) {
Log.e(TAG, "GeocoderAsyncTask onPostExecute exception: ", e);
final DialogFragment newFragment = ErrorDialogFragment.newInstance(R.string.error_dialog_location_error);
- newFragment.show(WeatherInformationMapActivity.this.getFragmentManager(), "errorDialog");
+ newFragment.show(WeatherInformationMapActivity.this.getSupportFragmentManager(),
+ "errorDialog");
} catch (final IOException e) {
Log.e(TAG, "GeocoderAsyncTask onPostExecute exception: ", e);
final DialogFragment newFragment = ErrorDialogFragment.newInstance(R.string.error_dialog_location_error);
- newFragment.show(WeatherInformationMapActivity.this.getFragmentManager(), "errorDialog");
+ newFragment.show(WeatherInformationMapActivity.this.getSupportFragmentManager(),
+ "errorDialog");
}
}
package de.example.exampletdd;
import android.app.ActionBar;
-import android.app.Activity;
import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
import de.example.exampletdd.model.GeocodingData;
import de.example.exampletdd.service.WeatherServicePersistenceFile;
-public class WeatherInformationSpecificDataActivity extends Activity {
+public class WeatherInformationSpecificDataActivity extends FragmentActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.app.ListFragment;
import android.support.v4.view.ViewPager;
-import android.util.Log;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
import de.example.exampletdd.activityinterface.GetWeather;
import de.example.exampletdd.fragment.current.WeatherInformationCurrentDataFragment;
import de.example.exampletdd.fragment.overview.WeatherInformationOverviewFragment;
import de.example.exampletdd.service.WeatherServicePersistenceFile;
public class WeatherTabsActivity extends FragmentActivity {
- static final int NUM_ITEMS = 2;
-
- MyAdapter mAdapter;
-
- ViewPager mPager;
-
+ private static final int NUM_ITEMS = 2;
+ private MyAdapter mAdapter;
+ private ViewPager mPager;
private GetWeather mGetWeather;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.fragment_pager);
+ this.setContentView(R.layout.fragment_pager);
- mAdapter = new MyAdapter(getSupportFragmentManager());
+ this.mAdapter = new MyAdapter(this.getSupportFragmentManager());
- mPager = (ViewPager)findViewById(R.id.pager);
- mPager.setAdapter(mAdapter);
+ this.mPager = (ViewPager)this.findViewById(R.id.pager);
+ this.mPager.setAdapter(this.mAdapter);
- mPager.setOnPageChangeListener(
+ this.mPager.setOnPageChangeListener(
new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(final int position) {
- // When swiping between pages, select the
- // corresponding tab.
- getActionBar().setSelectedNavigationItem(position);
+ WeatherTabsActivity.this.getActionBar().setSelectedNavigationItem(position);
}
});
- final ActionBar actionBar = getActionBar();
+ final ActionBar actionBar = this.getActionBar();
PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false);
@Override
public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
- // When the tab is selected, switch to the
- // corresponding page in the ViewPager.
- mPager.setCurrentItem(tab.getPosition());
+ WeatherTabsActivity.this.mPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
- // TODO Auto-generated method stub
}
@Override
public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
- // TODO Auto-generated method stub
}
actionBar.addTab(actionBar.newTab().setText("CURRENTLY").setTabListener(tabListener));
actionBar.addTab(actionBar.newTab().setText("FORECAST").setTabListener(tabListener));
-
}
@Override
final String value = sharedPreferences.getString(keyPreference, "");
String humanValue = "";
if (value.equals("5")) {
- humanValue = "5-Day Forecast";
+ humanValue = "5 DAY FORECAST";
} else if (value.equals("10")) {
- humanValue = "10-Day Forecast";
+ humanValue = "10 DAY FORECAST";
} else if (value.equals("14")) {
- humanValue = "14-Day Forecast";
+ humanValue = "14 DAY FORECAST";
}
- actionBar.setSubtitle(humanValue);
+ actionBar.getTabAt(1).setText(humanValue);
}
}
}
-
- public static class ArrayListFragment extends ListFragment {
- int mNum;
-
- /**
- * Create a new instance of CountingFragment, providing "num"
- * as an argument.
- */
- static ArrayListFragment newInstance(final int num) {
- final ArrayListFragment f = new ArrayListFragment();
-
- // Supply num input as an argument.
- final Bundle args = new Bundle();
- args.putInt("num", num);
- f.setArguments(args);
-
- return f;
- }
-
- /**
- * When creating, retrieve this instance's number from its arguments.
- */
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mNum = getArguments() != null ? getArguments().getInt("num") : 1;
- }
-
- /**
- * The Fragment's UI is just a simple text view showing its
- * instance number.
- */
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
- final View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
- final View tv = v.findViewById(R.id.text);
- ((TextView)tv).setText("Fragment #" + mNum);
- return v;
- }
-
- @Override
- public void onActivityCreated(final Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- final String[] chesses = new String[5];
- chesses[0] = "cheese 1";
- chesses[1] = "cheese 2";
- chesses[2] = "cheese 3";
- chesses[3] = "cheese 4";
- chesses[4] = "cheese 5";
- setListAdapter(new ArrayAdapter<String>(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);
- }
- }
-
-
}
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 {
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 {
import org.apache.http.client.ClientProtocolException;
-import android.app.DialogFragment;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
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;
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;
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");
}
}
}
@Override
protected void onPreExecute() {
- this.newFragment.show(WeatherInformationCurrentDataFragment.this.getActivity()
- .getFragmentManager(), "progressDialog");
+ this.newFragment.show(WeatherInformationCurrentDataFragment.this.getFragmentManager(),
+ "progressDialog");
}
@Override
} 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");
}
}
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)
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;
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;
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;
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");
}
}
@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
@Override
protected void onPreExecute() {
- this.newFragment.show(WeatherInformationOverviewFragment.this.getActivity()
- .getFragmentManager(), "progressDialog");
+ this.newFragment.show(WeatherInformationOverviewFragment.this.getFragmentManager(),
+ "progressDialog");
}
@Override
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;