This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
_____ _____ _ | |
| __ \ / ____| | | | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __ | |
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__| | |
| |__| | __/ |____| | | |_| | |_) | || (_) | | | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_| | |
__/ | | | |
|___/|_| | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentFilter; | |
import android.net.wifi.WifiConfiguration; | |
import android.net.wifi.WifiManager; | |
import android.support.annotation.NonNull; | |
import android.util.Log; | |
import static android.content.ContentValues.TAG; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.example.josiassena.jobscheduler"> | |
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void getCameraIds() { | |
cameraManager = (CameraManager) appContext.getSystemService(Context.CAMERA_SERVICE); | |
CameraCharacteristics cameraCharacteristics; | |
try { | |
for (String cameraId : cameraManager.getCameraIdList()) { | |
cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId); | |
if (isCameraFacingBack(cameraCharacteristics) && backCameraId == null) { | |
backCameraId = cameraId; | |
} else if (isCameraFacingFront(cameraCharacteristics) && frontCameraId == null) { | |
frontCameraId = cameraId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void getCameraIds() { | |
cameraManager = (CameraManager) appContext.getSystemService (Context.CAMERA_SERVICE); | |
CameraCharacteristics cameraCharacteristics; | |
try { | |
for (String cameraId : cameraManager.getCameraIdList()) { | |
cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId); | |
if (isCameraFacingBack(cameraCharacteristics)) { | |
backCameraId = cameraId; | |
} else if (isCameraFacingFront(cameraCharacteristics)) { | |
frontCameraId = cameraId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.packagename"> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> | |
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /> | |
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> | |
<application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GraphQLApi(private val sharedOkHttpClientBuilder: OkHttpClient.Builder) { | |
// ... | |
fun <D : Operation.Data, V : Operation.Variables> subscribe(subscription: Subscription<D, D, V>): Flowable<Response<D>> { | |
// Create our dedicated apollo client | |
val apolloClient = ApolloSubscriptionClientFactory(sharedOkHttpClientBuilder) | |
.createSubscriptionApolloClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subscription onNewMessagesReceived($groupUUID: String!) { | |
groupChatSubscription(group: $groupUUID) { | |
... on Message { | |
uuid | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApolloSubscriptionClientFactory { | |
fun createSubscriptionApolloClient(sharedOkHttpClientBuilder: OkHttpClient.Builder): ApolloClient { | |
val okHttpClient = sharedOkHttpClientBuilder | |
.pingInterval(KEEP_ALIVE_INTERVAL, TimeUnit.SECONDS) | |
.build() | |
val subscriptionTransportFactory = WebSocketSubscriptionTransport.Factory("wss://your_subscription_host/graphql", okHttpClient) | |
return ApolloClient.builder() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomePresenterOrViewModelEtc(private val api: GraphQLApi) { | |
// ... | |
fun sunscribeToMessages() { | |
val messagesSubscription = OnNewMessagesReceivedSubscription.builder() | |
.groupUUID("uuid") | |
.build() | |
api.subscribe(messagesSubscription) |
NewerOlder