본문
160302P(수)
Android Annotation
UI 매핑
TextView subjct = (TextView) findViewById(R.id.subject);
@ViewById
TextView subject;
파라미터 처리
String id = intent.getStringExtra("id");
@Extra("id") String id;
비동기 처리
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
...
}
protected void onProgressUpdate(Integer... progress) {
...
}
@Background
void backgroundJob() {
MovieContents movieContents = daumMovieService.getMovieContents("love");
String result = movieContents.getQuery();
setData(result);
}
@UIThread
void setData(String Data) {
textView.setText(data);
}
REST 통신
private InputStream download(String url) {
HttpURLConnection con = null;
URL url;
inputStream is = null;
try {
url = new URL(url);
...
}
}
@SystemService
BookmarkClient restClient;
@Rest("http://www.bookmarks.com")
public interface BookmarkClient {
@Get("/bookmarks/{userId}?search={search}")
Bookmarks getBookmarks(String search, String userId);
}
Click 이벤트
View updateBookmarksButton1 = findViewById(R.id.updateBookmarksButton1);
updateBookmarksButton1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
updateBookmarksClicked();
}
});
View updateBookmarksButton2 = findViewById(R.id.updateBookmarksButton2);
updateBookmarksButton2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
updateBookmarksClicked();
}
});
@Click({R.id.updateBookmarksButton1, R.id.updateBookmarksButton2})
void updateBookmarksClicked() {
searchAsync(search.getText().toString(), application.getUserId());
}
ETC
requestWindowFeature(Window.FEATURE_NO_TITLE);
@NoTitle
getWindow().setFlags(FLAG_FULLSCREEN, FLAG_FULLSCREEN);
@Fullscreen
setContentView(R.layout.bookmarks);
@EActivity(R.layout.bookmarks)
BookmarkApplication application = (BookmarkApplication) getApplication();
@App
BookmarkApplication application;
Animation fadeIn = AnimationUtils.loadAnimation(this, anim.fade_in);
@AnimationRes
Animation fadeIn;
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
@SystemService
ClipboardManager clipboardManager;
왜쓰이는지는 모르겠다.
코드를 보면 BookmarkAdapter를 리셋 해주는듯한데,
나는 평소에 adapter의 notifySetChanged()를 해주는데
여기는 아예 새로운 adapter를 만들고 set 해준다.
이것이 더 효율적인것인지는 모르겠다.
@AfterViews
void initBookmarkList() {
adapter = new BookmarkAdapter(this);
bookmarkList.setAdapter(adapter);
}
'Mobile > Android' 카테고리의 다른 글
160321A(월) (0) | 2016.03.21 |
---|---|
160319A(토) (0) | 2016.03.19 |
160210P(수) (0) | 2016.02.11 |
160119P(화) (0) | 2016.01.19 |
160118P(월) (0) | 2016.01.18 |
댓글