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

51 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.notes.tool.ResourceParser;
// NoteWidgetProvider_2x 类继承自 NoteWidgetProvider用于实现特定尺寸2x的便签小部件的功能包括设置小部件的布局、背景资源和类型等
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
// 当小部件需要更新时调用的方法,调用父类的 update 方法来执行更新操作
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds);
}
// 获取 2x 小部件的布局 ID 的方法,返回对应的布局资源 ID
@Override
protected int getLayoutId() {
return R.layout.widget_2x;
}
// 获取 2x 小部件的背景资源 ID 的方法,根据给定的背景颜色 ID通过 ResourceParser 的 WidgetBgResources 类获取对应的 2x 小部件背景图片资源 ID
@Override
protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
}
// 获取 2x 小部件的类型的方法,返回特定的 2x 小部件类型常量
@Override
protected int getWidgetType() {
return Notes.TYPE_WIDGET_2X;
}
}