Java Code Examples for com.serenegiant.utils.HandlerThreadHandler

The following examples show how to use com.serenegiant.utils.HandlerThreadHandler. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: libcommon   Source File: BluetoothManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * コンストラクタ
 * @param context
 * @param name サービス名, 任意, nullまたは空文字列ならば端末のモデルとIDを使う
 * @param secureProfileUUID 接続に使用するプロトコル(プロファイル)を識別するためのUUID。セキュア接続用。Android同士でつなぐなら任意で可。PC等のBluetoothシリアル通信を行うならUUID_SPPを使う
 * @param inSecureProfileUUID 接続に使用するプロトコル(プロファイル)を識別するためのUUID。インセキュア接続用。Android同士でつなぐなら任意で可。PC等のBluetoothシリアル通信を行うならUUID_SPPを使う nullならsecureProfileUUIDを使う
 * @param callback
 */
public BluetoothManager(@NonNull final Context context, final String name,
	@NonNull final UUID secureProfileUUID,
	@Nullable final UUID inSecureProfileUUID,
	@NonNull final BluetoothManagerCallback callback) {

	mWeakContext = new WeakReference<Context>(context);
	mName = !TextUtils.isEmpty(name) ? name : Build.MODEL + "_" + Build.ID;
	mSecureProfileUUID = secureProfileUUID;
	mInSecureProfileUUID = inSecureProfileUUID != null ? inSecureProfileUUID : secureProfileUUID;
	if (callback != null) {
		mCallbacks.add(callback);
	}
	mAdapter = BluetoothAdapter.getDefaultAdapter();
	if ((mAdapter == null) || !mAdapter.isEnabled()) {
		throw new IllegalStateException("bluetoothに対応していないか無効になっている");
	}
	mState = STATE_NONE;
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
	filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
	context.registerReceiver(mBroadcastReceiver, filter);
}
 
Example 2
Source Project: libcommon   Source File: BaseService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();
	if (DEBUG) Log.v(TAG, "onCreate:");
	final Context app_context = getApplicationContext();
	synchronized (mSync) {
		mLocalBroadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
		final IntentFilter filter = createIntentFilter();
		if ((filter != null) && filter.countActions() > 0) {
			mLocalBroadcastManager.registerReceiver(mLocalBroadcastReceiver, filter);
		}
		if (mAsyncHandler == null) {
			mAsyncHandler = HandlerThreadHandler.createHandler(getClass().getSimpleName());
		}
	}
}
 
Example 3
Source Project: libcommon   Source File: UdpBeacon.java    License: Apache License 2.0 6 votes vote down vote up
/**
	 * コンストラクタ
	 * @param callback
	 * @param port ビーコン用のポート番号
	 * @param beacon_intervals_ms ビーコン送信周期[ミリ秒], receiveOnly=trueなら無効
	 * @param receiveOnly ビーコンを送信せずに受信だけ行うかどうか, true:ビーコン送信しない
	 * @param rcv_min_intervals_ms 最小受信間隔[ミリ秒]
	 */
	public UdpBeacon(@Nullable final UdpBeaconCallback callback, final int port,
		final long beacon_intervals_ms, final boolean receiveOnly,
		final long rcv_min_intervals_ms) {
		
//		if (DEBUG) Log.v(TAG, "コンストラクタ:");
		if (callback != null) {
			mCallbacks.add(callback);
		}
		mAsyncHandler = HandlerThreadHandler.createHandler("UdpBeaconAsync");
		uuid = UUID.randomUUID();
		final Beacon beacon = new Beacon(uuid, port);
		beaconBytes = beacon.asBytes();
		mBeaconIntervalsMs = beacon_intervals_ms;
		mReceiveOnly = receiveOnly;
		mRcvMinIntervalsMs = rcv_min_intervals_ms;
	}
 
Example 4
Source Project: libcommon   Source File: ConnectivityHelper.java    License: Apache License 2.0 6 votes vote down vote up
public ConnectivityHelper(@NonNull final Context context,
	@NonNull final ConnectivityCallback callback) {

	if (DEBUG) Log.v(TAG, "Constructor:");
	mWeakContext = new WeakReference<>(context);
	mCallback = callback;
	mUIHandler = new Handler(context.getMainLooper());
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	mUIHandler.post(new Runnable() {
		@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
		@Override
		public void run() {
			init();
		}
	});
}
 
Example 5
Source Project: libcommon   Source File: DocumentTreeRecyclerAdapter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * コンストラクタ
 * @param context
 * @param layoutResId
 * @param root ディレクトリを示すDocumentFile
 */
public DocumentTreeRecyclerAdapter(
	@NonNull final Context context,
	@LayoutRes final int layoutResId,
	@NonNull final DocumentFile root) {

	super();
	if (root == null || !root.isDirectory()) {
		throw new IllegalArgumentException("root should be a directory!");
	}
	mContext = context;
	mLayoutRes = layoutResId;
	mRoot = root;
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	internalChangeDir(root);
}
 
Example 6
Source Project: AndroidUSBCamera   Source File: USBMonitor.java    License: Apache License 2.0 5 votes vote down vote up
public USBMonitor(final Context context, final OnDeviceConnectListener listener) {
	if (DEBUG) Log.v(TAG, "USBMonitor:Constructor");
	if (listener == null)
		throw new IllegalArgumentException("OnDeviceConnectListener should not null.");
	mWeakContext = new WeakReference<Context>(context);
	mUsbManager = (UsbManager)context.getSystemService(Context.USB_SERVICE);
	mOnDeviceConnectListener = listener;
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	destroyed = false;
	if (DEBUG) Log.v(TAG, "USBMonitor:mUsbManager=" + mUsbManager);
}
 
Example 7
Source Project: libcommon   Source File: AbstractDistributeTask.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * コンストラクタ
 * @param width
 * @param height
 * @param enableVSync Choreographerを使ってvsync同期して映像更新するかどうか
 */
protected AbstractDistributeTask(final int width, final int height,
	final boolean enableVSync) {

	if (DEBUG) Log.v(TAG, "コンストラクタ:enableVSync=" + enableVSync);
	mVideoWidth = width > 0 ? width : 640;
	mVideoHeight = height > 0 ? height : 480;
	mEnableVSync = enableVSync;
	mReleased = false;
	if (enableVSync) {
		mChoreographerHandler = HandlerThreadHandler.createHandler(TAG);
	} else {
		mChoreographerHandler = null;
	}
}
 
Example 8
Source Project: libcommon   Source File: MixRendererHolder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * コンストラクタ
 * @param parent
 * @param width
 * @param height
 * @param maxClientVersion
 * @param sharedContext
 * @param flags
 * @param enableVsync vsyncに同期して描画要求するかどうか
 */
public MixRendererTask(@NonNull final AbstractRendererHolder parent,
	final int width, final int height,
	final int maxClientVersion,
	@Nullable final EGLBase.IContext sharedContext, final int flags,
	final boolean enableVsync) {

	super(parent, width, height, maxClientVersion, sharedContext, flags, enableVsync);
	if (BuildCheck.isAndroid5()) {
		mAsyncHandler = HandlerThreadHandler.createHandler("OnFrameAvailable");
	}
	if (DEBUG) Log.v(TAG, "MixRendererTask#コンストラクタ:");
}
 
Example 9
Source Project: libcommon   Source File: AbstractChannelDataLink.java    License: Apache License 2.0 5 votes vote down vote up
public AbstractClient(@NonNull final AbstractChannelDataLink parent,
	@Nullable final ByteChannel channel) {

	if (DEBUG) Log.v(TAG, "Client#コンストラクタ:channel=" + channel);
	mWeakParent = new WeakReference<AbstractChannelDataLink>(parent);
	mSenderHandler = HandlerThreadHandler.createHandler(this);
	mChannel = channel;
}
 
Example 10
Source Project: libcommon   Source File: USBMonitor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * コンストラクタ
 * @param context
 * @param listener
 */
public USBMonitor(@NonNull final Context context,
	@NonNull final OnDeviceConnectListener listener) {

	if (DEBUG) Log.v(TAG, "USBMonitor:コンストラクタ");
	mWeakContext = new WeakReference<Context>(context);
	mUsbManager = ContextUtils.requireSystemService(context, UsbManager.class);
	mOnDeviceConnectListener = listener;
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	destroyed = false;
	if (DEBUG) Log.v(TAG, "USBMonitor:mUsbManager=" + mUsbManager);
}
 
Example 11
Source Project: DeviceConnect-Android   Source File: USBMonitor.java    License: MIT License 5 votes vote down vote up
public USBMonitor(final Context context, final OnDeviceConnectListener listener) {
	if (DEBUG) Log.v(TAG, "USBMonitor:Constructor");
	if (listener == null)
		throw new IllegalArgumentException("OnDeviceConnectListener should not null.");
	mWeakContext = new WeakReference<Context>(context);
	mUsbManager = (UsbManager)context.getSystemService(Context.USB_SERVICE);
	mOnDeviceConnectListener = listener;
	mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
	destroyed = false;
	if (DEBUG) Log.v(TAG, "USBMonitor:mUsbManager=" + mUsbManager);
}