이전 안드로이드 어플리케이션 블록에 이은 추가 오픈소스의 아키텍처, 동기, 사용법등을 정리한 자료입니다.
또한 위 블록을 통해 실제 안드로이드 어플리케이션을 리펙토링하는 사례를 설명 드립니다.
nipa 소프트웨어 공학센터 모바일 참조 모델로 만든 것이며, 추후 더 자세한 문서로 작성한 것들을 공개하도록 하겠습니다.
319. Interface
번거롭다!!!!!!
// Parcelable를 생성하기 위한 생성자 Parcel를 파라메타로 넘겨 받음
private UserInfo(Parcel source)
{
mName = source.readString();
mAge = source.readInt();
mEmail = source.readString();
}
// Parcelable을 상속 필수 Method
@Override
Intent intent = new Intent();
public int describeContents()
intent.setAction(ACTION_NAME);
{
intent.putExtra(UserInfo, userInfo);
return 0;
sendBradcast(intent);
}
// Parcelable의 write를 구현하기 위한 Method
@Override
public void writeToParcel(Parcel parcel, int arg1)
{
parcel.writeString(mName);
parcel.writeInt(mAge);
parcel.writeString(mEmail);
}
// Parcelable 객체로 구현하기 위한 Parcelable Method ArrayList구현 등..
public static final Parcelable.CreatorUserInfo CREATOR = new Parcelable.CreatorUserInfo()
{
……………………………
……………………………
!
!
!
320. Otto
public class
{
private
private
private
!
UserInfo
String mName;
int mAge;
String mEmail;
// Parcelable를 생성하기 위한 생성자 //임의 생성
public UserInfo(String name, int age, String email)
{
this.mName = name;
this.mAge = age;
this.mEmail = email;
}
// 각 값을 넘겨주기 위한 get터 생성
public String getName()
{
return mName;
}
public int getAge()
{
return mAge;
}
}
public String getEamil()
{
return mEmail;
}
!
!
!
기본
420. 사용
1.
2.
3.
4.
5.
Register Activity/Fragment to Bus!
Event 객체 정의!
produce, subscribe 함수 정의!
Bus를 통하여 기 정의한 event 객체 publishing!
Subscribing event (전달 받은 event 처리)
• Register Activity/Fragment
421. • Event 객체 정의
public class LocationChangedEvent {
public final float lat;
public final float lon;
!
}
public LocationChangedEvent(float lat, float lon) {
this.lat = lat;
this.lon = lon;
}
.........
.........
422. • Produce 함수 정의 및 Publish
findViewById(R.id.move_location).setOnClickListener(
new OnClickListener()
{
@Override
public void onClick(View v)
{
lastLatitude += (RANDOM.nextFloat() * OFFSET * 2) - OFFSET;
lastLongitude += (RANDOM.nextFloat() * OFFSET * 2) - OFFSET;
BusProvider.getInstance().post(produceLocationEvent());
}
});
423. • Produce 함수 정의 및 post
@Subscribe
public void onLocationChanged(LocationChangedEvent event)
{
locationEvents.add(0, event.toString());
if (adapter != null)
adapter.notifyDataSetChanged();
}
!
@Subscribe
public void onLocationCleared(LocationClearEvent event)
{
locationEvents.clear();
if (adapter != null)
adapter.notifyDataSetChanged();
}
1249. X.Y.Z (Major.Minor.Patch)
중요 업데이트 : 1.0.0 - 2.0.0!
마이너 업데이트 : 1.1.0 - 1.2.0!
버그 개선 버전 : 0.1.1 - 0.1.2!
최초 개발 버전 : 0.1.0!
선행배포 : 0.X.0-alpha, 0.X.0-beta!
빌드버전 : 0.1.1+build.29
114