This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainViewModel: ViewModel() { | |
private var creditScore = mutableStateOf(0) | |
private var age = mutableStateOf(18) | |
val isEligible = derivedStateOf { | |
creditScore > 400 && age > 18 && age < 70 | |
} | |
fun creditScore(score: Int) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
val viewModel: MainViewModel by viewModels() | |
val isEligible by remember { | |
viewModel.isEligible | |
} | |
Column( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainViewModel: ViewModel() { | |
var creditScore = 0 | |
var age = 18 | |
fun isEligible() = creditScore > 400 && age > 18 && age < 70 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MemberListViewHolder(mContext: Context, itemView:View):RecyclerView.ViewHolder(itemView){ | |
lateinit var userPreference: Preference<LoginResponse> | |
init{ | |
super.itemView | |
ButterKnife.bind(this,itemView) | |
inject(context) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@InstallIn(ActivityComponent::class) | |
@EntryPoint | |
interface UserListViewHolderEntryPoint { | |
var loginPref: Preference<LoginResponse> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MemberListViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){ | |
@Inject | |
lateinit var userPreference: Preference<LoginResponse> | |
init{ | |
super.itemView | |
ButterKnife.bind(this,itemView) | |
SheroesApplication.getAppComponent(itemView.context).inject(this) | |
if(null!=userPreference&&userPreference.isSet&&null!=userPreference.get().userSummary){ | |
mUserId=userPreference.get().userSummary.userId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultConfig { | |
// this will prevent the excetion for InstallIn check on injected modules for time being | |
javaCompileOptions.annotationProcessorOptions.arguments['dagger.hilt.disableModulesHaveInstallInCheck'] = 'true' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@InstallIn(SingletonComponent.class) | |
@Module( | |
includes = { | |
SheroesAppModule.class, VMModule.class, UseCaseModule.class, | |
ApiModule.class, RepositoryModule.class, AnalyticModule.class | |
} | |
) | |
interface AppModuleComponent{} | |
@InstallIn(SingletonComponent.class) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SheroesApplication extends Application { | |
SheroesAppComponent mSheroesAppComponent; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
mSheroesAppComponent = DaggerSheroesAppComponent.builder() | |
.sheroesAppModule( | |
new SheroesAppModule(this, this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Component( | |
modules = { | |
SheroesAppModule.class, VMModule.class, UseCaseModule.class, | |
ApiModule.class, RepositoryModule.class, AnalyticModule.class | |
} | |
) | |
public interface SheroesAppComponent { | |
void inject(HomeActivity homeActivity); |