MediaFacade


Source link: https://github.com/Drivemode/MediaFacade

MediaFacade

Facade modules for dealing with complicated MediaStore in a simple way.

Usage

Audio

Audio in MediaStore has several tables like Media, Artists, Albums, Playlists and Genres. MediaFacade provides easy accesses to those tables.

Albums

public class SampleActivity extends Activity {

private AudioFacade facade;
 @Override
protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

// ...

facade = AudioFacade.getInstance(this);

  Cursor albums = null;
  try {

 albums = facade.album().fetchAlbum();

 // do whatever you like with the album metadata
  
}
 finally {

 if (albums != null)

albums.close();

  
}

}
 
}

Artists

public class SampleActivity extends Activity {

private AudioFacade facade;
 @Override
protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

// ...

facade = AudioFacade.getInstance(this);

  Cursor artists = null;
  try {

 artists = facade.artist().fetchArtists();

 // do whatever you like with the album metadata
  
}
 finally {

 if (artists != null)

artists.close();

  
}

}
 
}

Genres

public class SampleActivity extends Activity {

private AudioFacade facade;
 @Override
protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

// ...

facade = AudioFacade.getInstance(this);

  Cursor genres = null;
  try {

 genres = facade.genre().fetchGenres();

 // do whatever you like with the album metadata
  
}
 finally {

 if (genres != null)

genres.close();

  
}

}
 
}

Playlists

public class SampleActivity extends Activity {

private AudioFacade facade;
private EditText playlistName;
 @Override
protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

// ...

facade = AudioFacade.getInstance(this);

  Cursor playlists = null;
  try {

 playlists = facade.playlist().fetchGenres();

 // do whatever you like with the album metadata
  
}
 finally {

 if (playlists != null)

playlists.close();

  
}

}

 public void onNewPlaylistButtonClick(View v) {

  String name = playlistName.getText().toString();

  Uri uri = facade.playlist().createNew(name);

  // you can add music tracks with this uri

}
 
}

Image and Video

Image and Video have similar structure in their tables. One noteworthy concept is Bucket, which is kind of Album for images and/or videos. Image and Video have 2 columns ( BUCKET_ID and BUCKET_DISPLAY_NAME) for describing which bucket the image belongs to.

Bucket

Since there's no specific table that manages each buckets so you need to group by bucket when you query images/videos in SQL. ImageFacade and VideoFacade do grouping for you.

public class SampleActivity extends Activity {

private ImageFacade facade;
 @Override
protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

// ...

facade = ImageFacade.getInstance(this);

  Cursor imageBuckets = null;
  try {

 imageBuckets = facade.bucket().fetch();

 if (imageBuckets == null)

return;

 while (imageBuckets.moveToNext()) {

long bucketId = imageBuckets.getLong(imageBuckets.getColumnIndex(MediaStore.Image.Media.BUCKET_ID));

// you can query images in the specific bucket with this bucketId

Cursor imagesInBucket = facade.image().fetchByBucket(bucketId);

// ...

 
}

  
}
 finally {

 if (imageBuckets != null)

imageBuckets.close();

  
}

}
 
}

Cursors

MediaFacade provides customized yet fully Android compatible Cursors for developers to access fields by just calling corresponding methods.

public class SampleActivity extends Activity {

private ImageFacade facade;
 @Override
protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

// ...

facade = ImageFacade.getInstance(this);

  ImageCursor imageBuckets = null;
  try {

 imageBuckets = facade.bucket().fetch();

 if (imageBuckets == null)

return;

 while (imageBuckets.moveToNext()) {

long bucketId = imageBuckets.id();

// you can query images in the specific bucket with this bucketId

ImageCursor imagesInBucket = facade.image().fetchByBucket(bucketId);

// ...

 
}

  
}
 finally {

 if (imageBuckets != null)

imageBuckets.close();

  
}

}
 
}

We have following customized classes of Cursors.

  • MediaItemCursor
  • AlbumCursor
  • AlbumItemCursor
  • GenreCursor
  • GenreItemCursor
  • ArtistCursor
  • ArtistItemCursor
  • PlaylistCurosr
  • PlaylistItemCurosr
  • ImageCursor
  • VideoCursor

These Cursors are subclasses of Cursor so that you can use them with CursorAdapter and various Cursor API.

Download

Gradle:

compile 'com.drivemode:mediafacade-audio:0.1.0@aar' compile 'com.drivemode:mediafacade-image:0.1.0@aar' compile 'com.drivemode:mediafacade-video:0.1.0@aar' 

License

Apache v2

Copyright (C) 2016 Drivemode, Inc. All rights reserved.  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
 http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

android-checkout is a library for Android In-App Billing (v3). The main goal is to reduce work which should be done by developers who want to integrate in-app purchases in their products. The project is inspired by Volley library and is designed to be easy to use, fast and flexible.

Mobile App testing on 300+ real devices!

  • Save in App Development Costs
  • Reduce Risks with Proactive, Agile Testing
  • Speed Up Time to Market
  • Reduce Operational & Unpredictable Costs
  • Improve App Ratings & Brand Reputation

AndroidAsync is a low level network protocol library.

Features:

  • Based on NIO. One thread, driven by callbacks. Highly efficient.
  • All operations return a Future that can be cancelled
  • Socket client + socket server
  • HTTP client + server
  • WebSocket client + server
  • Socket.IO client

This library is an Android networking abstraction library consisting of a combination of Volley, OkHttp, and Jackson, with a little glue to stick it all together. It's a great place to start if you need to execute requests, especially thos which return JSON.

RoboCoP is a Java library that can generate a fully-functional ContentProvider from a simple JSON schema file.

If you are looking for a listview with a paged header this is the dependency you are looking for. With PagedHeadListView you will be able to set your own fragments as new pages for the header, and a brand new indicator will be added automatically. You can play with all the custom attributes provided with the library to set indicator colors and position, ViewPager drag animation, and touch behaviour for the header view.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes