2016. 1. 25. 16:44

습관의 재발견



한줄 요약 : 

시작이 어렵다. -> 해결 방법 -> 아주 작은 목표를 세운다. -> 가볍게 시작 할 수 있다.

Posted by 천류성

TextView.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Posted by 천류성
Posted by 천류성

Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;

String[] projection = new String[] {

String[] projection = new String[] { ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.PHOTO_ID, ContactsContract.Data.RAW_CONTACT_ID };

Cursor contactCursor = managedQuery(uri, projection, null, null, null);
사진 가져오기 
contactId = ContactsContract.CommonDataKinds.Phone.CONTACT_ID의 값

public Bitmap getPhoto(Long contactId) {
Uri contactPhotoUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
InputStream photoDataStream =                                             Contacts.openContactPhotoInputStream(getContentResolver(),contactPhotoUri); 
Bitmap photo = BitmapFactory.decodeStream(photoDataStream);
return photo;
}

연락처 사진 변경.
rawContactId = ContactsContract.CommonDataKinds.Phone.RAW_CONTACT_ID 의 값

public static void setContactPhoto(ContentResolver c, byte[] bytes, long rawContactId) {

ContentValues values = new ContentValues();
int photoRow = -1;
String where = ContactsContract.Data.RAW_CONTACT_ID + " = " + rawContactId + "                     AND " + ContactsContract.Data.MIMETYPE + "=='" +             ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE + "'";
Cursor cursor = c.query(ContactsContract.Data.CONTENT_URI, null, where, null, null);
int idIdx = cursor.getColumnIndexOrThrow(ContactsContract.Data._ID);
if (cursor.moveToFirst()) {
photoRow = cursor.getInt(idIdx);
}
cursor.close();

values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
values.put(ContactsContract.Data.IS_SUPER_PRIMARY, 1);
values.put(ContactsContract.CommonDataKinds.Photo.PHOTO, bytes);
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
if (photoRow >= 0) {
c.update(ContactsContract.Data.CONTENT_URI, values, ContactsContract.Data._ID + " = " + photoRow, null);
} else {
c.insert(ContactsContract.Data.CONTENT_URI, values);
}

}

Posted by 천류성

ICS부터 android.provider.calendar 접근이 가능해 Canlendar DB를 사용하기 쉽다. 

calendar provider를 접근하지 못하는 이전 버전에서의 사용법. 

2.2 이상인 경우 
String targetProvider = "com.android.calendar"
2.2 미만인 경우 
String targetProvider = "calendar" 

ContentResolver contentResolver = getContentResolver();
String eventUri = String.format("content://%s/events", targetProvider);
String selectUri = String.format("content://%s/", targetProvider); 

//검색
Cursor cursor = contentResolver.query(Uri.parser(selectUri+"/calendars"), ......);
 //입력, 수정, 삭제
Uri uri =  ContentUris.withAppendedId(Uri.parse(eventUri), id));
contentResolver.update(uri, ....); 

All day추가 시
UTC 타임으로 추가 되며 당일 00시00분 부터 다음날 00시 00분으로 추가 됨.

 반복 이벤트 추가 시 
 rrule(icalendar 규칙) 과 반복 되는 시간 duration column을 추가.

 반복 이벤트 수정 시 
instance table의 start 시간과 _sync_id 컬럼을 이용해 originalInstanceTime, originalEvent 를 채움.
반복 이벤트 수정, 삭제 동작은 event table에 상황에 맞는 이벤트 추가로 반영 됨.(수정, 삭제 -> event row 추가)
Posted by 천류성


Posted by 천류성


Posted by 천류성


Posted by 천류성


Posted by 천류성
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
float step  = e2.getX() - e1.getX();
float dest = (step*2);                          // 좌/우  Flicking 시 +/-로 변경 됨.
return super.onFling(e1, e2, dest, velocityY);
}

붉은 부분의 연산은 상황에 맞도록 수정 하시면 됩니다.
 
Posted by 천류성
이전버튼 1 2 3 4 이전버튼

블로그 이미지
.....
천류성

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함