cleanup
This commit is contained in:
parent
5fb481a0d5
commit
cfef250d38
|
@ -4,7 +4,6 @@ import android.content.Context
|
||||||
import android.database.sqlite.SQLiteDatabase
|
import android.database.sqlite.SQLiteDatabase
|
||||||
import android.database.sqlite.SQLiteOpenHelper
|
import android.database.sqlite.SQLiteOpenHelper
|
||||||
import android.provider.BaseColumns
|
import android.provider.BaseColumns
|
||||||
import android.util.Log
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
object ProductContract {
|
object ProductContract {
|
||||||
|
@ -54,7 +53,6 @@ const val SQL_CREATE_CATEGORIES_TABLE =
|
||||||
class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
|
class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
|
||||||
|
|
||||||
override fun onCreate(db: SQLiteDatabase) {
|
override fun onCreate(db: SQLiteDatabase) {
|
||||||
Log.d("QWERTYUIOP", SQL_CREATE_PRODUCT_TABLE)
|
|
||||||
db.execSQL(SQL_CREATE_PRODUCT_TABLE)
|
db.execSQL(SQL_CREATE_PRODUCT_TABLE)
|
||||||
db.execSQL(SQL_CREATE_SHELF_TABLE)
|
db.execSQL(SQL_CREATE_SHELF_TABLE)
|
||||||
db.execSQL(SQL_CREATE_CATEGORIES_TABLE)
|
db.execSQL(SQL_CREATE_CATEGORIES_TABLE)
|
||||||
|
@ -88,13 +86,11 @@ class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE
|
||||||
imageHash = productImageHash
|
imageHash = productImageHash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d("QWERTYUIOP", "Deleting image with hash: $imageHash and $id")
|
|
||||||
val picturesDir = File(context.filesDir, "pictures")
|
val picturesDir = File(context.filesDir, "pictures")
|
||||||
val thumbnailsDir = File(context.cacheDir, "thumbnails")
|
val thumbnailsDir = File(context.cacheDir, "thumbnails")
|
||||||
|
|
||||||
File(picturesDir, "$imageHash.png").delete()
|
File(picturesDir, "$imageHash.png").delete()
|
||||||
File(thumbnailsDir, "$imageHash.webp").delete()
|
File(thumbnailsDir, "$imageHash.webp").delete()
|
||||||
Log.d("QWERTYUIOP", BaseColumns._ID + "=" + id)
|
|
||||||
db.delete(ProductContract.ProductEntry.TABLE_NAME, BaseColumns._ID + "=" + id, null)
|
db.delete(ProductContract.ProductEntry.TABLE_NAME, BaseColumns._ID + "=" + id, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ import androidx.fragment.app.FragmentPagerAdapter
|
||||||
class ViewPagerAdapter
|
class ViewPagerAdapter
|
||||||
public constructor(supportFragmentManager: FragmentManager) : FragmentPagerAdapter(supportFragmentManager) {
|
public constructor(supportFragmentManager: FragmentManager) : FragmentPagerAdapter(supportFragmentManager) {
|
||||||
|
|
||||||
private final var fragmentList1: ArrayList<Fragment> = ArrayList()
|
private var fragmentList1: ArrayList<Fragment> = ArrayList()
|
||||||
private final var fragmentTitleList1: ArrayList<String> = ArrayList()
|
private var fragmentTitleList1: ArrayList<String> = ArrayList()
|
||||||
|
|
||||||
public override fun getItem(position: Int): Fragment {
|
override fun getItem(position: Int): Fragment {
|
||||||
return fragmentList1.get(position)
|
return fragmentList1.get(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,15 +80,12 @@ class AddProductActivity : AppCompatActivity() {
|
||||||
put(ProductContract.ProductEntry.CATEGORY, categorySpinner.selectedItemPosition)
|
put(ProductContract.ProductEntry.CATEGORY, categorySpinner.selectedItemPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("QWERTYUIOP", "SIP ${categorySpinner.selectedItemPosition}")
|
|
||||||
|
|
||||||
db.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
|
db.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
|
||||||
|
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
takePictureButton.setOnClickListener {
|
takePictureButton.setOnClickListener {
|
||||||
Log.d("QWERTYUIOP", "test")
|
|
||||||
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
|
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +151,6 @@ class AddProductActivity : AppCompatActivity() {
|
||||||
generateThumbnailForImage(this, imageHash)
|
generateThumbnailForImage(this, imageHash)
|
||||||
|
|
||||||
imageView.setImageURI(getImageUri(this, pictureFile))
|
imageView.setImageURI(getImageUri(this, pictureFile))
|
||||||
Log.i("QWERTYUIOP", "Picture saved")
|
|
||||||
} else {
|
} else {
|
||||||
Log.e("QWERTYUIOP", "Cannot save a picture")
|
Log.e("QWERTYUIOP", "Cannot save a picture")
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,7 @@ class FullscreenActivity : Activity() {
|
||||||
|
|
||||||
val picturesDir = File(filesDir, "pictures")
|
val picturesDir = File(filesDir, "pictures")
|
||||||
picturesDir.mkdirs()
|
picturesDir.mkdirs()
|
||||||
Log.d("QWERTYUIOP", imageHash.toString())
|
|
||||||
val fullscreenImageFile = File(picturesDir, "$imageHash.png")
|
val fullscreenImageFile = File(picturesDir, "$imageHash.png")
|
||||||
// crash. change activity
|
|
||||||
fullscreenImageView.setImageURI(getImageUri(this, fullscreenImageFile))
|
fullscreenImageView.setImageURI(getImageUri(this, fullscreenImageFile))
|
||||||
fullscreenImageView.setOnClickListener {
|
fullscreenImageView.setOnClickListener {
|
||||||
this.finish()
|
this.finish()
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.foxarmy.barcodescannerforemployees.fragments.StorageFragment
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
// private lateinit var appBarConfiguration: AppBarConfiguration
|
|
||||||
private lateinit var binding: ActivityMainBinding
|
private lateinit var binding: ActivityMainBinding
|
||||||
public lateinit var adapter: ViewPagerAdapter
|
public lateinit var adapter: ViewPagerAdapter
|
||||||
|
|
||||||
|
@ -29,10 +28,6 @@ class MainActivity : AppCompatActivity() {
|
||||||
setupViewPager(binding.tabViewpager)
|
setupViewPager(binding.tabViewpager)
|
||||||
binding.tabTablayout.setupWithViewPager(binding.tabViewpager)
|
binding.tabTablayout.setupWithViewPager(binding.tabViewpager)
|
||||||
|
|
||||||
// val navController = findNavController(R.id.nav_host_fragment_content_storage)
|
|
||||||
// appBarConfiguration = AppBarConfiguration(navController.graph)
|
|
||||||
// setupActionBarWithNavController(navController, appBarConfiguration)
|
|
||||||
|
|
||||||
binding.newElementFab.setOnClickListener { view ->
|
binding.newElementFab.setOnClickListener { view ->
|
||||||
val currentPosition = binding.tabTablayout.selectedTabPosition
|
val currentPosition = binding.tabTablayout.selectedTabPosition
|
||||||
val fragment = adapter.getItem(currentPosition)
|
val fragment = adapter.getItem(currentPosition)
|
||||||
|
@ -92,10 +87,4 @@ class MainActivity : AppCompatActivity() {
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun onSupportNavigateUp(): Boolean {
|
|
||||||
// val navController = findNavController(R.id.nav_host_fragment_content_storage)
|
|
||||||
// return navController.navigateUp(appBarConfiguration)
|
|
||||||
// || super.onSupportNavigateUp()
|
|
||||||
// }
|
|
||||||
}
|
}
|
|
@ -14,15 +14,10 @@ import org.foxarmy.barcodescannerforemployees.R
|
||||||
import org.foxarmy.barcodescannerforemployees.views.CategoryView
|
import org.foxarmy.barcodescannerforemployees.views.CategoryView
|
||||||
|
|
||||||
class CategoriesFragment : Fragment() {
|
class CategoriesFragment : Fragment() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return inflater.inflate(R.layout.fragment_categories, container, false)
|
return inflater.inflate(R.layout.fragment_categories, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,41 +52,6 @@ class CategoriesFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// public fun updateContent() {
|
|
||||||
//
|
|
||||||
// val grv = getView()?.findViewById<GridLayout>(R.id.contentGridLayout)
|
|
||||||
// grv?.removeAllViews()
|
|
||||||
//
|
|
||||||
// val db = DBStorageController(requireContext()).readableDatabase
|
|
||||||
// val projection = arrayOf(
|
|
||||||
// BaseColumns._ID,
|
|
||||||
// ProductContract.ProductEntry.PRODUCT_NAME,
|
|
||||||
// ProductContract.ProductEntry.PRODUCT_NET_WEIGHT,
|
|
||||||
// ProductContract.ProductEntry.IMAGE_FILENAME
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, null, null, null, null, null)
|
|
||||||
//
|
|
||||||
// with (cursor) {
|
|
||||||
// while(moveToNext()) {
|
|
||||||
// val productId = getInt(getColumnIndexOrThrow(BaseColumns._ID))
|
|
||||||
// val productName = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NAME))
|
|
||||||
// val netWeight = getDouble(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NET_WEIGHT))
|
|
||||||
// val productImageHash = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.IMAGE_FILENAME))
|
|
||||||
//
|
|
||||||
// val product = AbstractProduct(productId, productName, netWeight, productImageHash, 1)
|
|
||||||
//
|
|
||||||
// generateThumbnailForImage(context!!, productImageHash)
|
|
||||||
//
|
|
||||||
// val abstractProduct = AbstractProductView(
|
|
||||||
// requireActivity(),
|
|
||||||
// requireContext(),
|
|
||||||
// product
|
|
||||||
// )
|
|
||||||
// grv?.addView(abstractProduct)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
package org.foxarmy.barcodescannerforemployees
|
|
||||||
|
|
||||||
import android.provider.BaseColumns
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
@ -25,7 +24,7 @@ class AbstractProductView: LinearLayout {
|
||||||
private var netWeightField: TextView
|
private var netWeightField: TextView
|
||||||
private var categoryField: TextView
|
private var categoryField: TextView
|
||||||
private var unitField: TextView
|
private var unitField: TextView
|
||||||
public var product: AbstractProduct
|
var product: AbstractProduct
|
||||||
var isProductSelected = false
|
var isProductSelected = false
|
||||||
|
|
||||||
constructor(activity: Activity, context: Context, product: AbstractProduct) : super(context) {
|
constructor(activity: Activity, context: Context, product: AbstractProduct) : super(context) {
|
||||||
|
@ -67,8 +66,6 @@ class AbstractProductView: LinearLayout {
|
||||||
|
|
||||||
productLayout.setOnLongClickListener {
|
productLayout.setOnLongClickListener {
|
||||||
isProductSelected = !isProductSelected
|
isProductSelected = !isProductSelected
|
||||||
Log.d("QWERTYUIOP", "Changed to value $isProductSelected")
|
|
||||||
|
|
||||||
this.background = ContextCompat.getDrawable(context, if (isProductSelected) R.drawable.outline_selected else R.drawable.outline)
|
this.background = ContextCompat.getDrawable(context, if (isProductSelected) R.drawable.outline_selected else R.drawable.outline)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue