diff --git a/NoteWidgetProvider_4x.java b/NoteWidgetProvider_4x.java new file mode 100644 index 0000000..13cbd0b --- /dev/null +++ b/NoteWidgetProvider_4x.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010 - 2011, The MiCode Open Source Community (www.micode.net) + * + * 遵循 Apache 许可证 2.0 版(“许可证”); + * 除非遵守许可证,否则不得使用此文件。 + * 你可以在以下网址获取许可证副本: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 除非适用法律要求或书面同意, + * 根据许可证分发的软件按“原样”分发, + * 不附带任何明示或暗示的保证或条件。 + * 请参阅许可证,了解具体的权限和限制。 + */ + +package net.micode.notes.widget; + +import android.appwidget.AppWidgetManager; +import android.content.Context; + +import net.micode.notes.R; +import net.micode.notes.data.Notes; +import net.micode.ones.tool.ResourceParser; + +// NoteWidgetProvider_4x 类继承自 NoteWidgetProvider,用于实现特定尺寸(4x)的便签小部件的功能,包括处理小部件更新、获取布局 ID、背景资源 ID 和小部件类型等 +public class NoteWidgetProvider_4x extends NoteWidgetProvider { + + // 重写父类的 onUpdate 方法,在小部件更新时调用父类的 update 方法来执行更新操作 + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + super.update(context, appWidgetManager, appWidgetIds); + } + + // 获取 4x 小部件的布局 ID,返回对应的布局资源 ID + protected int getLayoutId() { + return R.layout.widget_4x; + } + + // 重写父类的 getBgResourceId 方法,根据给定的背景颜色 ID 获取对应的 4x 小部件背景资源 ID + @Override + protected int getBgResourceId(int bgId) { + return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId); + } + + // 重写父类的 getWidgetType 方法,返回 4x 小部件的类型 + @Override + protected int getWidgetType() { + return Notes.TYPE_WIDGET_4X; + } +} \ No newline at end of file