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.
TEST1231/NoteWidgetProvider_4x.java

65 lines
3.0 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;
// 导入必要的Android和项目相关的类
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大小的笔记小部件
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
// 当小部件需要更新时,系统会调用此方法
// 参数包括上下文Context、小部件管理器AppWidgetManager和小部件ID数组int[]
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// 调用父类的update方法将更新请求传递给父类处理
// 父类可能会根据小部件ID数组更新一个或多个小部件
super.update(context, appWidgetManager, appWidgetIds);
}
// 获取当前小部件布局的资源ID
// 这个方法被父类中的某些方法调用用于加载小部件的UI布局
@Override
protected int getLayoutId() {
// 返回R.layout.widget_4x这是定义4x大小小部件布局的XML文件的资源ID
return R.layout.widget_4x;
}
// 根据传入的背景ID获取对应的背景资源ID
// 这个方法可能被父类中的某些方法调用,用于设置小部件的背景
@Override
protected int getBgResourceId(int bgId) {
// 使用ResourceParser.WidgetBgResources的getWidget4xBgResource方法
// 根据背景ID获取4x小部件的背景资源ID
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId);
}
// 获取当前小部件的类型
// 这个方法可能被父类中的某些方法调用,用于区分不同类型的小部件
@Override
protected int getWidgetType() {
// 返回Notes.TYPE_WIDGET_4X这是一个定义在Notes类中的常量
// 表示4x大小的小部件类型
return Notes.TYPE_WIDGET_4X;
}
}