This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MaterialApp( | |
theme: ThemeData( | |
brightness: Brightness.light, | |
primaryColor: Colors.red, | |
), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// At center of screen... | |
new FractionalTranslation( | |
translation: const Offset(0.5, 0.5), | |
// Stack whose origin is centered on screen | |
child: new Stack( | |
children: <Widget>[ | |
// This FractionalTranslation pulls the button back by | |
// 50% in both directions to center the button at the | |
// Stack's origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) { | |
Log.d("mgm:t1", "MainActivity.onKeyDown " + event); | |
if ( keyCode == KeyEvent.KEYCODE_MENU) { | |
handler.post(new Runnable() { | |
@Override | |
public void run() { | |
mDrawerFragment.openDrawer(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of how one might do some object-oriented programming in | |
// JavaScript. This example uses a prototype definition to present | |
// a fictional application that might govern a plane taking off | |
// from an airport. Notice how the program is not just a list of | |
// instructions - control often leaves the Plane object and then | |
// later returns to the Plane upon some outside event or message. | |
// Initiates the take off process | |
Plane.prototype.takeOff = function() { | |
this.doSafetyCheck(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of how one might do some functional programming in | |
// JavaScript. This example uses promises and presents a fictional | |
// process for taking a photo, creating a thumbnail, and saving | |
// them. Notice how the data is passed through all the functions | |
// instead of being stored in a higher scope. | |
obtainCamera() | |
.then(function(camera) { | |
// we receive a camera from obtainCamera() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* BusProvider is a Singleton which provides | |
* app-wide access to a single Bus instance. | |
*/ | |
public class BusProvider | |
{ | |
private static BusProvider instance; | |
public BusProvider getInstance() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Picasso canonical usage. Notice the elegance of the method chaining | |
Picasso.with(context).load(imageUrl).into(myImageView); | |
// Images fade in by default, if you don't want that | |
Picasso.with(context).load(imageUrl).noFade().into(myImageView); | |
// Explicitly control sizing and scaling | |
Picasso.with(context).load(imageUrl).resize(100, 100).centerCrop().into(myImageView); | |
// Provide placeholder images when downloading and upon error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compose a single request to send to the server: | |
HttpClient client = new DefaultHttpClient(); | |
HttpPost post = new HttpPost("http://www.myserver.com/apis/users/" + userId + "/profile"); | |
List<NameValuePair> bodyParams = new ArrayList<NameValuePair>(); | |
pairs.add(new NameValuePair("first_name", firstName)); | |
pairs.add(new NameValuePair("last_name", firstName)); | |
pairs.add(new NameValuePair("street1", firstName)); | |
pairs.add(new NameValuePair("street2", firstName)); | |
pairs.add(new NameValuePair("zip", firstName)); |
NewerOlder