|
|
/*
|
|
|
* 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.
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* 便签小部件实现类:2x尺寸版本
|
|
|
* 继承自NoteWidgetProvider基类,用于在桌面显示2x2网格大小的便签小部件
|
|
|
* 支持自定义背景、文本样式和便签内容展示
|
|
|
*/
|
|
|
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;
|
|
|
|
|
|
|
|
|
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
|
|
|
/**
|
|
|
* 小部件更新回调:当小部件被添加到桌面或需要更新时调用
|
|
|
* 调用父类的update方法处理实际更新逻辑
|
|
|
*/
|
|
|
@Override
|
|
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
|
super.update(context, appWidgetManager, appWidgetIds);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取布局资源ID:返回2x尺寸小部件对应的布局文件
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.widget_2x;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取背景资源ID:根据背景样式ID返回对应的背景资源
|
|
|
* @param bgId 背景样式ID,由ResourceParser定义
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getBgResourceId(int bgId) {
|
|
|
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取小部件类型:返回当前小部件的类型标识
|
|
|
* 用于数据库存储和区分不同尺寸的便签小部件
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getWidgetType() {
|
|
|
return Notes.TYPE_WIDGET_2X;
|
|
|
}
|
|
|
}
|