Coder Social home page Coder Social logo

android-upnp-browser's Introduction

Android UPnP Library

Forked from "Android UPnP Browser" (available on the Play Store)

A simple and Open Source UPnP library for Android. It retrieves the local UPnP devices and their informations and dynamically add them to your RecyclerView.Adapter

Usage

UPnPHelper is the main entry. You only need to provide it your own adapter (which should extends UPnPDeviceAdapter)

UPnPDeviceAdapter<MyViewHolder> adapter = new UPnPDeviceAdapter<MyViewHolder>(this){
	@NonNull
	@Override
	public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
		//CREATE YOUR HOLDER
	}

	@Override
	public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
		//BIND YOUR HOLDER
	}
	
	@Override
	@DrawableRes
	public int getDefaultIcon() {
		//RETURN DEFAULT DEVICE DRAWABLE
	}
};

UPnPHelper helper = new UPnPHelper(adapter);
helper.startObserver();

The UPnPHelper will open a socket and wait for the UPnPDevices. Each time a new UPnPDevice is found, it will added to your adapter. If the device found already exists in the adapter, it will automatically updated if its parameters have changed.

You can change the default UPnP socket timeout (the default value is set to 60 seconds)

UPnPHelper helper = new UPnPHelper(adapter, 10000); // 10 secondes
helper.startObserver();

You can stop the observation process at any moment by calling destroyObserver.

helper.destroyObserver();

You can override UPnPHelper in order to execute your own code in the following callbacks:

/**
 * Called when the first device has been found, before adding it to the adapter.
 */
void onFirstUPnPDeviceFound();

/**
 * Called each time a device is found / updated.
 */
void onUPnPDeviceFound(@NonNull UPnPDevice device);

/**
 * Called when the UPnP observation has ended (timeout - or destroyObserver called)
 */
void onUPnPObserverEnded();

/**
 * Called on UPnP observation error.
 */
void onUPnPObserverError();

Applications that use the lib

Printoid for OctoPrint LITE

Printoid for OctoPrint PRO

Printoid for OctoPrint PREMIUM

android-upnp-browser's People

Contributors

anthony-stephan-guilloteau avatar anthonyst91 avatar anthonystephan avatar dgmltn avatar kaiwinter 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.