/* * 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. */ 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.notes.tool.ResourceParser; /** * NoteWidgetProvider_4x 类继承自 NoteWidgetProvider,用于处理 4x 尺寸的笔记小部件。 * 它重写了父类的一些方法,以提供适合 4x 小部件的布局、背景资源和小部件类型等信息。 */ public class NoteWidgetProvider_4x 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); } /** * 获取 4x 小部件的布局资源 ID。 * * @return 4x 小部件的布局资源 ID,即 R.layout.widget_4x */ protected int getLayoutId() { return R.layout.widget_4x; } /** * 根据背景颜色 ID 获取 4x 小部件的背景资源 ID。 * 借助 ResourceParser 类中的 WidgetBgResources 内部类来获取对应背景资源。 * * @param bgId 背景颜色 ID,代表不同的背景颜色 * @return 4x 小部件对应背景颜色的背景资源 ID */ @Override protected int getBgResourceId(int bgId) { return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId); } /** * 获取 4x 小部件的类型。 * * @return 4x 小部件的类型,即 Notes.TYPE_WIDGET_4X */ @Override protected int getWidgetType() { return Notes.TYPE_WIDGET_4X; } }