blob: 6e541ee52215a4900ea3c3f835e21529474af891 [file] [log] [blame]
Scott Main50e990c2012-06-21 17:14:39 -07001fullpage=true
2page.title=Develop
3header.hide=1
4carousel=1
5tabbedList=1
6@jd:body
7
8<style>
9#noplayer-message {
10position:absolute;top:50%;left:0;width:100%;z-index:-1;text-align:center;display:none;
11}
12#player-frame object {z-index:1;}
13</style>
14
15<div id="player-wrapper">
16 <div id="player-frame">
17 <div id="noplayer-message">
18 <!-- busted flash player message -->
19 Your video is supposed to appear here.<br/>
20 Make sure you have the <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash&reg; Player</a>.
21 </div>
22 <div id="player"><!-- Youtube embeds here... actually replaces this div --></div>
23 <a class="close" onclick="$('#player-wrapper').hide()">close video</a>
24 </div>
25</div>
26
27<div class="wrap">
28 <!-- Slideshow -->
29 <div class="slideshow-container slideshow-develop col-16">
30 <a href="" class="slideshow-prev">Prev</a>
31 <a href="" class="slideshow-next">Next</a>
32 <div class="frame">
33 <ul>
34 <li class="item carousel-home">
35 <div class="col-8">
36 <img
37src="http://1.bp.blogspot.com/-6qyjPxTuzv0/T6lde-Oq_fI/AAAAAAAABXc/zle7OFEGP44/s400/fddns%2Bcopy.png"
38class="play no-shadow no-transform" />
39 </div>
40 <div class="content-right col-6">
41 <p class="title-intro">From the blog:</p>
42 <h2>Using DialogFragments</h2>
43 <p>In this post, I'll show how to use DialogFragments with the <a
44href="http://developer.android.com/reference/android/support/v4/app/DialogFragment.html">v4 support
45library</a> (for backward compatibility on pre-Honeycomb devices) to show a simple edit dialog and
46return a result to the calling Activity using an interface.</p>
47 <p><a
48href="http://android-developers.blogspot.com/2012/05/using-dialogfragments.html" class="button">Read
49more</a></p>
50 </div>
51 </li>
52 <li class="item carousel-home">
53 <div class="col-8">
54 <img
55src="http://1.bp.blogspot.com/-6K1kfNOdek8/T72bXvtTSQI/AAAAAAAABmw/kYzmJt0_328/s1600/google-play-subscriptions.png" class="play"></div>
56 <div class="content-right col-6">
57 <p class="title-intro">From the blog:</p>
58 <h2>In-app Subscriptions in Google Play</h2>
59 <p>Starting today, developers can use In-app Billing to sell monthly or annual
60subscriptions from inside of their apps. All subscriptions are auto-renewing, for every app and game
61and every type of subscription product.</p>
62 <p><a class="button"
63href="http://android-developers.blogspot.com/2012/05/in-app-subscriptions-in-google-play.html">Read
64more</a></p>
65 </div>
66 </li>
67 <li class="item carousel-home">
68 <div class="col-8">
69 <img
70src="{@docRoot}images/home/developers_live.png" class="play"></div>
71 <div class="content-right col-6">
72 <h2>Learn what great apps are made of</h2>
73 <p>Every week we host a live broadcast in which we review a collection of apps and games
74 nominated by the creators. It's no-holds-barred and we tell you exactly what is flawed or
75 fantastic in each app and how to make improvements.</p>
76 <p><a href="" class="button" onclick="$('ul#DevelopersLive li:first
77a').click();return false;">Watch the latest review</a></p>
78 </div>
79 </li>
Scott Main50e990c2012-06-21 17:14:39 -070080 </ul>
81 </div>
82 </div>
83 <!-- /End slideshow -->
84</div>
85<div class="wrap">
86 <!-- news and feature feed -->
87 <div class="feed col-8" style="margin-left:0">
88 <ul class="feed-nav">
89 <li class="active">DEVELOPER NEWS</li>
90 <li>FEATURED DOCS</li>
91 </ul>
92 <div class="feed-container">
93 <div class="feed-frame">
94 <!-- DEVELOPER NEWS -->
95 <ul>
96 <li><a href="http://android-developers.blogspot.com/2012/04/faster-emulator-with-better-hardware.html">
97 <div class="feed-image" style="background:url('../images/emulator-wvga800l.png') no-repeat 0 0">
98 </div>
99 <h4>A Faster Emulator with Better...</h4>
100 <p>Today were thrilled to announce several significant improvements to the emulator, including a dramatic...</p>
101 </a></li>
102 <li><a href="http://android-developers.blogspot.com/2012/04/android-c2dm-client-login-key.html">
103 <div class="feed-image" style="background:url('../images/develop/auth-code.png') no-repeat 0 0">
104 </div>
105 <h4>Android C2DM Client Login key...</h4>
106 <p>In the upcoming weeks, some of the older Client
107 Login authentication keys will expire. If you generated the token youre...</p>
108 </a></li>
109 <li><a href="http://android-developers.blogspot.com/2012/04/accessibility-are-you-serving-all-your.html">
110 <div class="feed-image">
111 </div>
112 <h4>Accessibility</h4>
113 <p>We recently published some new resources to help developers make their Android applications more accessible... </p>
114 </a></li>
115 <li><a href="http://android-developers.blogspot.com/2012/04/new-seller-countries-in-google-play.html">
116 <div class="feed-image" style="background:url('http://developer.android.com/images/home/play_logo.png') no-repeat 0 0" >
117 </div>
118 <h4>New Seller Countries in Google Play</h4>
119 <p>Over the past year weve been working to expand the list of
120 countries and currencies from which Android developers...</p>
121 </a></li>
122 </ul>
123 <!-- FEATURED DOCS -->
124 <ul>
125 <li><a href="{@docRoot}guide/google/play/billing/index.html">
126 <h4>Google Play In-app Billing</h4>
127 <p>In-app Billing is a Google Play service that lets you sell digital content from inside your applications. You can sell products as standard in-app products (one-time purchase) or with subscriptions (recurring...</p>
128 </a></li>
129 <li><a href="{@docRoot}guide/topics/providers/contacts-provider.html">
130 <h4>Contacts Provider</h4>
131 <p>The Contacts Provider is a powerful and flexible Android component that manages the device's central repository of data about people. You can use it to build powerful social features...</p>
132 </a></li>
133 <li><a href="{@docRoot}training/efficient-downloads/index.html">
134 <h4>Transferring Data Without Draining the Battery</h4>
135 <p>This training class demonstrates the best practices for scheduling and executing downloads using techniques such as caching, polling, and prefetching.</p>
136 </a></li>
137 <li><a href="{@docRoot}training/backward-compatible-ui/index.html">
138 <h4>Creating Backward-Compatible UIs</h4>
139 <p>This training class demonstrates how to use UI components and APIs available in newer versions of Android in a backward-compatible way, ensuring that your application still runs on previous versions...</p>
140 </a></li>
141 </ul>
142 </div>
143 </div>
144 </div> <!-- /news and feature feed -->
145 <!-- video feed -->
146 <div class="feed col-8" style="margin-right:0">
147 <ul class="feed-nav">
148 <li class="active">DEVELOPERS LIVE</li>
149 <li>VIDEO PLAYLISTS</li>
150 </ul>
151 <div class="feed-container">
152 <div class="feed-frame">
153 <ul id="DevelopersLive">
154 </ul>
155 <ul id="VideoPlaylists">
156 </ul>
157 </div>
158 </div>
159 </div>
160 <!-- /video feed -->
161</div>
162
163<br class="clearfix"/>
164 </div>
165
166
167
168
169
170
171
172
173
174
175<script src="//swfobject.googlecode.com/svn/trunk/swfobject/swfobject.js" type="text/javascript"></script>
176<script type="text/javascript">
177
178/* Load a video into the player box.
179 * @param id The YouTube video ID
180 * @param title The video title to display in the player box (character escaped)
181 * @param autoplay Whether to automatically play the video
182 */
183function loadVideo(id, title, autoplay) {
184 swfobject.embedSWF('//www.youtube.com/v/' + id + '&rel=1&border=0&fs=1&autoplay=' +
185 (autoplay?1:0), 'player', '525', '330', '9.0.0', false, false, {allowfullscreen: 'true'});
186 $("#videoPlayerTitle").html("<h2>" + unescape(title) + "</h2>");
187 $("#player-wrapper").show();
188 setTimeout(function(){$('#noplayer-message').show()}, 2000);
189}
190
191/* Draw all videos from a playlist into a 'videoPreviews' list
192 * @param data The feed data returned from the youtube request
193 */
194function renderVideoPlaylists(data) {
195 var MAX_LIST_DESC_LENGTH = 130; // the length at which we will trim the description
196 var MAX_VIDEO_DESC_LENGTH = 100; // the length at which we will trim the description
197 var MAX_LIST_LENGTH = 4; // number of videos to put in the list
198 var feed = data.feed;
199 var entries = feed.entry || [];
200 var playlistId = feed.yt$playlistId.$t;
201
202 var $ulVideos = $('<ul style="display:none"/>');
203 var summary = feed.media$group.media$description != null ? feed.media$group.media$description.$t : feed.subtitle.$t;
204
205 var $liPlaylist = $('<li class="playlist"></li>');
206 var $aPlaylist = $('<a href="" onclick="togglePlaylist(this);return false;"></a>');
207 $liPlaylist.append($aPlaylist);
208 $aPlaylist.append('<h4>' + feed.title.$t + '</h4>');
209
210 var playlistDescription = summary.substr(0, MAX_LIST_DESC_LENGTH);
211 playlistDescription += playlistDescription.length == MAX_LIST_DESC_LENGTH ? "..." : ""; // add ellipsis if we've chopped the description
212 $aPlaylist.append('<p>' + playlistDescription + '</p>');
213
214 // Loop through each entry (each video) and add it to the 'videoPreviews' list
215 var length = feed.entry.length < MAX_LIST_LENGTH ? feed.entry.length : MAX_LIST_LENGTH; // max of 4 videos per list
216 for (var i = 0; i < length; i++) {
217 var entry = entries[i];
218
219 var title = entry.title.$t;
220 var id = entry.media$group.yt$videoid.$t;
221 var thumbUrl = entry.media$group.media$thumbnail[0].url;
222 var fullDescription = entry.media$group.media$description.$t;
223 var playerUrl = entry.media$group.media$content[0].url;
224
225 var shortDescription = fullDescription.substr(0, MAX_VIDEO_DESC_LENGTH);
226 shortDescription += shortDescription.length == MAX_VIDEO_DESC_LENGTH ? "..." : ""; // add ellipsis if we've chopped the description
227
228 var img = $('<img src="' + thumbUrl + '" width="60" height="45"/>');
229 var a = $('<a href="#" onclick="loadVideo(\'' + id + '\',\'' + escape(title) + '\',true); return false;" />');
230 var pShortDescription = $('<p>' + shortDescription + '</p>');
231 var h5Title = "<h5>" + title + "</h5>";
232 var li = $('<li class="playlist-video"/>');
233
234 li.append(a);
235 a.append(img).append(h5Title).append(pShortDescription);
236
237 $ulVideos.append(li);
238
239 // use the first entry's thumbnail for the playlist
240 if (i == 0) {
241 $aPlaylist.prepend('<img src="' + thumbUrl + '" width="120" height="90"/>');
242 }
243 }
244
245 if (feed.entry.length > MAX_LIST_LENGTH) {
246 // add item to go to youtube for playlist
247 $ulVideos.append('<li class="more"><a href="//www.youtube.com/playlist?list=PL' + playlistId + '">More &raquo;</a></li>');
248 }
249
250 $liPlaylist.append($ulVideos);
251 $('#VideoPlaylists').append($liPlaylist);
252}
253
254
255function renderDevelopersLivePlaylist(data) {
256
257 var MAX_DESC_LENGTH = 125; // the length at which we will trim the description
258 var feed = data.feed;
259 var entries = feed.entry || [];
260 var playlistId = feed.yt$playlistId.$t;
261
262 var ul = $('#DevelopersLive');
263
264 // Loop through each entry (each video) and add it to the '#DevelopersLive' list
265 for (var i = 0; i < 4; i++) {
266 var entry = entries[i];
267
268 var title = entry.title.$t;
269 var id = entry.media$group.yt$videoid.$t;
270 var thumbUrl = entry.media$group.media$thumbnail[0].url;
271 var fullDescription = entry.media$group.media$description.$t;
272 var playerUrl = entry.media$group.media$content[0].url;
273 var shortDescription = fullDescription.substr(0, MAX_DESC_LENGTH);
274 shortDescription += shortDescription.length == MAX_DESC_LENGTH ? "..." : ""; // add ellipsis if we've chopped the description
275
276 var img = $('<img src="' + thumbUrl + '" width="120" height="90"/>');
277 var a = $('<a href="#" onclick="loadVideo(\'' + id + '\',\'' + escape(title) + '\',true); return false;" />');
278 var pShortDescription = $('<p>' + shortDescription + '</p>');
279 var h4Title = "<h4>" + title + "</h4>";
280 var li = $('<li/>');
281
282 li.append(a);
283 a.append(img).append(h4Title).append(pShortDescription);
284
285 ul.append(li);
286 }
287}
288
289
290
291/* This 'playlist' object defines the playlist IDs for each tab.
292 * Each name inside 'playlist' corresponds to class names for the tab that the playlists belong to (eg: "googleioTab" and "googleioBox" divs).
293 * Each string in 'ids' is the ID of a YouTube playlist that belongs in the corresponding tab.
294 */
295var playlists = {
296 'googleio' : {
297 'ids': ["734A052F802C96B9"]
298 },
299 'fridayreview' : {
300 'ids': ["B7B9B23D864A55C3"]
301 },
302 'officehours' : {
303 'ids': ["7383D9AADA6E6D55"]
304 },
305 'about' : {
306 'ids': ["D7C64411AF40DEA5"]
307 }
308};
309
310/* Request the playlist feeds from YouTube */
311function showVideosPlaylists() {
312 for (var x in playlists) {
313 var ids = playlists[x].ids;
314 for (var i in ids) {
315 var script = "<script type='text/javascript' src='//gdata.youtube.com/feeds/api/playlists/"
316 + ids[i] +
317 "?v=2&alt=json-in-script&max-results=50&callback=renderVideoPlaylists&orderby=published'><\/script>";
318 $("body").append(script);
319 }
320 }
321}
322
323
324/* Request the playlist feeds from YouTube */
325function showDevelopersLivePlaylist() {
326 var playlistId = "B7B9B23D864A55C3"; /* The Friday Review */
327 var script = "<script type='text/javascript' src='//gdata.youtube.com/feeds/api/playlists/"
328 + playlistId +
329 "?v=2&alt=json-in-script&max-results=10&callback=renderDevelopersLivePlaylist&orderby=published'><\/script > ";
330 $("body").append(script);
331}
332
333
334function togglePlaylist(listLink) {
335 var $list = $(listLink).parent();
336 var $ul = $list.find('ul');
337 if ($ul.is(":visible")) {
338 $ul.slideUp(function() {
339 $list.css({'height':'inherit'});
340 });
341 } else {
342 $list.closest('ul').find('li.playlist').find('ul').slideUp();
343 $ul.slideDown();
344 $list.css({'height':'auto'});
345 }
346}
347
348showDevelopersLivePlaylist();
349showVideosPlaylists();
350</script>