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.
5MI/NoteWidgetProvider_2x.java

64 lines
2.6 KiB

/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
* MiCode2010-2011
*
* 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;
// 声明该类属于net.micode.notes.widget包。
import android.appwidget.AppWidgetManager;
import android.content.Context;
// 导入Android小部件管理器和上下文相关的类。
import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser;
// 导入项目的资源、数据和工具类。
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
// 定义NoteWidgetProvider_2x类继承自NoteWidgetProvider用于提供2x小部件的具体实现。
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// 当小部件需要更新时,系统会调用此方法。
super.update(context, appWidgetManager, appWidgetIds);
// 调用父类的update方法执行更新逻辑。
}
@Override
protected int getLayoutId() {
// 获取小部件的布局资源ID。
return R.layout.widget_2x;
// 返回2x小部件的布局资源ID。
}
@Override
protected int getBgResourceId(int bgId) {
// 根据背景ID获取对应的资源ID。
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
// 使用ResourceParser工具类来获取2x小部件的背景资源ID。
}
@Override
protected int getWidgetType() {
// 获取小部件的类型。
return Notes.TYPE_WIDGET_2X;
// 返回小部件的类型常量,用于区分不同的小部件。
}
}