diff --git a/NoteWidgetProvider_2x.java b/NoteWidgetProvider_2x.java new file mode 100644 index 0000000..a6e3a67 --- /dev/null +++ b/NoteWidgetProvider_2x.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) + * 版权声明,表明该文件由MiCode开源社区拥有版权,时间为2010-2011年。 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 该文件在Apache License 2.0下授权,你只能在遵守该许可证的情况下使用此文件。 + * you may not use this file except in compliance with the License. + * 你可以在遵守许可证的情况下获取许可证的副本。 + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * 除非适用法律要求或书面同意,否则按“原样”分发的软件是没有任何形式的保证或条件的。 + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * 具体权限和限制详见许可证。 + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.micode.notes.widget; +// 声明该类属于net.micode.notes.widget包。 + +import android.appwidget.AppWidgetManager; +import android.content.Context; +// 导入Android小部件管理器和上下文相关的类。 + +import net.micode.notes.R; +import net.micode.notes.data.Notes; +import net.micode.notes.tool.ResourceParser; +// 导入项目的资源、数据和工具类。 + +public class NoteWidgetProvider_2x extends NoteWidgetProvider { + // 定义NoteWidgetProvider_2x类,继承自NoteWidgetProvider,用于提供2x小部件的具体实现。 + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + // 当小部件需要更新时,系统会调用此方法。 + super.update(context, appWidgetManager, appWidgetIds); + // 调用父类的update方法,执行更新逻辑。 + } + + @Override + protected int getLayoutId() { + // 获取小部件的布局资源ID。 + return R.layout.widget_2x; + // 返回2x小部件的布局资源ID。 + } + + @Override + protected int getBgResourceId(int bgId) { + // 根据背景ID获取对应的资源ID。 + return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId); + // 使用ResourceParser工具类来获取2x小部件的背景资源ID。 + } + + @Override + protected int getWidgetType() { + // 获取小部件的类型。 + return Notes.TYPE_WIDGET_2X; + // 返回小部件的类型常量,用于区分不同的小部件。 + } +} \ No newline at end of file