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

50 lines
1.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)
*
* 遵循 Apache 许可证 2.0 版(“许可证”);
* 除非遵守许可证,否则不得使用此文件。
* 你可以在以下网址获取许可证副本:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 除非适用法律要求或书面同意,
* 根据许可证分发的软件按“原样”分发,
* 不附带任何明示或暗示的保证或条件。
* 请参阅许可证,了解具体的权限和限制。
*/
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.ones.tool.ResourceParser;
// NoteWidgetProvider_4x 类继承自 NoteWidgetProvider用于实现特定尺寸4x的便签小部件的功能包括处理小部件更新、获取布局 ID、背景资源 ID 和小部件类型等
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
// 重写父类的 onUpdate 方法,在小部件更新时调用父类的 update 方法来执行更新操作
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds);
}
// 获取 4x 小部件的布局 ID返回对应的布局资源 ID
protected int getLayoutId() {
return R.layout.widget_4x;
}
// 重写父类的 getBgResourceId 方法,根据给定的背景颜色 ID 获取对应的 4x 小部件背景资源 ID
@Override
protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId);
}
// 重写父类的 getWidgetType 方法,返回 4x 小部件的类型
@Override
protected int getWidgetType() {
return Notes.TYPE_WIDGET_4X;
}
}