泛读报告的填写和按照现有理解注释了部分代码

pull/5/head
Surponess 2 months ago
parent 5c6e7f4ffa
commit 5d0521357e

Binary file not shown.

@ -26,6 +26,7 @@ import android.util.Log;
import java.util.HashMap;
public class Contact {
//建立联系人的哈希表
private static HashMap<String, String> sContactCache;
private static final String TAG = "Contact";
@ -37,24 +38,27 @@ public class Contact {
+ " WHERE min_match = '+')";
public static String getContact(Context context, String phoneNumber) {
//如果并没有哈希表则创建新的哈希表
if(sContactCache == null) {
sContactCache = new HashMap<String, String>();
}
//在哈希表的缓存中找到了联系人的电话,返回相应的字符串
if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
}
//应该是直接在存储联系人和电话的菜单里面查找电话号码所对应的联系人
String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME },
selection,
new String[] { phoneNumber },
null);
//如果找到了联系人就返回名称,没有就返回无
if (cursor != null && cursor.moveToFirst()) {
//找到联系人后把联系人和电话号码存入缓存中,以便下一次查找
try {
String name = cursor.getString(0);
sContactCache.put(phoneNumber, name);

@ -17,6 +17,7 @@
package net.micode.notes.data;
import android.net.Uri;
//纯定义,没有函数
public class Notes {
public static final String AUTHORITY = "micode_notes";
public static final String TAG = "Notes";

@ -26,7 +26,7 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
//定义了一系列操作的函数
public class NotesDatabaseHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "note.db";

@ -63,25 +63,45 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
});
}
//private void showNotification(int tickerId, String content) {
// Notification notification = new Notification(R.drawable.notification, mContext
// .getString(tickerId), System.currentTimeMillis());
// notification.defaults = Notification.DEFAULT_LIGHTS;
// notification.flags = Notification.FLAG_AUTO_CANCEL;
// PendingIntent pendingIntent;
// if (tickerId != R.string.ticker_success) {
// pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
// NotesPreferenceActivity.class), 0);
//
// } else {
// pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
// NotesListActivity.class), 0);
// }
// notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
// pendingIntent);
// mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
//}
private void showNotification(int tickerId, String content) {
Notification notification = new Notification(R.drawable.notification, mContext
.getString(tickerId), System.currentTimeMillis());
notification.defaults = Notification.DEFAULT_LIGHTS;
notification.flags = Notification.FLAG_AUTO_CANCEL;
PendingIntent pendingIntent;
if (tickerId != R.string.ticker_success) {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesPreferenceActivity.class), 0);
NotesPreferenceActivity.class), PendingIntent.FLAG_IMMUTABLE);
} else {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0);
NotesListActivity.class), PendingIntent.FLAG_IMMUTABLE);
}
notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
pendingIntent);
Notification.Builder builder = new Notification.Builder(mContext)
.setAutoCancel(true)
.setContentTitle(mContext.getString(R.string.app_name))
.setContentText(content)
.setContentIntent(pendingIntent)
.setWhen(System.currentTimeMillis())
.setOngoing(true);
Notification notification=builder.getNotification();
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
}
@Override
protected Integer doInBackground(Void... unused) {
publishProgess(mContext.getString(R.string.sync_progress_login, NotesPreferenceActivity

Loading…
Cancel
Save