ContentManager


Source link: https://github.com/stfalcon-studio/ContentManager

ContentManager

Library for getting photos, videos or files of any type from a device gallery, external storage, cloud(Google Drive, Dropbox and etc) or camera. With asynchronous load from the cloud and fixed bugs for some problem devices like Samsung or Sony.

Who we are

Need iOS and Android apps, MVP development or prototyping? Contact us via [email protected]. We develop software since 2009, and we're known experts in this field. Check out our portfolio and see more libraries from stfalcon-studio.

Download

Download via Gradle:

compile 'com.github.stfalcon:contentmanager:0.5'

or Maven:

<dependency>
<groupId>com.github.stfalcon</groupId>
<artifactId>contentmanager</artifactId>
<version>0.5</version>
<type>pom</type> </dependency>

Migration to version 0.5

In version 0.5 we have removed callback onLoadContentProgress(int loadPercent)(because it is very hard to calculate loadPercent correctly) and replaced it with callback onStartContentLoading() to handle a start of loading content. So if you are using ContentManager previous version, you need to make some correction after updating ContentManager version to 0.5. Also, we have added new cool feature: picking files with any types.

Usage

Add the folowing permission to AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Implement callback interface:

public class MainActivity extends AppCompatActivity implements ContentManager.PickContentListener {

Then implement PickContentListener methods:

/** * Success result callback * * @param uri

Content uri * @param contentType If you pick content can be Image or Video, if take - only Image */ @Override public void onContentLoaded(Uri uri, String contentType) {

 if (contentType.equals(ContentManager.Content.IMAGE.toString())) {

  //You can use any library for display image Fresco, Picasso, ImageLoader

  //For sample:

  ImageLoader.getInstance().displayImage(uri.toString(), ivPicture);

 
}
 else if (contentType.equals(ContentManager.Content.FILE.toString())) {

  //handle file result

  tvUri.setText(uri.toString());

 
}
 
}

 /** * Call when loading started */ @Override public void onStartContentLoading() {

//Show loader or something like that
progressBar.setVisibility(View.VISIBLE);
 
}
  /** * Call if have some problem with getting content * * @param error message */ @Override public void onError(String error) {

//Show error 
}
  /** * Call if user manual cancel picking or taking content */ @Override public void onCanceled() {

//User canceled 
}

Declare field:

private ContentManager contentManager;

Create instance where "this" is your activity:

contentManager = new ContentManager(this, this);

Override onActivityResult method of activity. It is needed for handling the result:

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {

super.onActivityResult(requestCode, resultCode, data);

contentManager.onActivityResult(requestCode, resultCode, data);
 
}

Override onRequestPermissionsResult method to handle realtime permissions:

@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

  super.onRequestPermissionsResult(requestCode, permissions, grantResults);

  contentManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
 
}

Override onSaveInstanceState, onRestoreInstanceState. It is needed for fixing bugs with some Samsung and Sony devices when taking photo in a landscape mode:

@Override protected void onRestoreInstanceState(Bundle savedInstanceState) {

super.onRestoreInstanceState(savedInstanceState);

contentManager.onRestoreInstanceState(savedInstanceState);
 
}
  @Override protected void onSaveInstanceState(Bundle outState) {

super.onSaveInstanceState(outState);

contentManager.onSaveInstanceState(outState);
 
}

Pick image:

contentManager.pickContent(ContentManager.Content.IMAGE);

Pick video:

contentManager.pickContent(ContentManager.Content.VIDEO);
 

Pick file:

contentManager.pickContent(ContentManager.Content.FILE);

Take photo from camera:

contentManager.takePhoto();
 

Take a look at the sample project for more information

Thanks

Thanks to @coomar2841 and his Android Multipicker Library. We peeked at him some points in the implementation of picking files.

License

Copyright 2017 stfalcon.com  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

Interesting concept of products incrementation inspired this Design.

A Kotlin android sample with rxjava, okhttp and retrofit.

SeekbarWithIntervals is an extension of the SeekBar with labels.

A smart seek bar for android with multiple junction points at random seek position.

Fastest way to run your gradle tasks.

RubberStamp is an Android library that makes it easy for you to add a watermark to your images.

Features

  • Add a watermark to your images.
  • It can be text or another image.
  • Multiple ways and features to customize how the watermark looks including attributes like font, color, opacity, size, shadow properties, etc.
  • Flexible API that has multiple pre-defined options to get started quickly.
  • Ability to tile your watermark across an image.

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