Giter Club home page Giter Club logo

contentmanager's Introduction

ContentManager

Library what helps getting photo or video from device gallery, from a cloud or from a camera. With asynchronous load from cload and fixed bugs for same problem devices like samsung or sony.

Download

Download via Gradle:

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

or Maven:

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

Usage

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 and etc.
    //For sample:
    ImageLoader.getInstance().displayImage(uri.toString(), ivPicture);
  } else {
    //handle video if needed
  }
}
        
/**
* Return progress of load content from cloud
*
* @param loadPercent load progress in percent
*/
@Override
public void onLoadContentProgress(int loadPercent) {
  //Show loader or something like that
}

/**
* 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 need for handle result

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  contentManager.onActivityResult(requestCode, resultCode, data);
}

Override onSaveInstanceState, onRestoreInstanceState. It is need for fix bug with some Samsung and Sony devices when taking photo in 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);

If you will select content from cloud it will be load async and you can track progress with onLoadContentProgress method

Take photo from camera

contentManager.takePhoto();

Look [Sample projects] sample for more information

License

Copyright 2016 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.

contentmanager's People

Contributors

bevzaanton avatar

Watchers

James Cloos avatar Subhash Ramesh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.