Android Open Source - Wikipedia-Daily-Widget Wiki Widget Provider Base






From Project

Back to project page Wikipedia-Daily-Widget.

License

The source code is released under:

GNU General Public License

If you think the Android project Wikipedia-Daily-Widget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.rmc.dfaw;
//from  www  .j a  v  a2s . com
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
import android.widget.RemoteViews;

public abstract class WikiWidgetProviderBase extends AppWidgetProvider {
  protected boolean backgroundEnabled;
  protected RemoteViews views;

  public void onDeleted(Context context, int[] appWidgetIds) {
    SharedPreferences settings = context.getSharedPreferences(
        WikiWidgetActivity.SHARED_PREF_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor settingsEditor = settings.edit();

    for (int i = 0; i < appWidgetIds.length; i++) {
      // this should always exist.
      if (settings.contains(appWidgetIds[i]
          + WikiWidgetActivity.WIDGET_TYPE_PREF
          + WikiWidgetActivity.APP_EXTENSION)) {
        settingsEditor.remove(appWidgetIds[i]
            + WikiWidgetActivity.NETWORK_TYPE_PREF
            + WikiWidgetActivity.APP_EXTENSION);
      } else {
        Log.e("UpdateStory", "Unknown widget type not deleted");
      }
      if (settings.contains(appWidgetIds[i]
          + WikiWidgetActivity.NETWORK_TYPE_PREF
          + WikiWidgetActivity.APP_EXTENSION)) {
        settingsEditor.remove(appWidgetIds[i]
            + WikiWidgetActivity.NETWORK_TYPE_PREF
            + WikiWidgetActivity.APP_EXTENSION);
      } else {
        Log.e("UpdateStory",
            "Unknown network type for widget not deleted");
      }
    }
  }

  public void onUpdate(Context context, AppWidgetManager appWidgetManager,
      int[] appWidgetIds) {

    // Build the intent to call the service
    Intent intent = new Intent(context.getApplicationContext(),
        UpdateStoryService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);

    // Update the widgets via the intent service
    context.startService(intent);

  }

}




Java Source Code List

com.rmc.dfaw.FeaturedArticleHandler.java
com.rmc.dfaw.OnThisDayHandler.java
com.rmc.dfaw.UpdateStoryService.java
com.rmc.dfaw.WikiWidgetActivity.java
com.rmc.dfaw.WikiWidgetHandler.java
com.rmc.dfaw.WikiWidgetLauncherScreen.java
com.rmc.dfaw.WikiWidgetProvider4By2.java
com.rmc.dfaw.WikiWidgetProvider4By3.java
com.rmc.dfaw.WikiWidgetProvider4By4.java
com.rmc.dfaw.WikiWidgetProviderBase.java