/* * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) * * Licensed under the Apache License, Version 2.0 (the "License"); * 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. */ // 包声明,表明该类属于 net.micode.notes.widget 包 package net.micode.notes.widget; // 导入应用小部件管理器类,用于管理和更新应用小部件 import android.appwidget.AppWidgetManager; // 导入 Android 上下文类,用于获取应用程序的环境信息 import android.content.Context; // 导入应用资源类,用于引用应用内的资源 import net.micode.notes.R; // 导入 Notes 类,用于引用笔记相关的常量和信息 import net.micode.notes.data.Notes; // 导入资源解析工具类,用于解析资源 import net.micode.notes.tool.ResourceParser; /** * NoteWidgetProvider_2x 类继承自 NoteWidgetProvider,是一个具体的应用小部件提供者类, * 用于处理 2x 尺寸的笔记应用小部件的相关操作。 */ public class NoteWidgetProvider_2x extends NoteWidgetProvider { /** * 当小部件更新时调用,调用父类的 update 方法进行更新操作 * @param context 应用程序上下文 * @param appWidgetManager 应用小部件管理器 * @param appWidgetIds 要更新的小部件 ID 数组 */ @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // 调用父类的 update 方法更新小部件 super.update(context, appWidgetManager, appWidgetIds); } /** * 获取 2x 小部件的布局 ID * @return 布局 ID,这里返回 R.layout.widget_2x */ @Override protected int getLayoutId() { return R.layout.widget_2x; } /** * 根据背景 ID 获取 2x 小部件对应的背景资源 ID * @param bgId 背景 ID * @return 背景资源 ID,通过 ResourceParser.WidgetBgResources 类的 getWidget2xBgResource 方法获取 */ @Override protected int getBgResourceId(int bgId) { return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId); } /** * 获取 2x 小部件的类型 * @return 小部件类型,这里返回 Notes.TYPE_WIDGET_2X */ @Override protected int getWidgetType() { return Notes.TYPE_WIDGET_2X; } }