attempt to make gridview
This commit is contained in:
parent
9ea70a30d8
commit
8747e44ae6
|
@ -4,14 +4,22 @@
|
||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2024-09-26T16:53:52.475667960Z">
|
<DropdownSelection timestamp="2024-09-29T11:44:40.817070813Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=RF8X50341NV" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=RF8X50341NV" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
<DialogSelection />
|
<DialogSelection>
|
||||||
|
<targets>
|
||||||
|
<Target type="DEFAULT_BOOT">
|
||||||
|
<handle>
|
||||||
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=RF8X50341NV" />
|
||||||
|
</handle>
|
||||||
|
</Target>
|
||||||
|
</targets>
|
||||||
|
</DialogSelection>
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
</selectionStates>
|
</selectionStates>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -44,6 +44,7 @@ dependencies {
|
||||||
implementation(libs.androidx.navigation.fragment.ktx)
|
implementation(libs.androidx.navigation.fragment.ktx)
|
||||||
implementation(libs.androidx.navigation.ui.ktx)
|
implementation(libs.androidx.navigation.ui.ktx)
|
||||||
implementation(libs.firebase.crashlytics.buildtools)
|
implementation(libs.firebase.crashlytics.buildtools)
|
||||||
|
implementation(libs.androidx.gridlayout)
|
||||||
testImplementation(libs.junit)
|
testImplementation(libs.junit)
|
||||||
androidTestImplementation(libs.androidx.junit)
|
androidTestImplementation(libs.androidx.junit)
|
||||||
androidTestImplementation(libs.androidx.espresso.core)
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.Toast
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.google.mlkit.vision.barcode.common.Barcode
|
import com.google.mlkit.vision.barcode.common.Barcode
|
||||||
import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
|
import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
|
||||||
import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
|
import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
|
||||||
|
@ -72,7 +73,6 @@ class AddProductFragment : Fragment() {
|
||||||
ActivityResultContracts.RequestPermission()
|
ActivityResultContracts.RequestPermission()
|
||||||
) { isGranted: Boolean ->
|
) { isGranted: Boolean ->
|
||||||
if (isGranted) {
|
if (isGranted) {
|
||||||
Toast.makeText(requireContext(), "Granted", Toast.LENGTH_LONG).show()
|
|
||||||
getPicture()
|
getPicture()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(requireContext(), "I need permission in order to take a picture", Toast.LENGTH_LONG).show()
|
Toast.makeText(requireContext(), "I need permission in order to take a picture", Toast.LENGTH_LONG).show()
|
||||||
|
@ -108,19 +108,12 @@ class AddProductFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
db.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
|
db.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
|
||||||
|
|
||||||
|
findNavController().navigate(R.id.storageFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.takePictureButton.setOnClickListener {
|
binding.takePictureButton.setOnClickListener {
|
||||||
|
|
||||||
requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
|
requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
|
||||||
|
|
||||||
// val imageUri: Uri = Uri.fromFile(File(File(context?.filesDir, "pictures"), "test.jpg"))
|
|
||||||
// val imageUri = Uri.parse("pictures/test.jpg")
|
|
||||||
// val picturesDir = File(context?.filesDir, "pictures")
|
|
||||||
// picturesDir.mkdirs()
|
|
||||||
// val uri = Uri.fromFile(File(picturesDir, "test.jpg"))
|
|
||||||
// Log.d("", uri.toString())
|
|
||||||
// takePicture.launch(uri)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.scanButton.setOnClickListener {
|
binding.scanButton.setOnClickListener {
|
||||||
|
@ -133,8 +126,6 @@ class AddProductFragment : Fragment() {
|
||||||
scanner.startScan()
|
scanner.startScan()
|
||||||
.addOnSuccessListener { barcode ->
|
.addOnSuccessListener { barcode ->
|
||||||
binding.productName.setText(barcode.rawValue)
|
binding.productName.setText(barcode.rawValue)
|
||||||
|
|
||||||
// val url = URL()
|
|
||||||
}
|
}
|
||||||
.addOnFailureListener { e ->
|
.addOnFailureListener { e ->
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
|
|
|
@ -5,7 +5,7 @@ import android.provider.BaseColumns
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import android.widget.GridView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,10 +33,7 @@ class StorageFragment : Fragment() {
|
||||||
val db = DBStorageController(requireContext()).readableDatabase
|
val db = DBStorageController(requireContext()).readableDatabase
|
||||||
val projection = arrayOf(BaseColumns._ID, ProductContract.ProductEntry.PRODUCT_NAME, ProductContract.ProductEntry.PRODUCT_NET_WEIGHT, ProductContract.ProductEntry.IMAGE_FILENAME)
|
val projection = arrayOf(BaseColumns._ID, ProductContract.ProductEntry.PRODUCT_NAME, ProductContract.ProductEntry.PRODUCT_NET_WEIGHT, ProductContract.ProductEntry.IMAGE_FILENAME)
|
||||||
|
|
||||||
val selection = "${ProductContract.ProductEntry.PRODUCT_NAME} = ?"
|
val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, null, null, null, null, null)
|
||||||
val selectionArgs = arrayOf("test")
|
|
||||||
|
|
||||||
val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, null)
|
|
||||||
|
|
||||||
with (cursor) {
|
with (cursor) {
|
||||||
while(moveToNext()) {
|
while(moveToNext()) {
|
||||||
|
@ -44,7 +41,7 @@ class StorageFragment : Fragment() {
|
||||||
val netWeight = getDouble(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NET_WEIGHT))
|
val netWeight = getDouble(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NET_WEIGHT))
|
||||||
val pictureFilename = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.IMAGE_FILENAME))
|
val pictureFilename = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.IMAGE_FILENAME))
|
||||||
|
|
||||||
getView()?.findViewById<ConstraintLayout>(R.id.storageLayout)?.addView(
|
getView()?.findViewById<GridView>(R.id.contentGridLayout)?.addView(
|
||||||
AbstractProductView(
|
AbstractProductView(
|
||||||
requireActivity(),
|
requireActivity(),
|
||||||
requireContext(),
|
requireContext(),
|
||||||
|
@ -56,7 +53,5 @@ class StorageFragment : Fragment() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,21 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".StorageFragment">
|
tools:context=".StorageFragment">
|
||||||
|
<androidx.gridlayout.widget.GridLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" android:id="@+id/contentGridLayout" app:columnCount="2"
|
||||||
|
app:rowCount="100">
|
||||||
|
|
||||||
|
</androidx.gridlayout.widget.GridLayout>
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" android:id="@+id/contentLayout"/>
|
||||||
|
</ScrollView>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" android:id="@+id/storageLayout">
|
android:layout_height="match_parent" android:id="@+id/storageLayout">
|
||||||
|
|
|
@ -13,6 +13,7 @@ constraintlayout = "2.1.4"
|
||||||
navigationFragmentKtx = "2.8.0"
|
navigationFragmentKtx = "2.8.0"
|
||||||
navigationUiKtx = "2.8.0"
|
navigationUiKtx = "2.8.0"
|
||||||
firebaseCrashlyticsBuildtools = "3.0.2"
|
firebaseCrashlyticsBuildtools = "3.0.2"
|
||||||
|
gridlayout = "1.0.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "cameraView" }
|
androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "cameraView" }
|
||||||
|
@ -27,6 +28,7 @@ androidx-constraintlayout = { group = "androidx.constraintlayout", name = "const
|
||||||
androidx-navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
|
androidx-navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
|
||||||
androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUiKtx" }
|
androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUiKtx" }
|
||||||
firebase-crashlytics-buildtools = { group = "com.google.firebase", name = "firebase-crashlytics-buildtools", version.ref = "firebaseCrashlyticsBuildtools" }
|
firebase-crashlytics-buildtools = { group = "com.google.firebase", name = "firebase-crashlytics-buildtools", version.ref = "firebaseCrashlyticsBuildtools" }
|
||||||
|
androidx-gridlayout = { group = "androidx.gridlayout", name = "gridlayout", version.ref = "gridlayout" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|
Loading…
Reference in New Issue