From 5b251112e15e12ae601f463ac9d804863421103e Mon Sep 17 00:00:00 2001 From: pfmv8qroc <1763461387@qq.com> Date: Thu, 17 Apr 2025 08:23:17 +0800 Subject: [PATCH] ADD file via upload --- src/Widget/NoteWidgetProvider_2x.java | 77 +++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/Widget/NoteWidgetProvider_2x.java diff --git a/src/Widget/NoteWidgetProvider_2x.java b/src/Widget/NoteWidgetProvider_2x.java new file mode 100644 index 0000000..904490b --- /dev/null +++ b/src/Widget/NoteWidgetProvider_2x.java @@ -0,0 +1,77 @@ +/* + * 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; + +/** + * NoteWidgetProvider_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) { + // 调用父类的 update 方法进行小部件更新 + super.update(context, appWidgetManager, appWidgetIds); + } + + /** + * 获取 2x 小部件的布局资源 ID。 + * + * @return 2x 小部件的布局资源 ID,即 R.layout.widget_2x + */ + @Override + protected int getLayoutId() { + return R.layout.widget_2x; + } + + /** + * 根据背景颜色 ID 获取 2x 小部件的背景资源 ID。 + * 调用 ResourceParser 类中的 WidgetBgResources 内部类的方法来获取相应的背景资源。 + * + * @param bgId 背景颜色 ID,用于指定要获取的背景颜色 + * @return 2x 小部件的背景资源 ID + */ + @Override + protected int getBgResourceId(int bgId) { + return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId); + } + + /** + * 获取 2x 小部件的类型。 + * + * @return 2x 小部件的类型,即 Notes.TYPE_WIDGET_2X + */ + @Override + protected int getWidgetType() { + return Notes.TYPE_WIDGET_2X; + } +} \ No newline at end of file