Skip to content

Conversation

@ProgramminCat
Copy link
Contributor

No description provided.

@ProgramminCat ProgramminCat mentioned this pull request Nov 9, 2025
27 tasks
@ProgramminCat
Copy link
Contributor Author

@TheLastProject

Copy link
Member

@TheLastProject TheLastProject left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a decent start, but this can definitely be more Kotlin-y :)

Comment on lines +47 to +69
private var binding: MainActivityBinding? = null
private var contentMainBinding: ContentMainBinding? = null
private var mDatabase: SQLiteDatabase? = null
private var mAdapter: LoyaltyCardCursorAdapter? = null
private var mCurrentActionMode: ActionMode? = null
private var mSearchView: SearchView? = null
private var mLoyaltyCardCount = 0
@JvmField
var mFilter: String = ""
private var currentQuery = ""
private var finalQuery = ""
protected var mGroup: Any? = null
protected var mOrder: LoyaltyCardOrder? = LoyaltyCardOrder.Alpha
protected var mOrderDirection: LoyaltyCardOrderDirection? = LoyaltyCardOrderDirection.Ascending
protected var selectedTab: Int = 0
private var mCardList: RecyclerView? = null
private var mHelpSection: View? = null
private var mNoMatchingCardsText: View? = null
private var mNoGroupCardsText: View? = null
private var groupsTabLayout: TabLayout? = null
private var mUpdateLoyaltyCardListRunnable: Runnable? = null
private var mBarcodeScannerLauncher: ActivityResultLauncher<Intent?>? = null
private var mSettingsLauncher: ActivityResultLauncher<Intent?>? = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vast majority of these probably work better as lateinit, given they're only null because the value isn't known yet. See other activities.

I'm skipping reviewing all the !! calls now, because turning stuff into lateinit will change that flow too most likely.

Comment on lines +152 to +154
builder.setNegativeButton(
R.string.cancel,
DialogInterface.OnClickListener { dialog: DialogInterface?, which: Int -> dialog!!.dismiss() })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent in formatting and put the ending ) on its own line :)

@Override
public boolean onActionItemClicked(ActionMode inputMode, MenuItem inputItem) {
override fun onActionItemClicked(inputMode: ActionMode, inputItem: MenuItem): Boolean {
if (inputItem.getItemId() == R.id.action_share) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of if/else in Java due to Java limitations with these R.id things, but I think in Kotlin you might be able to just use a when switch?

long twentyFourHoursAgo = System.currentTimeMillis() - (1000 * 60 * 60 * 24);

File[] tempFiles = getCacheDir().listFiles();
Thread(Runnable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at

I don't think the Runnable is needed

Comment on lines +273 to +276
mHelpSection = contentMainBinding!!.helpSection
mNoMatchingCardsText = contentMainBinding!!.noMatchingCardsText
mNoGroupCardsText = contentMainBinding!!.noGroupCardsText
mCardList = contentMainBinding!!.list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just get rid of these variables, Kotlin is a lot smarter about types and directly calling the elements in the contentMainBinding will probably be fine in Kotlin and even more readable and save some code complexity.

updateLoyaltyCardList(true)

FloatingActionButton addButton = binding.fabAdd;
// End of active tab logic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure to keep the "end of tab logic" right below the tab logic instead of just above the add button logic (so: no newline before, but a newline after)

Comment on lines 361 to 363
val addButton = binding!!.fabAdd

addButton.setOnClickListener(v -> {
Intent intent = new Intent(getApplicationContext(), ScanActivity.class);
Bundle bundle = new Bundle();
addButton.setOnClickListener(View.OnClickListener { v: View? ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also just call binding.fabAdd directly here, should work fine in Kotlin :)

override fun onOptionsItemSelected(inputItem: MenuItem): Boolean {
val id = inputItem.getItemId()

if (id == android.R.id.home) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all these if id = can also just be a when statement in Kotlin :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants