Skip to content

Commit 6cbf4f7

Browse files
committed
Add back MainActivity and AndroidManifest.xml for app module; add file structure, dependencies and don't do section to README
1 parent 34299e3 commit 6cbf4f7

File tree

6 files changed

+72
-39
lines changed

6 files changed

+72
-39
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
## App Module
2-
* Keep `AppContext` and `MainActivity`, but the package is unknown and will be change. (Lose git tracking)
1+
## File Structures
2+
* `/base` module:
3+
* Responsibility: define the base, common and utilities classes.
4+
* It can be updated by merging base repository, and will not affect the project modules.
5+
* `/app` module:
6+
* Responsibility: define all the features in your app.
7+
* Define `applicationId` as app package name.
8+
* Include all resources that app used. (including strings, colors, dimensions, drawables.)
9+
10+
## Dependencies
11+
* `/app` include `/base` serves as common library that the whole project used.
12+
13+
## Don't do
14+
Don't add anything to the module other than `/base`, since other modules will change the package to feature, and it will break the merge.
315

4-
## Base Module
5-
*

app/src/main/AndroidManifest.xml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- TODO: change the package name-->
3-
<manifest package="com.enginebai.project"
4-
xmlns:android="http://schemas.android.com/apk/res/android">
3+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="com.enginebai.project">
55

6-
<!-- TODO: uncomment and modify for your project-->
7-
<!-- <application-->
8-
<!-- android:allowBackup="true"-->
9-
<!-- android:icon="@mipmap/ic_launcher"-->
10-
<!-- android:label="@string/app_name"-->
11-
<!-- android:roundIcon="@mipmap/ic_launcher_round"-->
12-
<!-- android:supportsRtl="true"-->
13-
<!-- android:theme="@style/AppTheme"-->
14-
<!-- android:name=".AppContext">-->
15-
<!-- <activity android:name=".MainActivity">-->
16-
<!-- <intent-filter>-->
17-
<!-- <action android:name="android.intent.action.MAIN" />-->
6+
<!-- TODO: define your application name -->
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name=".MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
1817

19-
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
20-
<!-- </intent-filter>-->
21-
<!-- </activity>-->
22-
<!-- </application>-->
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
2322

2423
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.enginebai.project
2+
3+
import com.enginebai.base.view.BaseActivity
4+
5+
// TODO: rename the package for your project
6+
class MainActivity : BaseActivity() {
7+
override fun getLayoutId() = R.layout.activity_main
8+
9+
override fun handleErrorMessage(message: String) {
10+
TODO("Not yet implemented")
11+
}
12+
}

base/README.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

base/src/main/java/com/enginebai/base/view/BaseActivity.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,49 @@ package com.enginebai.base.view
33
import android.os.Bundle
44
import androidx.annotation.LayoutRes
55
import androidx.appcompat.app.AppCompatActivity
6+
import com.enginebai.base.utils.RxErrorHandler
7+
import io.reactivex.android.schedulers.AndroidSchedulers
68
import io.reactivex.disposables.CompositeDisposable
79
import io.reactivex.disposables.Disposable
10+
import org.koin.android.ext.android.inject
11+
import java.util.concurrent.TimeUnit
812

913
abstract class BaseActivity : AppCompatActivity() {
1014

1115
private val disposables = CompositeDisposable()
16+
private val rxErrorHandler: RxErrorHandler by inject()
17+
private var rxErrorDisposable: Disposable? = null
1218

1319
@LayoutRes
1420
abstract fun getLayoutId(): Int
1521

22+
abstract fun handleErrorMessage(message: String)
23+
1624
override fun onCreate(savedInstanceState: Bundle?) {
1725
super.onCreate(savedInstanceState)
1826
setContentView(getLayoutId())
1927
}
2028

21-
override fun onDestroy() {
29+
override fun onStart() {
30+
super.onStart()
31+
if (null == rxErrorDisposable || false == rxErrorDisposable?.isDisposed) {
32+
rxErrorDisposable = rxErrorHandler.errorMessageToDisplay
33+
.filter { it.isNotBlank() }
34+
.throttleFirst(2, TimeUnit.SECONDS)
35+
.observeOn(AndroidSchedulers.mainThread())
36+
.doOnNext { handleErrorMessage(it) }
37+
.subscribe()
38+
.disposeOnDestroy()
39+
}
40+
}
41+
42+
override fun onStop() {
43+
super.onStop()
44+
rxErrorDisposable?.dispose()
45+
}
46+
47+
48+
override fun onDestroy() {
2249
disposables.clear()
2350
super.onDestroy()
2451
}

0 commit comments

Comments
 (0)