Skip to content

Commit

Permalink
[Android #51] Hooked Device Information fragment to home
Browse files Browse the repository at this point in the history
  • Loading branch information
zakuArbor committed Sep 14, 2021
1 parent f6d6773 commit 6bd30ce
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.example.proxyauth.databinding.ActivityMainBinding
Expand All @@ -30,6 +31,12 @@ class MainActivity : AppCompatActivity() {
)
)
setupActionBarWithNavController(navController, appBarConfiguration)
NavigationUI.setupActionBarWithNavController(this, navController)
navView.setupWithNavController(navController)
}

override fun onSupportNavigateUp(): Boolean {
val navigationController = this.findNavController(R.id.nav_host_fragment_activity_main)
return navigationController.navigateUp()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.Navigation
import com.example.proxyauth.R
import com.example.proxyauth.databinding.FragmentHomeBinding
import java.lang.reflect.Method
Expand Down Expand Up @@ -75,12 +76,13 @@ class HomeFragment : Fragment() {
)
}
devListView.adapter = devAdapter
devListView.onItemClickListener = AdapterView.OnItemClickListener{_, _, pos, _ ->
devListView.onItemClickListener = AdapterView.OnItemClickListener{view, _, pos, _ ->
activity?.let {
//device.address
//device.name
val is_connected: Boolean = isConnected(deviceList[pos])
Toast.makeText(it, deviceList[pos].name + " " + is_connected.toString(), Toast.LENGTH_LONG).show()
Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_device)
//val is_connected: Boolean = isConnected(deviceList[pos])

}
}
updateDevList();
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/res/layout/fragment_device.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="@dimen/activity_horizontal_margin"
android:layout_marginVertical="@dimen/activity_vertical_margin"

android:layout_marginBottom="60dp"
tools:context=".ui.dashboard.DashboardFragment">

<TextView
Expand Down
14 changes: 12 additions & 2 deletions android/app/src/main/res/navigation/mobile_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@
android:id="@+id/navigation_home"
android:name="com.example.proxyauth.ui.home.HomeFragment"
android:label="@string/title_home"
tools:layout="@layout/fragment_home" />
tools:layout="@layout/fragment_home" >
<action
android:id="@+id/action_navigation_home_to_navigation_device"
app:destination="@id/navigation_device"
app:popUpTo="@id/navigation_home" />
</fragment>

<fragment
android:id="@+id/navigation_dashboard"
android:name="com.example.proxyauth.ui.dashboard.DashboardFragment"
android:label="@string/title_dashboard"
tools:layout="@layout/fragment_dashboard" />
tools:layout="@layout/fragment_dashboard" >
<action
android:id="@+id/action_navigation_dashboard_to_navigation_device"
app:destination="@id/navigation_device"
app:popUpTo="@id/navigation_dashboard" />
</fragment>

<fragment
android:id="@+id/navigation_notifications"
Expand Down

0 comments on commit 6bd30ce

Please sign in to comment.