Skip to content

Instantly share code, notes, and snippets.

View eyeahs's full-sized avatar

박현우(HyunwooPark) eyeahs

  • Hyundai
  • South Korea
View GitHub Profile
@eyeahs
eyeahs / MultiItemsCursorAdapter
Created July 23, 2014 02:36
CursorAdapter with two list items
Public class MultiItemsCursorAdapter extends CursorAdapter {
private static final int FIRST_ITEM_TYPE = 0;
private static final int SECOND_ITEM_TYPE = 1;
private static final int TYPE_MAX_CCOUNT = SECOND_ITEM + 1;
private final LayoutInflater layoutInflater;
private final MVPPresenter presenter;
public static class ViewHolder {
@InjectView(R.id.text_view)
@eyeahs
eyeahs / ActivityWithAsyncTask
Last active August 29, 2015 14:03
AsyncTask in Actvity
/*
AsyncTask can not be coded as instance inner class (non-static).
An instance inner class is tied to an instance of the containing class and it cannot be changed.
So, it is not possible to relink an instance of an async task to the new instance of the activity (on rotation).
What happens : when the async task finishes and onPostExecute is executed, the old activity is updated and not the new one.
*/
public class MyActivity extends Activity {
/*
@eyeahs
eyeahs / AsyncTaskWithFragment
Last active August 29, 2015 14:03
AsyncTask in Fragment
private static class MyAsyncTask extends AsyncTask<Void, Void, Void> {
private WeakReference<MyFragment> fragmentWeakRef;
private MyAsyncTask (MyFragmentfragment) {
this.fragmentWeakRef = new WeakReference<MyFragment>(fragment);
}
@Override
protected Void doInBackground(Void... params) {
@eyeahs
eyeahs / CustomAsyncTaskLoader
Last active August 29, 2015 14:03
Custom AsyncTaskLoader
public class CustomLoader extends AsyncTaskLoader<List<Data>> {
private List<Data> cachedData;
private ContentObserver observer = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
// CallLog Uri에 변경이 발생한 경우 LoadTask를 갱신한다.
onContentChanged();