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_2x.java

56 lines
2.5 KiB

1 month ago
/*
* 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; // 导入AppWidgetManager类用于管理应用小部件
import android.content.Context; // 导入Context类用于提供应用环境的全局信息
import net.micode.notes.R; // 导入R类用于访问应用的资源如布局文件、字符串等
import net.micode.notes.data.Notes; // 导入Notes类可能包含笔记的存储、类型定义等
import net.micode.notes.tool.ResourceParser; // 导入ResourceParser工具类用于解析资源
// NoteWidgetProvider_2x类继承自NoteWidgetProvider用于显示2x大小的笔记小部件
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
// 当小部件需要更新时调用此方法
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// 调用父类的update方法传入上下文、小部件管理器和小部件ID数组
super.update(context, appWidgetManager, appWidgetIds);
}
// 获取当前小部件布局的资源ID
@Override
protected int getLayoutId() {
// 返回R.layout.widget_2x这是定义2x大小小部件布局的XML文件的资源ID
return R.layout.widget_2x;
}
// 根据传入的背景ID获取对应的背景资源ID
@Override
protected int getBgResourceId(int bgId) {
// 使用ResourceParser.WidgetBgResources的getWidget2xBgResource方法根据背景ID获取2x小部件的背景资源ID
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
}
// 获取当前小部件的类型
@Override
protected int getWidgetType() {
// 返回Notes.TYPE_WIDGET_2X这是一个定义在Notes类中的常量表示2x大小的小部件类型
return Notes.TYPE_WIDGET_2X;
}
}