Java源码示例:no.nordicsemi.android.dfu.DfuServiceListenerHelper

示例1
@Override
public void onResume() {
    super.onResume();

    assert (mBlePeripheralAddress != null);
    Context context = getContext();
    if (context != null) {
        DfuServiceListenerHelper.registerProgressListener(context, mDfuProgressListener, mBlePeripheralAddress);
    }

    // Keep screen on
    FragmentActivity activity = getActivity();
    if (activity != null) {
        ScreenUtils.keepScreenOn(activity, true);
    }
}
 
示例2
@Override
public void onPause() {
    super.onPause();

    Context context = getContext();
    if (context != null) {
        DfuServiceListenerHelper.unregisterProgressListener(context, mDfuProgressListener);
    }

    // Disable keep screen on
    FragmentActivity activity = getActivity();
    if (activity != null) {
        ScreenUtils.keepScreenOn(activity, false);
    }

}
 
示例3
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_feature_dfu);
	isBLESupported();
	if (!isBLEEnabled()) {
		showBLEDialog();
	}
	setGUI();

	// restore saved state
	fileType = DfuService.TYPE_AUTO; // Default
	if (savedInstanceState != null) {
		fileType = savedInstanceState.getInt(DATA_FILE_TYPE);
		fileTypeTmp = savedInstanceState.getInt(DATA_FILE_TYPE_TMP);
		filePath = savedInstanceState.getString(DATA_FILE_PATH);
		fileStreamUri = savedInstanceState.getParcelable(DATA_FILE_STREAM);
		initFilePath = savedInstanceState.getString(DATA_INIT_FILE_PATH);
		initFileStreamUri = savedInstanceState.getParcelable(DATA_INIT_FILE_STREAM);
		selectedDevice = savedInstanceState.getParcelable(DATA_DEVICE);
		statusOk = statusOk || savedInstanceState.getBoolean(DATA_STATUS);
		scope = savedInstanceState.containsKey(DATA_SCOPE) ? savedInstanceState.getInt(DATA_SCOPE) : null;
		uploadButton.setEnabled(selectedDevice != null && statusOk);
		dfuCompleted = savedInstanceState.getBoolean(DATA_DFU_COMPLETED);
		dfuError = savedInstanceState.getString(DATA_DFU_ERROR);
	}

	DfuServiceListenerHelper.registerProgressListener(this, dfuProgressListener);
}
 
示例4
@Override
protected void onDestroy() {
	super.onDestroy();
	DfuServiceListenerHelper.unregisterProgressListener(this, dfuProgressListener);
}
 
示例5
@Override
public void onResume() {
	super.onResume();

	DfuServiceListenerHelper.registerProgressListener(getActivity(), mDfuProgressListener);
}
 
示例6
@Override
public void onPause() {
	super.onPause();

	DfuServiceListenerHelper.unregisterProgressListener(getActivity(), mDfuProgressListener);
}