From e476aea38517b4e8ecaa5cadcc09ccd2c559cdd4 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Tue, 18 Nov 2014 04:10:21 +0100 Subject: [PATCH] New Intent without action and avoiding classes declaration as strings --- .../weather/information/activity/AboutActivity.java | 5 +---- .../weather/information/activity/MainTabsActivity.java | 13 +++---------- .../information/fragment/overview/OverviewFragment.java | 6 ++---- .../weather/information/widget/WidgetIntentService.java | 7 ------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java index 2a684d2..12d19c0 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java @@ -17,7 +17,6 @@ package name.gumartinm.weather.information.activity; import android.app.ActionBar; import android.app.Activity; -import android.content.ComponentName; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -42,9 +41,7 @@ public class AboutActivity extends Activity { } public void onClickLegalInformation(final View view) { - final Intent intent = new Intent("name.gumartinm.weather.information.WEATHERINFO") - .setComponent(new ComponentName("name.gumartinm.weather.information", - "name.gumartinm.weather.information.activity.LicensesActivity")); + final Intent intent = new Intent(this.getApplicationContext(), LicensesActivity.class); this.startActivity(intent); } diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java index afe06c5..d3951cf 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java @@ -18,7 +18,6 @@ package name.gumartinm.weather.information.activity; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.FragmentTransaction; -import android.content.ComponentName; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -115,21 +114,15 @@ public class MainTabsActivity extends FragmentActivity { Intent intent; final int itemId = item.getItemId(); if (itemId == R.id.weather_menu_settings) { - intent = new Intent("name.gumartinm.weather.information.WEATHERINFO") - .setComponent(new ComponentName("name.gumartinm.weather.information", - "name.gumartinm.weather.information.activity.PreferencesActivity")); + intent = new Intent(this.getApplicationContext(), PreferencesActivity.class); this.startActivity(intent); return true; } else if (itemId == R.id.weather_menu_map) { - intent = new Intent("name.gumartinm.weather.information.WEATHERINFO"). - setComponent(new ComponentName("name.gumartinm.weather.information", - "name.gumartinm.weather.information.activity.MapActivity")); + intent = new Intent(this.getApplicationContext(), MapActivity.class); this.startActivity(intent); return true; } else if (itemId == R.id.weather_menu_about) { - intent = new Intent("name.gumartinm.weather.information.WEATHERINFO"). - setComponent(new ComponentName("name.gumartinm.weather.information", - "name.gumartinm.weather.information.activity.AboutActivity")); + intent = new Intent(this.getApplicationContext(), AboutActivity.class); this.startActivity(intent); return true; } else { diff --git a/app/src/main/java/name/gumartinm/weather/information/fragment/overview/OverviewFragment.java b/app/src/main/java/name/gumartinm/weather/information/fragment/overview/OverviewFragment.java index 701e5e2..12130d2 100644 --- a/app/src/main/java/name/gumartinm/weather/information/fragment/overview/OverviewFragment.java +++ b/app/src/main/java/name/gumartinm/weather/information/fragment/overview/OverviewFragment.java @@ -31,7 +31,6 @@ import java.util.Locale; import org.apache.http.client.ClientProtocolException; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -50,6 +49,7 @@ import android.widget.ListView; import com.fasterxml.jackson.core.JsonParseException; import name.gumartinm.weather.information.R; +import name.gumartinm.weather.information.activity.SpecificActivity; import name.gumartinm.weather.information.fragment.specific.SpecificFragment; import name.gumartinm.weather.information.httpclient.CustomHTTPClient; import name.gumartinm.weather.information.model.DatabaseQueries; @@ -195,9 +195,7 @@ public class OverviewFragment extends ListFragment { .getFragmentManager().findFragmentById(R.id.weather_specific_fragment); if (fragment == null) { // handset layout - final Intent intent = new Intent("name.gumartinm.weather.information.WEATHERINFO") - .setComponent(new ComponentName("name.gumartinm.weather.information", - "name.gumartinm.weather.information.activity.SpecificActivity")); + final Intent intent = new Intent(this.getActivity().getApplicationContext(), SpecificActivity.class); intent.putExtra("CHOSEN_DAY", (int) id); OverviewFragment.this.getActivity().startActivity(intent); } else { diff --git a/app/src/main/java/name/gumartinm/weather/information/widget/WidgetIntentService.java b/app/src/main/java/name/gumartinm/weather/information/widget/WidgetIntentService.java index 057ba69..5497921 100644 --- a/app/src/main/java/name/gumartinm/weather/information/widget/WidgetIntentService.java +++ b/app/src/main/java/name/gumartinm/weather/information/widget/WidgetIntentService.java @@ -323,11 +323,4 @@ public class WidgetIntentService extends IntentService { final AppWidgetManager manager = AppWidgetManager.getInstance(this.getApplicationContext()); manager.updateAppWidget(appWidgetId, remoteView); } - -// private void updateWidgets(final RemoteViews remoteView) { -// -// final ComponentName widgets = new ComponentName(this.getApplicationContext(), WidgetProvider.class); -// final AppWidgetManager manager = AppWidgetManager.getInstance(this.getApplicationContext()); -// manager.updateAppWidget(widgets, remoteView); -// } } -- 2.1.4