/* * 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包下的NoteWidgetProvider_2x类,这个类继承自NoteWidgetProvider类 package net.micode.notes.widget; // 导入必要的Android库 import android.appwidget.AppWidgetManager; // 管理App小部件的类 import android.content.Context; // 提供应用环境信息的接口 // 导入项目内部的库 import net.micode.notes.R; // 项目的资源文件 import net.micode.notes.data.Notes; // 项目的数据模型类,可能包含笔记的数据结构和方法 import net.micode.notes.tool.ResourceParser; // 项目的工具类,用于解析资源 // NoteWidgetProvider_2x类的定义开始 public class NoteWidgetProvider_2x extends NoteWidgetProvider { // 重写父类的onUpdate方法,这是在更新小部件时被调用的方法 @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // 调用父类的update方法,传递相同的参数,进行实际的更新操作 super.update(context, appWidgetManager, appWidgetIds); } // 重写父类的getLayoutId方法,这个方法用于获取小部件的布局资源ID @Override protected int getLayoutId() { // 返回预定义的2x小部件布局资源ID return R.layout.widget_2x; } // 重写父类的getBgResourceId方法,这个方法用于获取小部件的背景资源ID @Override protected int getBgResourceId(int bgId) { // 使用ResourceParser工具的getWidget2xBgResource方法,根据传入的bgId参数获取对应的2x小部件背景资源ID,并返回 return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId); } // 重写父类的getWidgetType方法,这个方法用于获取小部件的类型 @Override protected int getWidgetType() { // 返回预定义的2x小部件类型ID,这个ID可能在Notes类中有定义 return Notes.TYPE_WIDGET_2X; } } // NoteWidgetProvider_2x类的定义结束