{"id":21331049,"url":"https://github.com/bobomee/mediafacade","last_synced_at":"2025-03-16T00:41:55.352Z","repository":{"id":160854611,"uuid":"93321481","full_name":"BoBoMEe/MediaFacade","owner":"BoBoMEe","description":null,"archived":false,"fork":false,"pushed_at":"2017-06-04T15:10:13.000Z","size":118,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T13:46:08.966Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BoBoMEe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-04T15:10:00.000Z","updated_at":"2020-10-29T02:01:24.000Z","dependencies_parsed_at":"2023-09-11T13:45:18.188Z","dependency_job_id":null,"html_url":"https://github.com/BoBoMEe/MediaFacade","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoBoMEe%2FMediaFacade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoBoMEe%2FMediaFacade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoBoMEe%2FMediaFacade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoBoMEe%2FMediaFacade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BoBoMEe","download_url":"https://codeload.github.com/BoBoMEe/MediaFacade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809848,"owners_count":20351407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T22:28:43.438Z","updated_at":"2025-03-16T00:41:55.321Z","avatar_url":"https://github.com/BoBoMEe.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MediaFacade\n\nFacade modules for dealing with complicated MediaStore in a simple way.\n\n## Usage\n\n### Files\n\n`Files` in `MediaStore` is the file that non-media file types (text, HTML, PDF, etc)\n`FilesFacade` provides easy accesses to those files.\n\n```java\npublic class SampleActivity extends Activity {\n  private FilesFacade facade;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    // ...\n    facade = FilesFacade.getInstance(this);\n    Cursor files = null;\n    try {\n      files = facade.mimeType().fetch(new String[] { \"image/jpeg\" });\n      // do whatever you like with the album metadata\n    } finally {\n      if (files != null)\n        files.close();\n    }\n  }\n\n}\n```\n\n### Audio\n\n`Audio` in `MediaStore` has several tables like `Media`, `Artists`, `Albums`, `Playlists` and `Genres`.\n`MediaFacade` provides easy accesses to those tables.\n\n#### Albums\n\n```java\npublic class SampleActivity extends Activity {\n  private AudioFacade facade;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    // ...\n\n    facade = AudioFacade.getInstance(this);\n    Cursor albums = null;\n    try {\n      albums = facade.album().fetchAlbum();\n      // do whatever you like with the album metadata\n    } finally {\n      if (albums != null)\n        albums.close();\n    }\n  }\n}\n```\n\n#### Artists\n\n```java\npublic class SampleActivity extends Activity {\n  private AudioFacade facade;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    // ...\n\n    facade = AudioFacade.getInstance(this);\n    Cursor artists = null;\n    try {\n      artists = facade.artist().fetchArtists();\n      // do whatever you like with the album metadata\n    } finally {\n      if (artists != null)\n        artists.close();\n    }\n  }\n}\n```\n\n#### Genres\n\n```java\npublic class SampleActivity extends Activity {\n  private AudioFacade facade;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    // ...\n\n    facade = AudioFacade.getInstance(this);\n    Cursor genres = null;\n    try {\n      genres = facade.genre().fetchGenres();\n      // do whatever you like with the album metadata\n    } finally {\n      if (genres != null)\n        genres.close();\n    }\n  }\n}\n```\n\n#### Playlists\n\n```java\npublic class SampleActivity extends Activity {\n  private AudioFacade facade;\n  private EditText playlistName;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    // ...\n\n    facade = AudioFacade.getInstance(this);\n    Cursor playlists = null;\n    try {\n      playlists = facade.playlist().fetchGenres();\n      // do whatever you like with the album metadata\n    } finally {\n      if (playlists != null)\n        playlists.close();\n    }\n  }\n\n  public void onNewPlaylistButtonClick(View v) {\n    String name = playlistName.getText().toString();\n    Uri uri = facade.playlist().createNew(name);\n    // you can add music tracks with this uri\n  }\n}\n```\n\n### Image and Video\n\n`Image` and `Video` have similar structure in their tables.\nOne noteworthy concept is `Bucket`, which is kind of `Album` for images and/or videos.\n`Image` and `Video` have 2 columns (`BUCKET_ID` and `BUCKET_DISPLAY_NAME`) for describing which bucket the image belongs to.\n\n#### Bucket\n\nSince there's no specific table that manages each buckets so you need to group by bucket when you query images/videos in SQL.\n`ImageFacade` and `VideoFacade` do grouping for you.\n\n```java\npublic class SampleActivity extends Activity {\n  private ImageFacade facade;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    // ...\n\n    facade = ImageFacade.getInstance(this);\n    Cursor imageBuckets = null;\n    try {\n      imageBuckets = facade.bucket().fetch();\n      if (imageBuckets == null)\n        return;\n      while (imageBuckets.moveToNext()) {\n        long bucketId = imageBuckets.getLong(imageBuckets.getColumnIndex(MediaStore.Image.Media.BUCKET_ID));\n        // you can query images in the specific bucket with this bucketId\n        Cursor imagesInBucket = facade.image().fetchByBucket(bucketId);\n        // ...\n      }\n    } finally {\n      if (imageBuckets != null)\n        imageBuckets.close();\n    }\n  }\n}\n```\n\n### Cursors\n\nMediaFacade provides customized yet fully Android compatible `Cursor`s for developers to access fields by just calling corresponding methods.\n\n```java\npublic class SampleActivity extends Activity {\n  private ImageFacade facade;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    // ...\n\n    facade = ImageFacade.getInstance(this);\n    ImageCursor imageBuckets = null;\n    try {\n      imageBuckets = facade.bucket().fetch();\n      if (imageBuckets == null)\n        return;\n      while (imageBuckets.moveToNext()) {\n        long bucketId = imageBuckets.id();\n        // you can query images in the specific bucket with this bucketId\n        ImageCursor imagesInBucket = facade.image().fetchByBucket(bucketId);\n        // ...\n      }\n    } finally {\n      if (imageBuckets != null)\n        imageBuckets.close();\n    }\n  }\n}\n```\n\nWe have following customized classes of `Cursor`s.\n\n- MediaCursor\n- FilesCursor\n\n- AlbumCursor\n- AlbumMembersCursor\n- GenreCursor\n- GenreMembersCursor\n- ArtistCursor\n- ArtistMembersCursor\n- PlaylistCurosr\n- PlaylistMembersCurosr\n\n- ImageCursor\n\n- VideoCursor\n\nThese `Cursor`s are subclasses of `Cursor` so that you can use them with `CursorAdapter` and various `Cursor` API.\n\n\n## License\n\nApache v2\n\n```\nCopyright (C) 2016 Drivemode, Inc. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License.\n```\n\nApache v2\n\n```\nCopyright (C) 2017 BoBoMEe. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License.\n```\n\n## Links\n\n- [MediaFacade](https://github.com/Drivemode/MediaFacade)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobomee%2Fmediafacade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobomee%2Fmediafacade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobomee%2Fmediafacade/lists"}