ui包注释。

pull/3/head
pnv9folh3 1 year ago
parent fc127b9dff
commit 4761650bc3

@ -0,0 +1,72 @@
/*
* 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.
*/
//220340038 毛彦翔 2024/4/14 22:57
package net.micode.notes.ui;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
public class AlarmInitReceiver extends BroadcastReceiver { //继承了BroadcastReceiver类 这个类在哪呢?
private static final String [] PROJECTION = new String [] { //名为PROJECTION的私有 final类型的静态字符串数组 好安全
NoteColumns.ID, //某个ID 是AlarmActivity中的同款检索ID吗
NoteColumns.ALERTED_DATE //似乎是闹钟提醒的日期。
};
private static final int COLUMN_ID = 0;
private static final int COLUMN_ALERTED_DATE = 1; //变量初始化
@Override
public void onReceive(Context context, Intent intent) { //名为onReceive的公有类
long currentDate = System.currentTimeMillis(); //currentDate 初始化为 当前系统时间
Cursor c = context.getContentResolver().query(Notes.CONTENT_NOTE_URI/*指定了查询的数据源*/,
PROJECTION, //33行中定义的数组 返回ID和ALERTED_DATE
NoteColumns.ALERTED_DATE + ">? AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE,
//筛选条件 找到ALERTED_DATE大于当前时间并且TYPE等于TYPE_NOTE的便签。type是什么啊。
new String[] { String.valueOf(currentDate) }, //强制转换把long类型的currentDate转换成String
null); //干嘛用的null
if (c != null) { //c不为空
if (c.moveToFirst()) {
/* false
* true
*
*/
do {
long alertDate = c.getLong(COLUMN_ALERTED_DATE);
Intent sender = new Intent(context, AlarmReceiver.class);
sender.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, c.getLong(COLUMN_ID)));
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, sender, 0);
AlarmManager alermManager = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
alermManager.set(AlarmManager.RTC_WAKEUP, alertDate, pendingIntent);
} while (c.moveToNext()); //遍历查询到的便签挨个设闹钟
}
c.close(); //释放
}
}
} //好困 睡觉
Loading…
Cancel
Save