forked from lubuwest/Friendiqa
v0.1
This commit is contained in:
parent
591d55f43a
commit
fb560b54b1
115 changed files with 5537 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
|||
// Author: Ben Lau (https://github.com/benlau)
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
namespace AndroidNative {
|
||||
|
||||
/// SystemDispatcher provides an simple messaging interface between C/C++/QML and Java code.
|
||||
|
||||
class SystemDispatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~SystemDispatcher();
|
||||
static SystemDispatcher* instance();
|
||||
|
||||
/// Dispatch a message via Dispatcher
|
||||
/** The message will be first passed to Java's SystemDispatcher and invoke
|
||||
* registered listener. Once it is finished, it will emit the
|
||||
* "dispatched" signal.
|
||||
*
|
||||
*/
|
||||
Q_INVOKABLE void dispatch(QString type , QVariantMap message = QVariantMap());
|
||||
|
||||
/// Load a Java class
|
||||
/** It will dispatch a message to Java and let it to load a Java class. That
|
||||
* will force to run code in static block.
|
||||
*
|
||||
*/
|
||||
Q_INVOKABLE void loadClass(QString javaClassName);
|
||||
|
||||
/// Register JNI native methods. This function must be called in JNI_OnLoad. Otherwise, the messenger will not be working
|
||||
static void registerNatives();
|
||||
|
||||
/// The name of message that will be dispatched during Activity.onActivityResult.
|
||||
static QString ACTIVITY_RESULT_MESSAGE;
|
||||
|
||||
/// The name of message that will be dispatched during Activity.onResume.
|
||||
static QString ACTIVITY_RESUME_MESSAGE;
|
||||
|
||||
signals:
|
||||
/// The signal is emitted when a message is dispatched.
|
||||
void dispatched(QString type , QVariantMap message);
|
||||
|
||||
private:
|
||||
explicit SystemDispatcher(QObject* parent = 0);
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue