-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
201 additions
and
271 deletions.
There are no files selected for viewing
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
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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/haife/mcas/di/component/MainComponent.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.haife.mcas.di.component | ||
|
||
import com.haife.mcas.MainActivity | ||
import com.haife.mcas.di.module.MainModule | ||
import com.haife.mcas.mvp.ui.fragment.MainFragment | ||
import dagger.Component | ||
|
||
|
||
@Component(modules = [MainModule::class], dependencies = [AppComponent::class]) | ||
interface MainComponent { | ||
fun inject(fragment: MainActivity) | ||
fun inject(fragment: MainFragment) | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.haife.mcas.di.module | ||
|
||
import com.haife.mcas.di.scope.ActivityScope | ||
import com.haife.mcas.mvp.contract.MainContract | ||
import com.haife.mcas.mvp.model.MainModel | ||
import dagger.Module | ||
import dagger.Provides | ||
|
||
@Module | ||
//构建MainModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter | ||
class MainModule(private val view: MainContract.View) { | ||
@ActivityScope | ||
@Provides | ||
fun provideMainView(): MainContract.View { | ||
return this.view | ||
} | ||
|
||
@ActivityScope | ||
@Provides | ||
fun provideMainModel(model: MainModel): MainContract.Model { | ||
return model | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/haife/mcas/mvp/contract/MainContract.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.haife.mcas.mvp.contract | ||
|
||
import androidx.fragment.app.Fragment | ||
import com.haife.mcas.mvp.IModel | ||
import com.haife.mcas.mvp.IView | ||
|
||
interface MainContract { | ||
interface View : IView { | ||
|
||
fun getFragment(): Fragment | ||
|
||
} | ||
|
||
interface Model : IModel | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.haife.mcas.mvp.model | ||
|
||
import android.app.Application | ||
import com.google.gson.Gson | ||
import com.haife.mcas.di.scope.ActivityScope | ||
import com.haife.mcas.integration.IRepositoryManager | ||
import com.haife.mcas.mvp.BaseModel | ||
import com.haife.mcas.mvp.contract.MainContract | ||
import javax.inject.Inject | ||
|
||
@ActivityScope | ||
class MainModel | ||
@Inject | ||
constructor(repositoryManager: IRepositoryManager) : BaseModel(repositoryManager), MainContract.Model { | ||
@Inject | ||
lateinit var mGson: Gson | ||
|
||
@Inject | ||
lateinit var mApplication: Application | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/haife/mcas/mvp/presenter/MainPresenter.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.haife.mcas.mvp.presenter | ||
|
||
import android.app.Application | ||
import com.haife.mcas.di.scope.ActivityScope | ||
import com.haife.mcas.di.scope.FragmentScope | ||
import com.haife.mcas.http.imageloader.ImageLoader | ||
import com.haife.mcas.integration.AppManager | ||
import com.haife.mcas.mvp.BasePresenter | ||
import com.haife.mcas.mvp.contract.MainContract | ||
|
||
import me.jessyan.rxerrorhandler.core.RxErrorHandler | ||
import javax.inject.Inject | ||
|
||
|
||
@ActivityScope | ||
class MainPresenter | ||
@Inject | ||
constructor(model: MainContract.Model, rootView: MainContract.View) : | ||
BasePresenter<MainContract.Model, MainContract.View>(model, rootView) { | ||
@Inject | ||
lateinit var mErrorHandler: RxErrorHandler | ||
|
||
@Inject | ||
lateinit var mApplication: Application | ||
|
||
@Inject | ||
lateinit var mImageLoader: ImageLoader | ||
|
||
@Inject | ||
lateinit var mAppManager: AppManager | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/haife/mcas/mvp/ui/fragment/MainFragment.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.haife.mcas.mvp.ui.fragment | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.haife.mcas.R | ||
import com.haife.mcas.base.BaseSupportFragment | ||
import com.haife.mcas.di.component.AppComponent | ||
import com.haife.mcas.di.module.MainModule | ||
import com.haife.mcas.mvp.contract.MainContract | ||
import com.haife.mcas.mvp.presenter.MainPresenter | ||
|
||
|
||
class MainFragment : BaseSupportFragment<MainPresenter>(), MainContract.View { | ||
companion object { | ||
fun newInstance(): MainFragment { | ||
val fragment = MainFragment() | ||
return fragment | ||
} | ||
} | ||
|
||
override fun setupFragmentComponent(appComponent: AppComponent) { | ||
|
||
} | ||
|
||
override fun initView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
return inflater.inflate(R.layout.fragment_main, container, false) | ||
} | ||
|
||
/** | ||
* 在 onActivityCreate()时调用 | ||
*/ | ||
override fun initData(savedInstanceState: Bundle?) { | ||
initListener() | ||
} | ||
|
||
private fun initListener() { | ||
|
||
} | ||
|
||
override fun getFragment(): Fragment = this | ||
override fun showMessage(message: String) { | ||
|
||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
</LinearLayout> |
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
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
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
Oops, something went wrong.