Skip to content

Commit

Permalink
update: Setup Initial Research
Browse files Browse the repository at this point in the history
  • Loading branch information
amirisback committed Oct 23, 2022
1 parent 6035def commit 133fc4c
Show file tree
Hide file tree
Showing 15 changed files with 273 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
implementation "androidx.fragment:fragment-ktx:1.5.3"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"

implementation "com.google.android.material:material:1.6.1"
implementation "com.google.android.material:material:1.7.0"

testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".MainApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -13,7 +14,14 @@
android:theme="@style/Theme.Research"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".ui.DetailActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/com/frogobox/research/MainActivity.kt

This file was deleted.

42 changes: 42 additions & 0 deletions app/src/main/java/com/frogobox/research/MainApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.frogobox.research

import android.app.Application
import android.content.Context
import android.os.Build
import java.util.*

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

class MainApp : Application() {

companion object {
val TAG: String = MainApp::class.java.simpleName

lateinit var instance: MainApp

fun getContext(): Context = instance.applicationContext

fun getCurrentLocale(): Locale? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
instance.resources.configuration.locales[0]
} else {
instance.resources.configuration.locale
}
}

}

override fun onCreate() {
super.onCreate()
instance = this
}

}
17 changes: 17 additions & 0 deletions app/src/main/java/com/frogobox/research/core/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.frogobox.research.core

import androidx.appcompat.app.AppCompatActivity

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

abstract class BaseActivity : AppCompatActivity() {

}
30 changes: 30 additions & 0 deletions app/src/main/java/com/frogobox/research/core/BaseBindActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.frogobox.research.core

import android.os.Bundle
import androidx.viewbinding.ViewBinding

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

abstract class BaseBindActivity<VB: ViewBinding> : BaseActivity() {

protected val binding: VB by lazy { initBinding() }

abstract fun initBinding(): VB

open fun initView() {}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
initView()
}

}
50 changes: 50 additions & 0 deletions app/src/main/java/com/frogobox/research/core/BaseBindFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.frogobox.research.core

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

abstract class BaseBindFragment<VB : ViewBinding> : BaseFragment() {

companion object {
val TAG: String = BaseBindFragment::class.java.simpleName
}

private var _binding: VB? = null

protected val binding: VB get() = _binding!!

abstract fun setupViewBinding(inflater: LayoutInflater, container: ViewGroup?): VB

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = setupViewBinding(inflater, container)
if (savedInstanceState == null) {
Log.d(TAG,"View Binding : ${binding::class.java.simpleName}")
}
return binding.root
}

override fun onDestroy() {
super.onDestroy()
_binding = null
Log.d(TAG,"Destroying View Binding")
}

}
17 changes: 17 additions & 0 deletions app/src/main/java/com/frogobox/research/core/BaseFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.frogobox.research.core

import androidx.fragment.app.Fragment

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

abstract class BaseFragment : Fragment() {

}
18 changes: 18 additions & 0 deletions app/src/main/java/com/frogobox/research/ext/ContextExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.frogobox.research.ext

import android.content.Context
import android.widget.Toast

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

fun Context.showToast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
29 changes: 29 additions & 0 deletions app/src/main/java/com/frogobox/research/ui/DetailActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.frogobox.research.ui

import android.os.Bundle
import com.frogobox.research.core.BaseBindActivity
import com.frogobox.research.databinding.ActivityDetailBinding

class DetailActivity : BaseBindActivity<ActivityDetailBinding>() {

companion object {
private val TAG: String = DetailActivity::class.java.simpleName
}

override fun initBinding(): ActivityDetailBinding {
return ActivityDetailBinding.inflate(layoutInflater)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// TODO : Add your code here

}

override fun initView() {
binding.apply {

}
}

}
29 changes: 29 additions & 0 deletions app/src/main/java/com/frogobox/research/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.frogobox.research.ui

import android.os.Bundle
import com.frogobox.research.core.BaseBindActivity
import com.frogobox.research.databinding.ActivityMainBinding

class MainActivity : BaseBindActivity<ActivityMainBinding>() {

companion object {
private val TAG: String = MainActivity::class.java.simpleName
}

override fun initBinding(): ActivityMainBinding {
return ActivityMainBinding.inflate(layoutInflater)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// TODO : Add your code here

}

override fun initView() {
binding.apply {

}
}

}
19 changes: 19 additions & 0 deletions app/src/main/java/com/frogobox/research/util/Constant.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.frogobox.research.util

/**
* Created by Faisal Amir on 24/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

object Constant {

object Extra {
const val EXTRA_DATA = "EXTRA_DATA"
}

}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.DetailActivity">

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context=".ui.MainActivity">

<TextView
android:layout_width="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id "com.android.application" version '7.3.0' apply false
id "com.android.library" version '7.3.0' apply false
id "com.android.application" version '7.3.1' apply false
id "com.android.library" version '7.3.1' apply false
id "org.jetbrains.kotlin.android" version "1.7.0" apply false
}

Expand Down

0 comments on commit 133fc4c

Please sign in to comment.