1. 에뮬레이터 리스트를 확인한다.  android_sdk/tools/emulator -list-avds

2. android_sdk/tools/emulator @에뮬레이터 이름


Posted by 천류성

Gradle 추가. 

compile 'com.github.bumptech.glide:glide:3.7.0'


Option Module 추가(3.5버전 이후 변경된 방식). 

Diskcache, Memory Cache 사용. 

기본 ARGB_8888 형식으로 변경 (4444 default). 

public class MyGlideModule implements GlideModule {
private final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
private final int cacheSize = maxMemory / 8;
private final int DISK_CACHE_SIZE = 1024 * 1024 * 10;

@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, "cache", DISK_CACHE_SIZE))
.setMemoryCache(new LruResourceCache(cacheSize))
.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888)
;
}

@Override
public void registerComponents(Context context, Glide glide) {

}
}


AndroidManifest.xml Module meta-data 추가.

<meta-data
android:name="package.MyGlideModule"
android:value="GlideModule" />


간단한 사용 방법 : 

Glide.with(fragment.getContext())
.load(url)
.into(view);
  • Gif 사용가능. 
  • Animation 추가 가능.
  • thumbnail 형식 이미지 변환가능. 
  • 기타 등등 다양한 기능. 


참조 : https://github.com/bumptech/glide

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 천류성
@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 이전버튼

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

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.3
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
31

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함