Weitere ähnliche Inhalte Ähnlich wie Android Bootstrap (20) Kürzlich hochgeladen (20) Android Bootstrap5. agenda
open source
libraries
examples
bootstrap
9. open source
roboguice
action bar sherlock
http-request
gson
view pager indicator
robotium
maven
android maven plugin
fragments
11. roboguice.org
class RoboWay extends RoboActivity {
@InjectView(R.id.name) TextView name;
@InjectView(R.id.thumbnail) ImageView thumbnail;
@InjectResource(R.drawable.icon) Drawable icon;
@InjectResource(R.string.app_name) String myName;
@Inject LocationManager loc;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
name.setText( "Hello, " + myName );
}
}
12. roboguice.org
User Interface
Service Layer
ed a string
wha t if I ne e?
d own her
r esource
Persistence Layer
service layer: goo.gl/7NQVZ persistence layer: goo.gl/j5u74
13. roboguice.org
public class UserRepository {
@InjectResource(R.string.public_key) String publicKey;
public void saveProfile(UserProfile profile) {
// user publicKey to do some encryption
// Now, save the encrypted profile to db/api/etc
}
}
14. roboguice.org
public class UserRepository {
@InjectResource(R.string.public_key) String publicKey;
@Inject protected AuthService authService;
public void saveProfile(UserProfile profile) {
// Get auth token from auth service then save
// user publicKey to do some encryption
// Now, save the encrypted profile to api
}
}
24. github.com/rtyley/roboguice-sherlock
public class CarouselActivity extends RoboSherlockFragmentActivity {
@InjectView(id.tpi_header) private TitlePageIndicator indicator;
@InjectView(id.vp_pages) private ViewPager pager;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.carousel_view);
pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager()));
indicator.setViewPager(pager);
pager.setCurrentItem(1);
}
}
32. code.google.com/p/google-gson/
a pojo
class BagOfPrimitives {
private int value1 = 1;
private String value2 = "abc";
private transient int value3 = 3;
BagOfPrimitives() {
// no-args constructor
}
}
serialization
BagOfPrimitives obj = new BagOfPrimitives();
Gson gson = new Gson();
String json = gson.toJson(obj);
deserialization
BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class);
33. code.google.com/p/google-gson/
a pojo
class BagOfPrimitives {
private int value1 = 1;
private String value2 = "abc";
private transient int value3 = 3;
BagOfPrimitives() {
// no-args constructor
}
}
serialization
BagOfPrimitives obj = new BagOfPrimitives();
Gson gson = new Gson();
String json = gson.toJson(obj);
deserialization
BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class);
49. code.google.com/p/robotium
public class EditorTest extends
ActivityInstrumentationTestCase2<EditorActivity> {
private Solo solo;
public EditorTest() {
super("com.test.editor",
EditorActivity.class);
}
public void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
public void testPreferenceIsSaved() throws Exception {
solo.sendKey(Solo.MENU);
solo.clickOnText("More");
solo.clickOnText("Preferences");
solo.clickOnText("Edit File Extensions");
Assert.assertTrue(solo.searchText("rtf"));
solo.clickOnText("txt");
solo.clearEditText(2);
solo.enterText(2, "robotium");
solo.clickOnButton("Save");
solo.goBack();
solo.clickOnText("Edit File Extensions");
Assert.assertTrue(solo.searchText("application/robotium"));
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
}
}
54. androidbootstrap.com
includes
roboguice
action bar sherlock
http-request
gson
view pager indicator
robotium
maven
android maven plugin
fragments
api consumption
image downloading
image caching
cache mechanism
pojo support
ahhhhhh yeah
and more...
Hinweis der Redaktion \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n