From 0b4bdf94ecf989bf8851d6ecb0b1594d5d73c13d Mon Sep 17 00:00:00 2001 From: Ayush-Suman Date: Tue, 11 Feb 2020 17:57:57 +0530 Subject: [PATCH 1/4] Multiple click crash handled --- .../dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt index d0c1b1b..09f2100 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt @@ -83,9 +83,8 @@ class EventsAdapter(private val listener: OnMarkFavouriteClicked): RecyclerView. listener.getDirections(events[position].venue) } - RxView.clicks(holder.view).debounce(200, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe { - listener.showAboutRules(events[position].details, events[position].name, events[position].contact) - } + RxView.clicks(holder.view).debounce(200, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe({ + listener.showAboutRules(events[position].details, events[position].name, events[position].contact)},{}) } From 3a3526064b3c2752ce91410aa2c9b024b880dbc4 Mon Sep 17 00:00:00 2001 From: Ayush-Suman Date: Tue, 11 Feb 2020 18:14:34 +0530 Subject: [PATCH 2/4] Notification Crash Handled --- .../com/dvm/appd/oasis/dbg/MainActivity.kt | 21 ++++++++++++++++--- .../dbg/events/view/adapters/EventsAdapter.kt | 5 ++--- .../wallet/views/adapters/CartChildAdapter.kt | 8 +++---- .../wallet/views/adapters/OrdersAdapter.kt | 4 ++-- .../views/adapters/StallItemsChildAdapter.kt | 8 +++---- .../wallet/views/adapters/StallsAdapter.kt | 4 ++-- 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt index d0b9811..08a373d 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt @@ -223,7 +223,9 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { /*This method is used for the initial setup of the notification channels If the notification chanel already exists, no action is taken, and hence it is safe to call this method every time the app starts*/ - private fun setupNotificationChannel() { + private fun setupNotificationChannel() {try { + + startService(Intent(this, FirebaseMessagingService::class.java)) // Notification Channels are only available for Oreo(Api Level 26) and onwards // Since support libraries don't have a library for setting up notification channels, this check is necessary @@ -249,7 +251,8 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { getString(R.string.chanel_name_status_change_notifications), NotificationManager.IMPORTANCE_HIGH ) - statusChangeChannel.description = getString(R.string.chanel_desc_status_change_notifications) + statusChangeChannel.description = + getString(R.string.chanel_desc_status_change_notifications) statusChangeChannel.canBypassDnd() val eventsChannel = NotificationChannel( @@ -276,7 +279,16 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { cashBackChannel.description = getString(R.string.channel_desc_cashback_notifications) cashBackChannel.canBypassDnd() val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager - notificationManager.createNotificationChannels(listOf(generalChannel, ratingsChannel, statusChangeChannel, eventsChannel, quizChannel, cashBackChannel)) + notificationManager.createNotificationChannels( + listOf( + generalChannel, + ratingsChannel, + statusChangeChannel, + eventsChannel, + quizChannel, + cashBackChannel + ) + ) } FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener { Log.d("Main Activity", "Recived New Token = ${it.token}}") @@ -285,6 +297,9 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { Log.e("Main Activity", "Failed to recive token") setupNotificationChannel() } + }catch (e:Exception){ + + } } private fun checkForUpdates() { diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt index 09f2100..9a6bb99 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/events/view/adapters/EventsAdapter.kt @@ -79,13 +79,12 @@ class EventsAdapter(private val listener: OnMarkFavouriteClicked): RecyclerView. // } RxView.clicks(holder.directions).debounce(200, TimeUnit.MILLISECONDS).observeOn( - AndroidSchedulers.mainThread()).subscribe { + AndroidSchedulers.mainThread()).subscribe ({ listener.getDirections(events[position].venue) - } + },{}) RxView.clicks(holder.view).debounce(200, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe({ listener.showAboutRules(events[position].details, events[position].name, events[position].contact)},{}) - } } \ No newline at end of file diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/CartChildAdapter.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/CartChildAdapter.kt index 40d8af9..e436dd4 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/CartChildAdapter.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/CartChildAdapter.kt @@ -75,11 +75,11 @@ class CartChildAdapter(private val listener: OnButtonClicked): RecyclerView.Adap holder.isVeg.setImageResource(R.drawable.ic_non_veg) } - RxView.clicks(holder.plus).debounce(200, TimeUnit.MILLISECONDS).subscribe { + RxView.clicks(holder.plus).debounce(200, TimeUnit.MILLISECONDS).subscribe ({ listener.plusButtonClicked(cartChildItems[position], cartChildItems[position].quantity + 1) - } + },{}) - RxView.clicks(holder.minus).debounce(200, TimeUnit.MILLISECONDS).subscribe { + RxView.clicks(holder.minus).debounce(200, TimeUnit.MILLISECONDS).subscribe ({ if (cartChildItems[position].quantity > 1) { listener.plusButtonClicked(cartChildItems[position], cartChildItems[position].quantity - 1) @@ -87,6 +87,6 @@ class CartChildAdapter(private val listener: OnButtonClicked): RecyclerView.Adap listener.deleteCartItemClicked(cartChildItems[position].itemId) } - } + },{}) } } \ No newline at end of file diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/OrdersAdapter.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/OrdersAdapter.kt index e0fe057..2039f65 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/OrdersAdapter.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/OrdersAdapter.kt @@ -95,7 +95,7 @@ class OrdersAdapter(private val listener:OrderCardClick): RecyclerView.Adapter 1){ listener.addButtonClicked(stallItems[position], stallItems[position].quantity - 1) @@ -89,7 +89,7 @@ class StallItemsChildAdapter(private val listener:OnAddClickedListener) : Recycl listener.deleteCartItemClicked(stallItems[position].itemId) } - } + },{}) } else { diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/StallsAdapter.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/StallsAdapter.kt index 09748df..5a86ec2 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/StallsAdapter.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/wallet/views/adapters/StallsAdapter.kt @@ -34,9 +34,9 @@ class StallsAdapter (private val listener:OnStallSelectedListener): RecyclerView Glide.with(holder.itemView.context!!).load(stalls[position].imageUrl).circleCrop().placeholder(R.color.zxing_transparent).circleCrop().into(holder.stallImg) - RxView.clicks(holder.parent).debounce(200, TimeUnit.MILLISECONDS).subscribe { + RxView.clicks(holder.parent).debounce(200, TimeUnit.MILLISECONDS).subscribe ({ listener.stallSelected(stalls[position]) - } + },{}) } inner class StallsViewHolder(view: View) : RecyclerView.ViewHolder(view) { val stallName = view.quantity From 4aa1753ee464aca61f980a3223763456124f0dcb Mon Sep 17 00:00:00 2001 From: Ayush-Suman Date: Tue, 11 Feb 2020 19:17:26 +0530 Subject: [PATCH 3/4] Corrected Code Indentation --- .../com/dvm/appd/oasis/dbg/MainActivity.kt | 256 ++++++++++-------- 1 file changed, 142 insertions(+), 114 deletions(-) diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt index 08a373d..8a8179b 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt @@ -73,7 +73,7 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { setStatusBarColor(R.color.OnBoarding_colour) // Hide the status bar. - // window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN + // window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN // Remember that you should never show the action bar if the // status bar is hidden, so hide that too if necessary. actionBar?.hide() @@ -88,12 +88,12 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { } } - /* try { - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - } catch (e: java.lang.Exception) { - sharedPreferences.edit().putBoolean("NAVIGATION DISABLED", false).apply() - }*/ + /* try { + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + } catch (e: java.lang.Exception) { + sharedPreferences.edit().putBoolean("NAVIGATION DISABLED", false).apply() + }*/ remoteConfig = FirebaseRemoteConfig.getInstance() remoteConfig.setDefaults(R.xml.remote_config_defaults) sharedPreferences = AppModule(application).providesSharedPreferences(application) @@ -180,13 +180,22 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { .setPositiveButton( resources.getString(R.string.alert_notification_positive_button), DialogInterface.OnClickListener { dialog, which -> - sharedPreferences.edit().putBoolean("wantsNotification", false).apply() + sharedPreferences.edit().putBoolean("wantsNotification", false) + .apply() try { startActivity(intent) - }catch (e: ActivityNotFoundException){ - Toast.makeText(applicationContext, "Error. Not supported in your phone", Toast.LENGTH_SHORT).show() + } catch (e: ActivityNotFoundException) { + Toast.makeText( + applicationContext, + "Error. Not supported in your phone", + Toast.LENGTH_SHORT + ).show() } catch (e: Exception) { - Toast.makeText(this, "Your mobile doesn't support this feature", Toast.LENGTH_LONG).show() + Toast.makeText( + this, + "Your mobile doesn't support this feature", + Toast.LENGTH_LONG + ).show() dialog.cancel() } }) @@ -210,8 +219,12 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { var deepLink: Uri? = null if (it != null) { deepLink = it.link - Toast.makeText(this, deepLink.getQueryParameter("invitedBy"), Toast.LENGTH_LONG).show() - sharedPreferences.edit().putString(AuthRepository.Keys.referredBy, deepLink.getQueryParameter("invitedBy")).apply() + Toast.makeText(this, deepLink.getQueryParameter("invitedBy"), Toast.LENGTH_LONG) + .show() + sharedPreferences.edit().putString( + AuthRepository.Keys.referredBy, + deepLink.getQueryParameter("invitedBy") + ).apply() Log.d("Main Activity", "Deep link received = $deepLink") } else { Log.e("Main Activity", "Empty link found") @@ -223,88 +236,88 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { /*This method is used for the initial setup of the notification channels If the notification chanel already exists, no action is taken, and hence it is safe to call this method every time the app starts*/ - private fun setupNotificationChannel() {try { - - - startService(Intent(this, FirebaseMessagingService::class.java)) - // Notification Channels are only available for Oreo(Api Level 26) and onwards - // Since support libraries don't have a library for setting up notification channels, this check is necessary - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val generalChannel = NotificationChannel( - getString(R.string.chanel_id_general_notifications), - getString(R.string.chanel_name_general_notifications), - NotificationManager.IMPORTANCE_HIGH - ) - generalChannel.description = getString(R.string.chanel_desc_general_notifications) - generalChannel.canBypassDnd() - - val ratingsChannel = NotificationChannel( - getString(R.string.chanel_id_rating_notifications), - getString(R.string.chanel_name_rating_notifications), - NotificationManager.IMPORTANCE_HIGH - ) - ratingsChannel.description = getString(R.string.chanel_desc_rating_notifications) - ratingsChannel.canBypassDnd() - - val statusChangeChannel = NotificationChannel( - getString(R.string.chanel_id_status_change_notifications), - getString(R.string.chanel_name_status_change_notifications), - NotificationManager.IMPORTANCE_HIGH - ) - statusChangeChannel.description = - getString(R.string.chanel_desc_status_change_notifications) - statusChangeChannel.canBypassDnd() - - val eventsChannel = NotificationChannel( - getString(R.string.channel_id_rating_events), - "Favourite Events", - NotificationManager.IMPORTANCE_HIGH - ) - eventsChannel.description = "Notify about your favourite events" - eventsChannel.canBypassDnd() - - val quizChannel = NotificationChannel( - getString(R.string.channel_id_quiz), - getString(R.string.channel_id_quiz), - NotificationManager.IMPORTANCE_HIGH - ) - quizChannel.description = "Inform about the latest developments in the quiz game" - quizChannel.canBypassDnd() - - val cashBackChannel = NotificationChannel( - getString(R.string.channel_id_cashback_notifications), - "Cashback", - NotificationManager.IMPORTANCE_HIGH - ) - cashBackChannel.description = getString(R.string.channel_desc_cashback_notifications) - cashBackChannel.canBypassDnd() - val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager - notificationManager.createNotificationChannels( - listOf( - generalChannel, - ratingsChannel, - statusChangeChannel, - eventsChannel, - quizChannel, - cashBackChannel + private fun setupNotificationChannel() { + try { + startService(Intent(this, FirebaseMessagingService::class.java)) + // Notification Channels are only available for Oreo(Api Level 26) and onwards + // Since support libraries don't have a library for setting up notification channels, this check is necessary + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val generalChannel = NotificationChannel( + getString(R.string.chanel_id_general_notifications), + getString(R.string.chanel_name_general_notifications), + NotificationManager.IMPORTANCE_HIGH ) - ) - } - FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener { - Log.d("Main Activity", "Recived New Token = ${it.token}}") - // TODO send the new token to the backend server - }.addOnFailureListener { - Log.e("Main Activity", "Failed to recive token") - setupNotificationChannel() - } - }catch (e:Exception){ + generalChannel.description = getString(R.string.chanel_desc_general_notifications) + generalChannel.canBypassDnd() - } + val ratingsChannel = NotificationChannel( + getString(R.string.chanel_id_rating_notifications), + getString(R.string.chanel_name_rating_notifications), + NotificationManager.IMPORTANCE_HIGH + ) + ratingsChannel.description = getString(R.string.chanel_desc_rating_notifications) + ratingsChannel.canBypassDnd() + + val statusChangeChannel = NotificationChannel( + getString(R.string.chanel_id_status_change_notifications), + getString(R.string.chanel_name_status_change_notifications), + NotificationManager.IMPORTANCE_HIGH + ) + statusChangeChannel.description = + getString(R.string.chanel_desc_status_change_notifications) + statusChangeChannel.canBypassDnd() + + val eventsChannel = NotificationChannel( + getString(R.string.channel_id_rating_events), + "Favourite Events", + NotificationManager.IMPORTANCE_HIGH + ) + eventsChannel.description = "Notify about your favourite events" + eventsChannel.canBypassDnd() + + val quizChannel = NotificationChannel( + getString(R.string.channel_id_quiz), + getString(R.string.channel_id_quiz), + NotificationManager.IMPORTANCE_HIGH + ) + quizChannel.description = "Inform about the latest developments in the quiz game" + quizChannel.canBypassDnd() + + val cashBackChannel = NotificationChannel( + getString(R.string.channel_id_cashback_notifications), + "Cashback", + NotificationManager.IMPORTANCE_HIGH + ) + cashBackChannel.description = + getString(R.string.channel_desc_cashback_notifications) + cashBackChannel.canBypassDnd() + val notificationManager = + getSystemService(NOTIFICATION_SERVICE) as NotificationManager + notificationManager.createNotificationChannels( + listOf( + generalChannel, + ratingsChannel, + statusChangeChannel, + eventsChannel, + quizChannel, + cashBackChannel + ) + ) + } + FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener { + Log.d("Main Activity", "Recived New Token = ${it.token}}") + // TODO send the new token to the backend server + }.addOnFailureListener { + Log.e("Main Activity", "Failed to recive token") + setupNotificationChannel() + } + } catch (e: Exception) { + } } private fun checkForUpdates() { val updateManager = AppUpdateManagerFactory.create(this) - updateManager.appUpdateInfo.addOnSuccessListener {appUpdateInfo -> + updateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo -> /*remoteConfig.fetch().addOnCompleteListener {task -> if (task.isSuccessful) { @@ -371,13 +384,16 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) { // Toast.makeText(this, "New Update Available", Toast.LENGTH_LONG).show() Log.d("Main Activity", "NewUpdate Available") - remoteConfig.fetch().addOnCompleteListener {task -> + remoteConfig.fetch().addOnCompleteListener { task -> if (task.isSuccessful) { // Toast.makeText(this, "Fetched Remote config variables successfully", Toast.LENGTH_LONG).show() // Toast.makeText(this, "Result = ${task.result.toString()}", Toast.LENGTH_LONG).show() // Toast.makeText(this, "Available Version = ${appUpdateInfo.availableVersionCode()}", Toast.LENGTH_LONG).show() val versionNumber = remoteConfig.all["update_version"].toString() - if (appUpdateInfo.availableVersionCode().toString() == versionNumber && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) { + if (appUpdateInfo.availableVersionCode().toString() == versionNumber && appUpdateInfo.isUpdateTypeAllowed( + AppUpdateType.IMMEDIATE + ) + ) { // Toast.makeText(this, "Entered flow for immidiate update", Toast.LENGTH_LONG).show() /*updateManager.startUpdateFlowForResult( appUpdateInfo, @@ -386,8 +402,7 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { REQUEST_CODE_UPDATE_IMMIDIATE )*/ startActivity(Intent(this, ImmidiateUpdateActivity::class.java)) - } - else { + } else { // Toast.makeText(this, "Entered flow for flexible update", Toast.LENGTH_LONG).show() /*val updateListener = InstallStateUpdatedListener { updateState -> @@ -399,8 +414,12 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { } } updateManager.registerListener(updateListener)*/ - val snackbar = Snackbar.make(this.coordinator_parent, "A newer version of the app is available", Snackbar.LENGTH_INDEFINITE) - snackbar.setAction("UPDATE", object : View.OnClickListener{ + val snackbar = Snackbar.make( + this.coordinator_parent, + "A newer version of the app is available", + Snackbar.LENGTH_INDEFINITE + ) + snackbar.setAction("UPDATE", object : View.OnClickListener { override fun onClick(v: View?) { /*updateManager.startUpdateFlowForResult( appUpdateInfo, @@ -410,25 +429,30 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { )*/ try { val intent = Intent(Intent.ACTION_VIEW).apply { - data = Uri.parse("https://play.google.com/store/apps/details?id=v2015.oasis.pilani.bits.com.home") + data = + Uri.parse("https://play.google.com/store/apps/details?id=v2015.oasis.pilani.bits.com.home") // setPackage("v2015.oasis.pilani.bits.com.home") } startActivity(intent) } catch (e: Exception) { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=v2015.oasis.pilani.bits.com.home"))) + startActivity( + Intent( + Intent.ACTION_VIEW, + Uri.parse("market://details?id=v2015.oasis.pilani.bits.com.home") + ) + ) } snackbar.dismiss() } }) - snackbar.setBehavior(object : BaseTransientBottomBar.Behavior(){ + snackbar.setBehavior(object : BaseTransientBottomBar.Behavior() { override fun canSwipeDismissView(child: View): Boolean { return false } }) snackbar.show() } - } - else { + } else { // Toast.makeText(this, "Cannot recieve data from remote config", Toast.LENGTH_LONG).show() Log.d("Main Activity", "Unable to fetch from remote config") } @@ -438,8 +462,12 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { } private fun showSnackBarToInstallUpdate(appUpdateManager: AppUpdateManager) { - val snackbar = Snackbar.make(coordinator_parent, "A new update has been downloaded and is ready to install", Snackbar.LENGTH_INDEFINITE) - snackbar.setBehavior(object : BaseTransientBottomBar.Behavior(){ + val snackbar = Snackbar.make( + coordinator_parent, + "A new update has been downloaded and is ready to install", + Snackbar.LENGTH_INDEFINITE + ) + snackbar.setBehavior(object : BaseTransientBottomBar.Behavior() { override fun canSwipeDismissView(child: View): Boolean { return false } @@ -459,10 +487,10 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { super.onResume() setStatusBarColor(R.color.OnBoarding_colour) // Hide the status bar. - // window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN + // window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN // Remember that you should never show the action bar if the // status bar is hidden, so hide that too if necessary. - // actionBar?.hide() + // actionBar?.hide() /*try { window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION @@ -529,11 +557,6 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { fun hideCustomToolbarForLevel2Fragments() { - - - - - bottom_navigation_bar.isVisible = false } @@ -541,7 +564,7 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { Log.d("MainActivity", "Entered function to change color") window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) - window.setStatusBarColor(ContextCompat.getColor(this,color)) + window.setStatusBarColor(ContextCompat.getColor(this, color)) } override fun onWindowFocusChanged(hasFocus: Boolean) { @@ -554,19 +577,24 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { sharedPreferences.edit().putBoolean("NAVIGATION DISABLED", false).apply() }*/ // Hide the status bar. - // window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN + // window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN // Remember that you should never show the action bar if the // status bar is hidden, so hide that too if necessary. - // actionBar?.hide() + // actionBar?.hide() } override fun onNetworkStatusScahnged(isConnected: Boolean) { if (isConnected) { - val snackbar = Snackbar.make(this.coordinator_parent, "Back Online", Snackbar.LENGTH_SHORT) + val snackbar = + Snackbar.make(this.coordinator_parent, "Back Online", Snackbar.LENGTH_SHORT) snackbar.view.setBackgroundColor(resources.getColor(R.color.colorGreen)) snackbar.show() } else { - Snackbar.make(this.coordinator_parent, "Not Connected to the internet", Snackbar.LENGTH_INDEFINITE).setBehavior(object : BaseTransientBottomBar.Behavior(){ + Snackbar.make( + this.coordinator_parent, + "Not Connected to the internet", + Snackbar.LENGTH_INDEFINITE + ).setBehavior(object : BaseTransientBottomBar.Behavior() { override fun canSwipeDismissView(child: View): Boolean { return false } From e5b1c00c41f92391abb08c6c916ecd3aecf6579a Mon Sep 17 00:00:00 2001 From: Ayush-Suman Date: Tue, 11 Feb 2020 19:24:08 +0530 Subject: [PATCH 4/4] Corrected Code Indentation --- app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt b/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt index 8a8179b..616d6c6 100644 --- a/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt +++ b/app/src/main/java/com/dvm/appd/oasis/dbg/MainActivity.kt @@ -263,8 +263,7 @@ class MainActivity : AppCompatActivity(), NetworkChangeNotifier { getString(R.string.chanel_name_status_change_notifications), NotificationManager.IMPORTANCE_HIGH ) - statusChangeChannel.description = - getString(R.string.chanel_desc_status_change_notifications) + statusChangeChannel.description = getString(R.string.chanel_desc_status_change_notifications) statusChangeChannel.canBypassDnd() val eventsChannel = NotificationChannel(