Skip to content

Commit 1eaa3a0

Browse files
committed
Initial commit
0 parents  commit 1eaa3a0

File tree

158 files changed

+4692
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+4692
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetDropDown.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/migrations.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle.kts

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
plugins {
2+
id("com.android.application")
3+
id("org.jetbrains.kotlin.android")
4+
id("androidx.navigation.safeargs")
5+
}
6+
7+
android {
8+
namespace = "com.aytachuseynli.energyappui"
9+
compileSdk = 34
10+
11+
buildFeatures{
12+
viewBinding = true
13+
}
14+
15+
defaultConfig {
16+
applicationId = "com.aytachuseynli.energyappui"
17+
minSdk = 26
18+
targetSdk = 34
19+
versionCode = 1
20+
versionName = "1.0"
21+
22+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
23+
}
24+
25+
buildTypes {
26+
release {
27+
isMinifyEnabled = false
28+
proguardFiles(
29+
getDefaultProguardFile("proguard-android-optimize.txt"),
30+
"proguard-rules.pro"
31+
)
32+
}
33+
}
34+
compileOptions {
35+
sourceCompatibility = JavaVersion.VERSION_1_8
36+
targetCompatibility = JavaVersion.VERSION_1_8
37+
}
38+
kotlinOptions {
39+
jvmTarget = "1.8"
40+
}
41+
}
42+
43+
dependencies {
44+
45+
implementation("androidx.core:core-ktx:1.12.0")
46+
implementation("androidx.appcompat:appcompat:1.6.1")
47+
implementation("com.google.android.material:material:1.11.0")
48+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
49+
implementation("androidx.navigation:navigation-fragment-ktx:2.7.6")
50+
implementation("androidx.navigation:navigation-ui-ktx:2.7.6")
51+
testImplementation("junit:junit:4.13.2")
52+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
53+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
54+
55+
implementation("androidx.cardview:cardview:1.0.0")
56+
57+
implementation ("androidx.recyclerview:recyclerview:1.3.2")
58+
59+
implementation("androidx.viewpager2:viewpager2:1.0.0")
60+
61+
implementation("androidx.palette:palette:1.0.0")
62+
63+
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
64+
implementation("androidx.paging:paging-runtime-ktx:3.2.1")
65+
66+
implementation ("com.github.bumptech.glide:glide:4.16.0")
67+
68+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.aytachuseynli.energyappui
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.aytachuseynli.energyappui", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
7+
8+
<application
9+
android:allowBackup="true"
10+
android:dataExtractionRules="@xml/data_extraction_rules"
11+
android:fullBackupContent="@xml/backup_rules"
12+
android:icon="@mipmap/ic_launcher"
13+
android:label="@string/app_name"
14+
android:roundIcon="@mipmap/ic_launcher_round"
15+
android:supportsRtl="true"
16+
android:theme="@style/Theme.EnergyAppUi"
17+
tools:targetApi="31">
18+
<activity
19+
android:name=".MainActivity"
20+
android:exported="true">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.aytachuseynli.energyappui
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import androidx.navigation.fragment.NavHostFragment
6+
import androidx.navigation.ui.NavigationUI
7+
import com.aytachuseynli.energyappui.common.utils.Extensions.goneEach
8+
import com.aytachuseynli.energyappui.common.utils.Extensions.visible
9+
import com.aytachuseynli.energyappui.common.utils.Extensions.visibleEach
10+
import com.aytachuseynli.energyappui.databinding.ActivityMainBinding
11+
12+
class MainActivity : AppCompatActivity() {
13+
private lateinit var binding: ActivityMainBinding
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
binding=ActivityMainBinding.inflate(layoutInflater)
17+
setContentView(binding.root)
18+
19+
val navHostFragment =
20+
supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
21+
val navController = navHostFragment.navController
22+
NavigationUI.setupWithNavController(binding.bottomMenu, navController)
23+
24+
binding.bottomMenu.menu
25+
binding.bottomMenu.setOnItemSelectedListener {
26+
NavigationUI.onNavDestinationSelected(it,navController)
27+
true
28+
}
29+
navController.addOnDestinationChangedListener { _, destination, _ ->
30+
with(binding){
31+
when (destination.id) {
32+
R.id.fragmentProfile->{
33+
listOf(homeHeader,bottomMenu).goneEach()
34+
profileHeader.visible()
35+
}
36+
R.id.homePageFragment->{
37+
listOf(homeHeader,bottomMenu,welcome,mainPageText).visibleEach()
38+
listOf(profileHeader,serviceTxt).goneEach()
39+
}
40+
R.id.servicesPageFragment->{
41+
listOf(homeHeader,bottomMenu,serviceTxt).visibleEach()
42+
listOf(profileHeader,welcome,mainPageText).goneEach()
43+
serviceTxt.text=resources.getString(R.string.services)
44+
}
45+
R.id.morePageFragment->{
46+
listOf(homeHeader,bottomMenu,serviceTxt).visibleEach()
47+
listOf(profileHeader,welcome,mainPageText).goneEach()
48+
serviceTxt.text=resources.getString(R.string.questions)
49+
}
50+
R.id.toFaq->{
51+
52+
listOf(homeHeader,bottomMenu,serviceTxt).visibleEach()
53+
listOf(profileHeader,welcome,mainPageText).goneEach()
54+
serviceTxt.text=resources.getString(R.string.more)
55+
}
56+
R.id.payingsPageFragment->{
57+
listOf(homeHeader,bottomMenu,serviceTxt).visibleEach()
58+
listOf(profileHeader,welcome,mainPageText).goneEach()
59+
serviceTxt.text=resources.getString(R.string.payments)
60+
}
61+
R.id.analysisPageFragment->{
62+
listOf(homeHeader,bottomMenu,serviceTxt).visibleEach()
63+
listOf(profileHeader,welcome,mainPageText).goneEach()
64+
serviceTxt.text=resources.getString(R.string.analys_view)
65+
}
66+
R.id.safetyFragment->{
67+
listOf(homeHeader,serviceTxt).visibleEach()
68+
listOf(profileHeader,bottomMenu,welcome,mainPageText).goneEach()
69+
serviceTxt.text=resources.getString(R.string.safety_rules)
70+
}
71+
R.id.setLimitFragment->{
72+
listOf(homeHeader,bottomMenu).goneEach()
73+
}
74+
else -> { binding.bottomMenu.visible()}
75+
}
76+
}
77+
}
78+
binding.profileIc.setOnClickListener {
79+
navController.navigate(R.id.fragmentProfile)
80+
}
81+
binding.btnBack.setOnClickListener{
82+
navController.popBackStack()
83+
}
84+
}
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.aytachuseynli.energyappui.common
2+
3+
import androidx.recyclerview.widget.DiffUtil
4+
5+
class GenericDiffUtil<T>(private val myItemsTheSame: (oldItem: T, newItem: T) -> Boolean,
6+
private val myContentsTheSame: (oldItem: T, newItem: T) -> Boolean) : DiffUtil.ItemCallback<T>() {
7+
override fun areItemsTheSame(oldItem: T & Any, newItem: T & Any): Boolean {
8+
return myItemsTheSame(oldItem, newItem)
9+
}
10+
11+
override fun areContentsTheSame(oldItem: T & Any, newItem: T & Any): Boolean {
12+
return myContentsTheSame(oldItem, newItem)
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.aytachuseynli.energyappui.common.base
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.fragment.app.Fragment
8+
import androidx.viewbinding.ViewBinding
9+
10+
abstract class BaseFragment<VB : ViewBinding>(
11+
private val bindingInflater: (inflater: LayoutInflater) -> VB,
12+
) : Fragment() {
13+
14+
private var _binding: VB? = null
15+
val binding: VB get() = _binding as VB
16+
17+
protected abstract fun observeEvents()
18+
protected abstract fun onCreateFinish()
19+
protected open fun setupListeners() = Unit
20+
21+
22+
override fun onCreateView(
23+
inflater: LayoutInflater,
24+
container: ViewGroup?,
25+
savedInstanceState: Bundle?,
26+
): View? {
27+
_binding = bindingInflater.invoke(layoutInflater)
28+
29+
return binding.root
30+
}
31+
32+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
33+
super.onViewCreated(view, savedInstanceState)
34+
onCreateFinish()
35+
observeEvents()
36+
setupListeners()
37+
}
38+
39+
override fun onDestroyView() {
40+
super.onDestroyView()
41+
_binding = null
42+
}
43+
44+
}

0 commit comments

Comments
 (0)