|
|
/*
|
|
|
* 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.
|
|
|
*/
|
|
|
|
|
|
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尺寸的笔记小组件实现类
|
|
|
* <p>
|
|
|
* 该类继承自NoteWidgetProvider抽象类,实现了2x尺寸笔记小组件的具体功能
|
|
|
* 包括布局设置、背景资源获取和小组件类型定义
|
|
|
* </p>
|
|
|
*/
|
|
|
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
|
|
|
/**
|
|
|
* 更新小组件的UI和数据
|
|
|
* <p>
|
|
|
* 该方法重写了AppWidgetProvider的onUpdate方法,调用父类的update方法来更新2x尺寸小组件
|
|
|
* </p>
|
|
|
* @param context 上下文对象
|
|
|
* @param appWidgetManager 小组件管理器
|
|
|
* @param appWidgetIds 要更新的小组件ID数组
|
|
|
*/
|
|
|
@Override
|
|
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
|
super.update(context, appWidgetManager, appWidgetIds);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取2x尺寸小组件的布局ID
|
|
|
* <p>
|
|
|
* 返回2x尺寸小组件的布局资源ID
|
|
|
* </p>
|
|
|
* @return 2x小组件布局资源ID
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.widget_2x;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据背景颜色ID获取2x小组件对应的背景资源ID
|
|
|
* <p>
|
|
|
* 通过ResourceParser获取2x尺寸小组件的背景资源ID
|
|
|
* </p>
|
|
|
* @param bgId 数据库中的背景颜色ID
|
|
|
* @return 2x小组件对应的背景资源ID
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getBgResourceId(int bgId) {
|
|
|
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取2x小组件类型
|
|
|
* <p>
|
|
|
* 返回2x尺寸小组件的类型标识
|
|
|
* </p>
|
|
|
* @return 2x小组件类型标识
|
|
|
*/
|
|
|
@Override
|
|
|
protected int getWidgetType() {
|
|
|
return Notes.TYPE_WIDGET_2X;
|
|
|
}
|
|
|
}
|