|
|
/*
|
|
|
* Copyright (c) 2010 - 2011, The MiCode Open Source Community (www.micode.net)
|
|
|
*
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
* 表示该代码遵循Apache License 2.0开源协议,只有在遵守此协议的情况下才能使用该代码
|
|
|
* 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;
|
|
|
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 {
|
|
|
|
|
|
// 重写父类的onUpdate方法,当桌面小部件需要更新时会调用此方法
|
|
|
// 参数context表示应用上下文,用于获取各种系统服务等资源
|
|
|
// appWidgetManager用于管理桌面小部件相关操作,比如更新小部件的UI等
|
|
|
// appWidgetIds是需要更新的小部件的ID数组
|
|
|
@Override
|
|
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
|
// 调用父类的update方法来执行一些通用的或者在更新小部件时需要做的基础操作
|
|
|
super.update(context, appWidgetManager, appWidgetIds);
|
|
|
}
|
|
|
|
|
|
// 获取该桌面小部件对应的布局资源ID,这里返回的是对应4x小部件布局的资源ID
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.widget_4x;
|
|
|
}
|
|
|
|
|
|
// 根据传入的背景资源ID(bgId)获取该4x桌面小部件对应的背景资源ID
|
|
|
// 可能不同的背景ID对应不同的样式、图片等背景相关资源,通过ResourceParser工具类来获取具体资源
|
|
|
@Override
|
|
|
protected int getBgResourceId(int bgId) {
|
|
|
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId);
|
|
|
}
|
|
|
|
|
|
// 获取该桌面小部件的类型,这里返回的是代表4x小部件类型的标识(可能用于区分不同尺寸、不同类型的小部件)
|
|
|
@Override
|
|
|
protected int getWidgetType() {
|
|
|
return Notes.TYPE_WIDGET_4X;
|
|
|
}
|
|
|
} |