New Intent without action and avoiding classes declaration as strings
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Tue, 18 Nov 2014 03:10:21 +0000 (04:10 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Tue, 18 Nov 2014 03:10:21 +0000 (04:10 +0100)
app/src/main/java/name/gumartinm/weather/information/activity/AboutActivity.java
app/src/main/java/name/gumartinm/weather/information/activity/MainTabsActivity.java
app/src/main/java/name/gumartinm/weather/information/fragment/overview/OverviewFragment.java
app/src/main/java/name/gumartinm/weather/information/widget/WidgetIntentService.java

index 2a684d2..12d19c0 100644 (file)
@@ -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);
     }
 
index afe06c5..d3951cf 100644 (file)
@@ -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 {
index 701e5e2..12130d2 100644 (file)
@@ -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 {
index 057ba69..5497921 100644 (file)
@@ -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);
-//     }
 }