SlideShare une entreprise Scribd logo
1  sur  65
Design Patterns for
   Tablets and
  Smartphones
 Michael Galpin, Bump Technologies
About me
• Apps!

 • Bump

 • eBay Mobile

• Book!

 • Android in Practice

   • Chapter 15
Agenda
     • Key Concepts

         • App Structure

         • Fragments

     • Goodies

         • Action Bar

         • Loaders

         • Eye Candy
So you built an app...
One app or two?




•Re-use code & assets       •Simpler logic
•Build on Market presence   •New platform features
Library Projects
Breakin’ it down


      App
Breakin’ it down


App             Tablet App



      Library
What’s in a Library?
• I/O: Networking, files, content
 • Data parsing
• Models
• Services, Receivers, Content Providers
• Resources
 • Drawables, Strings
Moving Targets
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.manning.aip.tabdroid"
       android:versionCode="1"
       android:versionName="1.0">
    <uses-sdk android:minSdkVersion="11" />
    <supports-screens
         android:smallScreens="false"
         android:normalScreens="false"
         android:largeScreens="true"
         android:xlargeScreens="true"
         android:requiresSmallestWidthDp="500"
    />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.manning.aip.tabdroid"
       android:versionCode="1"
       android:versionName="1.0">
    <uses-sdk android:minSdkVersion="11" />
    <supports-screens
         android:smallScreens="false"
         android:normalScreens="false"
         android:largeScreens="true"
                                               API <= 12
         android:xlargeScreens="true"
         android:requiresSmallestWidthDp="500"
    />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.manning.aip.tabdroid"
       android:versionCode="1"
       android:versionName="1.0">
    <uses-sdk android:minSdkVersion="11" />
    <supports-screens
         android:smallScreens="false"
         android:normalScreens="false"
         android:largeScreens="true"
         android:xlargeScreens="true"

    />
         android:requiresSmallestWidthDp="500"
                                                       API >= 13
Not all tablets are created
          equally
Screen Size Selectors
Have your cake and eat it
          too
Multiple APKs


App             Tablet App



      Library
Multiple APKs
      MyApp on the Market

App                    Tablet App



            Library
Fragments
Stop me if you’ve heard this one
Fragment
Fragment
Fragment
Fragment
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/details_container">

  <fragment
    class="com.manning.aip.tabdroid.SectionDetailsFragment"
    android:id="@+id/section_list_fragment"
    android:visibility="gone"
    android:layout_marginTop="?android:attr/actionBarSize"
    android:layout_width="300dp"
    android:layout_height="match_parent" />

  <fragment
    class="com.manning.aip.tabdroid.DealFragment"
    android:id="@+id/deal_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</LinearLayout>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/details_container"
  android:gravity="bottom">

  <fragment
    class="com.manning.aip.tabdroid.DealFragment"
    android:id="@+id/deal_fragment"
    android:layout_marginTop="?android:attr/actionBarSize"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

  <fragment
    class="com.manning.aip.tabdroid.FilmstripFragment"
    android:id="@+id/section_filmstrip_fragment"
    android:visibility="gone"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_gravity="bottom"/>

</LinearLayout>
Fragments: Not just for
      Tablets
• “Smart” UI
 • Stateful
 • Mange data (state)
• Communicates
Spot the Fragment
Communication & Coupling
public class SectionDetailsFragment extends ListFragment {	

      private void showDeal(int position){
      	 app.currentItem = app.currentSection.items.get(position);
      	 DealFragment fragment =
            (DealFragment) getFragmentManager().findFragmentById(R.id.deal_fragment);
      	 fragment.showCurrentItem();
      }

      @Override
      public void onListItemClick(ListView l, View v, int position, long id) {
          currentPosition = position;
          showDeal(position);
      }
...
}
Who knows you &
 who do you know?


Fragment   Activity   Fragment
Use an Observer
public class SectionDetailsFragment extends ListFragment {
	 OnItemSelectedListener listener;
	
	 public static interface OnItemSelectedListener {
	 	 public void onItemSelected(Item item);
	 }
	 public void setOnItemSelectedListener(
     OnItemSelectedListener listener){
	 	 this.listener = listener;
	 }

      private void showDeal(int position){
      	app.currentItem = app.currentSection.items.get(position);
      	listener.onItemSelected(app.currentItem);
      }
...
}
...and Observe
public class DealsMain extends Activity implements OnItemSelectedListener{

      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.home);

          SectionDetailsFragment sectionFragment =
          	 (SectionDetailsFragment)
               getFragmentManager().findFragmentById(R.id.section_list_fragment);
          sectionFragment.setOnItemSelectedListener(this);
      }

       @Override
	     public void onItemSelected(Item item) {
       	      DealFragment fragment =
                 (DealFragment) getFragmentManager().findFragmentById(R.id.deal_fragment);
       	      fragment.showItem(item);
	     }
...
}
Queues



Fragment    Activity   Fragment

 inbound                  outbound
Queues



Fragment    Activity   Fragment

 inbound                  outbound
Queues
           (Handlers)


Fragment      Activity   Fragment

 inbound                    outbound
But I have to
  support
Android 2.1
The Action Bar
ActionBar Essentials

• Replaces Menu
• Can be top & bottom in ICS
• Not available in Compatibility Package
 • Helper for menus -> ActionBar
Loaders
Threads
Handlers

Threads
AsyncTask

          Handlers

Threads
AsyncTaskLoader
                     AsyncTask

          Handlers

Threads
Why do I need Loaders?

 • Encapsulates
  • Loading of data
  • Caching of data
  • Updates to data
 • Cursors and Async
Eye Candy
Drag and Drop
class BoxDragListener implements OnDragListener{
  boolean insideOfMe = false;
  Drawable border = null;
  Drawable redBorder = getResources().getDrawable(R.drawable.border3);

    @Override
    public boolean onDrag(View self, DragEvent event) {
      if (event.getAction() == DragEvent.ACTION_DRAG_STARTED){
        border = self.getBackground();
        self.setBackgroundDrawable(redBorder);
      } else if (event.getAction() == DragEvent.ACTION_DRAG_ENTERED){
        insideOfMe = true;
      } else if (event.getAction() == DragEvent.ACTION_DRAG_EXITED){
        insideOfMe = false;
      } else if (event.getAction() == DragEvent.ACTION_DROP){
        if (insideOfMe){
          // add to container

        } else if (event.getAction() == DragEvent.ACTION_DRAG_ENDED){
          self.setBackgroundDrawable(border);
        }
        return true;
    }
}
public class DndActivity extends Activity {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.grid);

             findViewById(R.id.topLeft).setOnDragListener(new BoxDragListener());
             findViewById(R.id.bottomLeft).setOnDragListener(new BoxDragListener());
             findViewById(R.id.topRight).setOnDragListener(new BoxDragListener());
             findViewById(R.id.bottomRight).setOnDragListener(new BoxDragListener());

      }
...
      ImageView imgView = (ImageView) recycledView;
      imgView.setOnLongClickListener(new OnLongClickListener(){

             @Override
             public boolean onLongClick(View view) {
                     ClipData data = ClipData.newPlainText("foo","bar");
                     DragShadowBuilder shadowBuilder = new DragShadowBuilder(owner);
                     owner.startDrag(data, shadowBuilder, owner, 0);
                     return true;
             }

      });
}
Animators

ImageView backgroundImage = (count % 2 == 0) ? rightSlide : leftSlide;

ObjectAnimator anim =
    ObjectAnimator.ofFloat(backgroundImage, "alpha", 0.0f, 1.0f);

anim.addListener(new AnimatorListenerAdapter(){
    public void onAnimationEnd(Animator animator){
        nextSlide();
    }
});
Design Patterns for Tablets and Smartphones

Contenu connexe

Tendances

Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your appsJuan C Catalan
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseRené Winkelmeyer
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Chris Alfano
 
MVVM with SwiftUI and Combine
MVVM with SwiftUI and CombineMVVM with SwiftUI and Combine
MVVM with SwiftUI and CombineTai Lun Tseng
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .netStephen Lorello
 
Why SOLID matters - even for JavaScript
Why SOLID matters - even for JavaScriptWhy SOLID matters - even for JavaScript
Why SOLID matters - even for JavaScriptmartinlippert
 
Getting Started With Material Design
Getting Started With Material DesignGetting Started With Material Design
Getting Started With Material DesignYasin Yildirim
 
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...彼得潘 Pan
 
How to build an AngularJS backend-ready app WITHOUT BACKEND
How to build an AngularJS backend-ready app WITHOUT BACKEND How to build an AngularJS backend-ready app WITHOUT BACKEND
How to build an AngularJS backend-ready app WITHOUT BACKEND Enrique Oriol Bermúdez
 
描画とビジネスをクリーンに分ける(公開用)
描画とビジネスをクリーンに分ける(公開用)描画とビジネスをクリーンに分ける(公開用)
描画とビジネスをクリーンに分ける(公開用)Kenji Tanaka
 
Mad Max is back, plus the rest of our new reviews and notable screenings
Mad Max is back, plus the rest of our new reviews and notable screeningsMad Max is back, plus the rest of our new reviews and notable screenings
Mad Max is back, plus the rest of our new reviews and notable screeningschicagonewsonlineradio
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveVin Lim
 
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...JavaScripters Community
 
Frontends w ithout javascript
Frontends w ithout javascriptFrontends w ithout javascript
Frontends w ithout javascriptStephen Lorello
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 
Session 2
Session 2Session 2
Session 2alfador
 
Promises are so passé - Tim Perry - Codemotion Milan 2016
Promises are so passé - Tim Perry - Codemotion Milan 2016Promises are so passé - Tim Perry - Codemotion Milan 2016
Promises are so passé - Tim Perry - Codemotion Milan 2016Codemotion
 

Tendances (20)

Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your apps
 
ILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterpriseILUG 2010 - Deploying plug-ins to the enterprise
ILUG 2010 - Deploying plug-ins to the enterprise
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
MVVM with SwiftUI and Combine
MVVM with SwiftUI and CombineMVVM with SwiftUI and Combine
MVVM with SwiftUI and Combine
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .net
 
Why SOLID matters - even for JavaScript
Why SOLID matters - even for JavaScriptWhy SOLID matters - even for JavaScript
Why SOLID matters - even for JavaScript
 
Getting Started With Material Design
Getting Started With Material DesignGetting Started With Material Design
Getting Started With Material Design
 
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
Standford 2015 week5: 1.View Controller Lifecycle, Autolayout 2. Scroll View ...
 
How to build an AngularJS backend-ready app WITHOUT BACKEND
How to build an AngularJS backend-ready app WITHOUT BACKEND How to build an AngularJS backend-ready app WITHOUT BACKEND
How to build an AngularJS backend-ready app WITHOUT BACKEND
 
描画とビジネスをクリーンに分ける(公開用)
描画とビジネスをクリーンに分ける(公開用)描画とビジネスをクリーンに分ける(公開用)
描画とビジネスをクリーンに分ける(公開用)
 
Mad Max is back, plus the rest of our new reviews and notable screenings
Mad Max is back, plus the rest of our new reviews and notable screeningsMad Max is back, plus the rest of our new reviews and notable screenings
Mad Max is back, plus the rest of our new reviews and notable screenings
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's Perspective
 
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
 
iOS and Android apps automation
iOS and Android apps automationiOS and Android apps automation
iOS and Android apps automation
 
Frontends w ithout javascript
Frontends w ithout javascriptFrontends w ithout javascript
Frontends w ithout javascript
 
Discontinuing Reader Matches
Discontinuing Reader MatchesDiscontinuing Reader Matches
Discontinuing Reader Matches
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
Session 2
Session 2Session 2
Session 2
 
Promises are so passé - Tim Perry - Codemotion Milan 2016
Promises are so passé - Tim Perry - Codemotion Milan 2016Promises are so passé - Tim Perry - Codemotion Milan 2016
Promises are so passé - Tim Perry - Codemotion Milan 2016
 
Boost your angular app with web workers
Boost your angular app with web workersBoost your angular app with web workers
Boost your angular app with web workers
 

En vedette

The Future of Big Data in Education
The Future of Big Data in EducationThe Future of Big Data in Education
The Future of Big Data in EducationHendrik Drachsler
 
Phoenix Az Inter Tribal Council Ee Presentation
Phoenix   Az Inter Tribal Council   Ee PresentationPhoenix   Az Inter Tribal Council   Ee Presentation
Phoenix Az Inter Tribal Council Ee PresentationICF_HCD
 
A Long Walk to Water - Lssn 8
A Long Walk to Water - Lssn 8A Long Walk to Water - Lssn 8
A Long Walk to Water - Lssn 8Terri Weiss
 
MACE Presentation
MACE PresentationMACE Presentation
MACE PresentationJoss Winn
 
Social media for HE lifelong learning (public version)
Social media for HE lifelong learning (public version)Social media for HE lifelong learning (public version)
Social media for HE lifelong learning (public version)Lis Parcell
 
Lyddie: Unit3 lesson7
Lyddie: Unit3 lesson7Lyddie: Unit3 lesson7
Lyddie: Unit3 lesson7Terri Weiss
 
Bulgaria 25et
Bulgaria 25etBulgaria 25et
Bulgaria 25etGavranica
 
More than a 1000 words
More than a 1000 wordsMore than a 1000 words
More than a 1000 wordsTimothy Kunau
 
Institutions Struggeling with Web2.0
Institutions Struggeling with Web2.0Institutions Struggeling with Web2.0
Institutions Struggeling with Web2.0Hendrik Drachsler
 
Lyddie: Unit3 lesson5
Lyddie: Unit3 lesson5Lyddie: Unit3 lesson5
Lyddie: Unit3 lesson5Terri Weiss
 
Incline & Pacific - なぜ作るのか
Incline & Pacific - なぜ作るのかIncline & Pacific - なぜ作るのか
Incline & Pacific - なぜ作るのかKazuho Oku
 
Opportunities & Obligations
Opportunities & ObligationsOpportunities & Obligations
Opportunities & ObligationsMartin Rehm
 

En vedette (20)

The Future of Big Data in Education
The Future of Big Data in EducationThe Future of Big Data in Education
The Future of Big Data in Education
 
How to pitch an idea
How to pitch an idea How to pitch an idea
How to pitch an idea
 
Phoenix Az Inter Tribal Council Ee Presentation
Phoenix   Az Inter Tribal Council   Ee PresentationPhoenix   Az Inter Tribal Council   Ee Presentation
Phoenix Az Inter Tribal Council Ee Presentation
 
A Long Walk to Water - Lssn 8
A Long Walk to Water - Lssn 8A Long Walk to Water - Lssn 8
A Long Walk to Water - Lssn 8
 
MACE Presentation
MACE PresentationMACE Presentation
MACE Presentation
 
Mobile Web 5.0
Mobile Web 5.0Mobile Web 5.0
Mobile Web 5.0
 
Social media for HE lifelong learning (public version)
Social media for HE lifelong learning (public version)Social media for HE lifelong learning (public version)
Social media for HE lifelong learning (public version)
 
Lyddie: Unit3 lesson7
Lyddie: Unit3 lesson7Lyddie: Unit3 lesson7
Lyddie: Unit3 lesson7
 
Bulgaria 25et
Bulgaria 25etBulgaria 25et
Bulgaria 25et
 
More than a 1000 words
More than a 1000 wordsMore than a 1000 words
More than a 1000 words
 
Net 451 in action
Net 451 in actionNet 451 in action
Net 451 in action
 
Institutions Struggeling with Web2.0
Institutions Struggeling with Web2.0Institutions Struggeling with Web2.0
Institutions Struggeling with Web2.0
 
Lyddie: Unit3 lesson5
Lyddie: Unit3 lesson5Lyddie: Unit3 lesson5
Lyddie: Unit3 lesson5
 
Incline & Pacific - なぜ作るのか
Incline & Pacific - なぜ作るのかIncline & Pacific - なぜ作るのか
Incline & Pacific - なぜ作るのか
 
PresentacióN
PresentacióNPresentacióN
PresentacióN
 
Origen, filosofía
Origen, filosofíaOrigen, filosofía
Origen, filosofía
 
JURE 2010
JURE 2010JURE 2010
JURE 2010
 
19 Sx.I.I.Mb
19 Sx.I.I.Mb19 Sx.I.I.Mb
19 Sx.I.I.Mb
 
Opportunities & Obligations
Opportunities & ObligationsOpportunities & Obligations
Opportunities & Obligations
 
30 wcwb
30 wcwb30 wcwb
30 wcwb
 

Similaire à Design Patterns for Tablets and Smartphones

Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
What's New in Android
What's New in AndroidWhat's New in Android
What's New in AndroidRobert Cooper
 
android level 3
android level 3android level 3
android level 3DevMix
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?Brenda Cook
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Mario Jorge Pereira
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegapyangdj
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaveryangdj
 
Advanced Android gReporter
Advanced Android gReporterAdvanced Android gReporter
Advanced Android gReporternatdefreitas
 
07_UIAndroid.pdf
07_UIAndroid.pdf07_UIAndroid.pdf
07_UIAndroid.pdfImranS18
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Robert DeLuca
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in androidInnovationM
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Concept2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Conceptaborjinik
 
STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOORABU HASAN
 
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...Bruno Salvatore Belluccia
 
Android JetPack: easy navigation with the new Navigation Controller
Android JetPack: easy navigation with the new Navigation ControllerAndroid JetPack: easy navigation with the new Navigation Controller
Android JetPack: easy navigation with the new Navigation ControllerLeonardo Pirro
 

Similaire à Design Patterns for Tablets and Smartphones (20)

Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
What's New in Android
What's New in AndroidWhat's New in Android
What's New in Android
 
android level 3
android level 3android level 3
android level 3
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015
 
Action bar
Action barAction bar
Action bar
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Mini curso Android
Mini curso AndroidMini curso Android
Mini curso Android
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
 
Advanced Android gReporter
Advanced Android gReporterAdvanced Android gReporter
Advanced Android gReporter
 
07_UIAndroid.pdf
07_UIAndroid.pdf07_UIAndroid.pdf
07_UIAndroid.pdf
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Concept2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Concept
 
STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOOR
 
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
GDG Mediterranean Dev Fest Code lab #DevFestMed15 da android ad android wear ...
 
Android JetPack: easy navigation with the new Navigation Controller
Android JetPack: easy navigation with the new Navigation ControllerAndroid JetPack: easy navigation with the new Navigation Controller
Android JetPack: easy navigation with the new Navigation Controller
 

Plus de Michael Galpin

Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in schoolMichael Galpin
 
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump TechnologiesScala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump TechnologiesMichael Galpin
 
That’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your BatteryThat’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your BatteryMichael Galpin
 
Persistent Data Structures And Managed References
Persistent Data Structures And Managed ReferencesPersistent Data Structures And Managed References
Persistent Data Structures And Managed ReferencesMichael Galpin
 
Mobile Development 101
Mobile Development 101Mobile Development 101
Mobile Development 101Michael Galpin
 
RIAs Done Right: Grails, Flex, and EXT GWT
RIAs Done Right: Grails, Flex, and EXT GWTRIAs Done Right: Grails, Flex, and EXT GWT
RIAs Done Right: Grails, Flex, and EXT GWTMichael Galpin
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java DevelopersMichael Galpin
 

Plus de Michael Galpin (11)

Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in school
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump TechnologiesScala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
 
That’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your BatteryThat’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your Battery
 
Persistent Data Structures And Managed References
Persistent Data Structures And Managed ReferencesPersistent Data Structures And Managed References
Persistent Data Structures And Managed References
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
 
Mobile Development 101
Mobile Development 101Mobile Development 101
Mobile Development 101
 
RIAs Done Right: Grails, Flex, and EXT GWT
RIAs Done Right: Grails, Flex, and EXT GWTRIAs Done Right: Grails, Flex, and EXT GWT
RIAs Done Right: Grails, Flex, and EXT GWT
 
Eclipse @eBay 2009
Eclipse @eBay 2009Eclipse @eBay 2009
Eclipse @eBay 2009
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java Developers
 
Eclipse@eBay
Eclipse@eBayEclipse@eBay
Eclipse@eBay
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Design Patterns for Tablets and Smartphones

  • 1. Design Patterns for Tablets and Smartphones Michael Galpin, Bump Technologies
  • 2. About me • Apps! • Bump • eBay Mobile • Book! • Android in Practice • Chapter 15
  • 3. Agenda • Key Concepts • App Structure • Fragments • Goodies • Action Bar • Loaders • Eye Candy
  • 4. So you built an app...
  • 5. One app or two? •Re-use code & assets •Simpler logic •Build on Market presence •New platform features
  • 8. Breakin’ it down App Tablet App Library
  • 9. What’s in a Library? • I/O: Networking, files, content • Data parsing • Models • Services, Receivers, Content Providers • Resources • Drawables, Strings
  • 11.
  • 12.
  • 13.
  • 14. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.manning.aip.tabdroid" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="11" /> <supports-screens android:smallScreens="false" android:normalScreens="false" android:largeScreens="true" android:xlargeScreens="true" android:requiresSmallestWidthDp="500" />
  • 15. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.manning.aip.tabdroid" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="11" /> <supports-screens android:smallScreens="false" android:normalScreens="false" android:largeScreens="true" API <= 12 android:xlargeScreens="true" android:requiresSmallestWidthDp="500" />
  • 16. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.manning.aip.tabdroid" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="11" /> <supports-screens android:smallScreens="false" android:normalScreens="false" android:largeScreens="true" android:xlargeScreens="true" /> android:requiresSmallestWidthDp="500" API >= 13
  • 17. Not all tablets are created equally
  • 19.
  • 20. Have your cake and eat it too
  • 21. Multiple APKs App Tablet App Library
  • 22. Multiple APKs MyApp on the Market App Tablet App Library
  • 23.
  • 25. Stop me if you’ve heard this one
  • 26.
  • 29.
  • 32. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/details_container"> <fragment class="com.manning.aip.tabdroid.SectionDetailsFragment" android:id="@+id/section_list_fragment" android:visibility="gone" android:layout_marginTop="?android:attr/actionBarSize" android:layout_width="300dp" android:layout_height="match_parent" /> <fragment class="com.manning.aip.tabdroid.DealFragment" android:id="@+id/deal_fragment" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
  • 33. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/details_container" android:gravity="bottom"> <fragment class="com.manning.aip.tabdroid.DealFragment" android:id="@+id/deal_fragment" android:layout_marginTop="?android:attr/actionBarSize" android:layout_width="match_parent" android:layout_height="wrap_content" /> <fragment class="com.manning.aip.tabdroid.FilmstripFragment" android:id="@+id/section_filmstrip_fragment" android:visibility="gone" android:layout_width="match_parent" android:layout_height="300dp" android:layout_gravity="bottom"/> </LinearLayout>
  • 34.
  • 35. Fragments: Not just for Tablets • “Smart” UI • Stateful • Mange data (state) • Communicates
  • 37. Communication & Coupling public class SectionDetailsFragment extends ListFragment { private void showDeal(int position){ app.currentItem = app.currentSection.items.get(position); DealFragment fragment = (DealFragment) getFragmentManager().findFragmentById(R.id.deal_fragment); fragment.showCurrentItem(); } @Override public void onListItemClick(ListView l, View v, int position, long id) { currentPosition = position; showDeal(position); } ... }
  • 38. Who knows you & who do you know? Fragment Activity Fragment
  • 39. Use an Observer public class SectionDetailsFragment extends ListFragment { OnItemSelectedListener listener; public static interface OnItemSelectedListener { public void onItemSelected(Item item); } public void setOnItemSelectedListener( OnItemSelectedListener listener){ this.listener = listener; } private void showDeal(int position){ app.currentItem = app.currentSection.items.get(position); listener.onItemSelected(app.currentItem); } ... }
  • 40. ...and Observe public class DealsMain extends Activity implements OnItemSelectedListener{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home); SectionDetailsFragment sectionFragment = (SectionDetailsFragment) getFragmentManager().findFragmentById(R.id.section_list_fragment); sectionFragment.setOnItemSelectedListener(this); } @Override public void onItemSelected(Item item) { DealFragment fragment = (DealFragment) getFragmentManager().findFragmentById(R.id.deal_fragment); fragment.showItem(item); } ... }
  • 41. Queues Fragment Activity Fragment inbound outbound
  • 42. Queues Fragment Activity Fragment inbound outbound
  • 43. Queues (Handlers) Fragment Activity Fragment inbound outbound
  • 44. But I have to support Android 2.1
  • 45.
  • 46.
  • 47.
  • 49.
  • 50.
  • 51.
  • 52. ActionBar Essentials • Replaces Menu • Can be top & bottom in ICS • Not available in Compatibility Package • Helper for menus -> ActionBar
  • 54.
  • 57. AsyncTask Handlers Threads
  • 58. AsyncTaskLoader AsyncTask Handlers Threads
  • 59. Why do I need Loaders? • Encapsulates • Loading of data • Caching of data • Updates to data • Cursors and Async
  • 62. class BoxDragListener implements OnDragListener{ boolean insideOfMe = false; Drawable border = null; Drawable redBorder = getResources().getDrawable(R.drawable.border3); @Override public boolean onDrag(View self, DragEvent event) { if (event.getAction() == DragEvent.ACTION_DRAG_STARTED){ border = self.getBackground(); self.setBackgroundDrawable(redBorder); } else if (event.getAction() == DragEvent.ACTION_DRAG_ENTERED){ insideOfMe = true; } else if (event.getAction() == DragEvent.ACTION_DRAG_EXITED){ insideOfMe = false; } else if (event.getAction() == DragEvent.ACTION_DROP){ if (insideOfMe){ // add to container } else if (event.getAction() == DragEvent.ACTION_DRAG_ENDED){ self.setBackgroundDrawable(border); } return true; } }
  • 63. public class DndActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid); findViewById(R.id.topLeft).setOnDragListener(new BoxDragListener()); findViewById(R.id.bottomLeft).setOnDragListener(new BoxDragListener()); findViewById(R.id.topRight).setOnDragListener(new BoxDragListener()); findViewById(R.id.bottomRight).setOnDragListener(new BoxDragListener()); } ... ImageView imgView = (ImageView) recycledView; imgView.setOnLongClickListener(new OnLongClickListener(){ @Override public boolean onLongClick(View view) { ClipData data = ClipData.newPlainText("foo","bar"); DragShadowBuilder shadowBuilder = new DragShadowBuilder(owner); owner.startDrag(data, shadowBuilder, owner, 0); return true; } }); }
  • 64. Animators ImageView backgroundImage = (count % 2 == 0) ? rightSlide : leftSlide; ObjectAnimator anim = ObjectAnimator.ofFloat(backgroundImage, "alpha", 0.0f, 1.0f); anim.addListener(new AnimatorListenerAdapter(){ public void onAnimationEnd(Animator animator){ nextSlide(); } });

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n