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.
XiaoMiNotes/src/widget/NoteWidgetProvider_2x.java

71 lines
2.2 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.

/*
* 版权所有 (c) 2010-2011The MiCode 开源社区 (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;
/**
* 2x大小笔记小部件提供者
* 继承自NoteWidgetProvider专门处理2x大小的小部件
* 实现抽象父类的具体方法提供2x小部件的特定配置
*/
public class NoteWidgetProvider_2x 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); // 调用父类更新方法
}
/**
* 获取2x小部件的布局ID
* @return 2x小部件的布局资源ID
*/
@Override
protected int getLayoutId() {
return R.layout.widget_2x; // 返回2x小部件的布局文件
}
/**
* 根据背景颜色ID获取对应的背景资源ID
* 专门为2x小部件提供背景资源
* @param bgId 背景颜色ID
* @return 2x小部件的背景资源ID
*/
@Override
protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId); // 获取2x小部件的背景资源
}
/**
* 获取小部件类型标识
* @return 2x小部件类型常量
*/
@Override
protected int getWidgetType() {
return Notes.TYPE_WIDGET_2X; // 返回2x小部件的类型标识
}
}