|
|
/*
|
|
|
* 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; // 包路径,表示该类属于 net.micode.notes.widget 包
|
|
|
|
|
|
import android.appwidget.AppWidgetManager; // 导入 AppWidgetManager,用于管理小部件
|
|
|
import android.content.Context; // 导入 Context,用于获取应用上下文
|
|
|
|
|
|
import net.micode.notes.R; // 导入资源文件
|
|
|
import net.micode.notes.data.Notes; // 导入笔记数据相关的类
|
|
|
import net.micode.notes.tool.ResourceParser; // 导入资源解析工具类
|
|
|
|
|
|
/*
|
|
|
NoteWidgetProvider_4x 类,用于实现 4x 大小的笔记小部件。
|
|
|
继承自 NoteWidgetProvider 抽象类,实现了具体的布局、背景资源和小部件类型。
|
|
|
*/
|
|
|
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
|
|
|
/*
|
|
|
当小部件需要更新时调用的方法。
|
|
|
调用父类的 update 方法来更新小部件。
|
|
|
|
|
|
@param context 上下文
|
|
|
@param appWidgetManager 小部件管理器
|
|
|
@param appWidgetIds 需要更新的小部件 ID 数组
|
|
|
*/
|
|
|
@Override
|
|
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
|
super.update(context, appWidgetManager, appWidgetIds); // 调用父类的 update 方法
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
获取小部件的布局 ID。
|
|
|
返回 4x 大小的小部件布局资源 ID。
|
|
|
|
|
|
@return 小部件布局资源 ID
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.widget_4x; // 返回 4x 大小的小部件布局资源 ID
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
获取小部件的背景资源 ID。
|
|
|
根据背景颜色 ID,返回对应的 4x 大小的小部件背景资源 ID。
|
|
|
|
|
|
@param bgId 背景颜色 ID
|
|
|
@return 背景资源 ID
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getBgResourceId(int bgId) {
|
|
|
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId); // 调用工具类获取背景资源 ID
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
获取小部件的类型。
|
|
|
返回 4x 大小的小部件类型。
|
|
|
|
|
|
@return 小部件类型
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getWidgetType() {
|
|
|
return Notes.TYPE_WIDGET_4X; // 返回 4x 大小的小部件类型
|
|
|
}
|
|
|
} |