Convert 'MessageListFragment' to Kotlin

This commit is contained in:
cketti 2020-11-06 05:29:01 +01:00
parent 6d506151f3
commit b6ba133d12
5 changed files with 1507 additions and 1976 deletions

View file

@ -217,7 +217,7 @@ open class MessageList :
if (!hasMessageListFragment) {
val fragmentTransaction = fragmentManager.beginTransaction()
val messageListFragment = MessageListFragment.newInstance(
search, false, K9.isThreadedViewEnabled && !noThreading
search!!, false, K9.isThreadedViewEnabled && !noThreading
)
fragmentTransaction.add(R.id.message_list_container, messageListFragment)
fragmentTransaction.commit()

View file

@ -1,7 +1,10 @@
package com.fsck.k9.fragment
import android.content.Context
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import org.koin.dsl.module
val fragmentModule = module {
single { SortTypeToastProvider() }
factory { LocalBroadcastManager.getInstance(get<Context>()) }
}

View file

@ -71,12 +71,10 @@ public class MessageListHandler extends Handler {
sendMessage(msg);
}
public void restoreListPosition() {
public void restoreListPosition(Parcelable savedListState) {
MessageListFragment fragment = mFragment.get();
if (fragment != null) {
android.os.Message msg = android.os.Message.obtain(this, ACTION_RESTORE_LIST_POSITION,
fragment.savedListState);
fragment.savedListState = null;
android.os.Message msg = android.os.Message.obtain(this, ACTION_RESTORE_LIST_POSITION, savedListState);
sendMessage(msg);
}
}
@ -125,16 +123,17 @@ public class MessageListHandler extends Handler {
break;
}
case ACTION_GO_BACK: {
fragment.fragmentListener.goBack();
fragment.goBack();
break;
}
case ACTION_RESTORE_LIST_POSITION: {
fragment.listView.onRestoreInstanceState((Parcelable) msg.obj);
Parcelable savedListState = (Parcelable) msg.obj;
fragment.restoreListState(savedListState);
break;
}
case ACTION_OPEN_MESSAGE: {
MessageReference messageReference = (MessageReference) msg.obj;
fragment.fragmentListener.openMessage(messageReference);
fragment.openMessage(messageReference);
break;
}
}

View file

@ -1,8 +0,0 @@
package com.fsck.k9.ui.messagelist
import com.fsck.k9.fragment.MessageListFragment
import org.koin.androidx.viewmodel.ext.android.viewModel
class MessageListFragmentDiContainer(fragment: MessageListFragment) {
val viewModel: MessageListViewModel by fragment.viewModel()
}