You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
king/widget/NoteWidgetProvider_4x.java

78 lines
2.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* 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;
// 导入 AppWidgetManager 类,用于管理和更新应用小部件
import android.appwidget.AppWidgetManager;
// 导入 Context 类,提供应用程序的全局信息和资源访问
import android.content.Context;
// 导入应用的资源类,用于访问应用的资源,如布局、字符串等
import net.micode.notes.R;
// 导入 Notes 类,包含笔记相关的常量和定义
import net.micode.notes.data.Notes;
// 导入 ResourceParser 类,用于解析资源
import net.micode.notes.tool.ResourceParser;
/**
* NoteWidgetProvider_4x 类继承自 NoteWidgetProvider用于处理 4x 尺寸的笔记应用小部件的更新和相关操作。
*/
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
/**
* 当小部件需要更新时,系统会调用此方法。
*
* @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。
*
* @param bgId 背景的 ID用于确定具体的背景样式。
* @return 返回对应背景 ID 的 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;
}
}