Skip to content

Commit 07ec23f

Browse files
committed
Initial commit
0 parents  commit 07ec23f

File tree

75 files changed

+1876
-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.

75 files changed

+1876
-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/gradle.xml

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

.idea/jarRepositories.xml

+25
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.

.idea/vcs.xml

+6
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

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
}
5+
6+
android {
7+
compileSdkVersion 29
8+
buildToolsVersion "29.0.3"
9+
10+
defaultConfig {
11+
applicationId "com.srt.backstackproblem"
12+
minSdkVersion 21
13+
targetSdkVersion 29
14+
versionCode 1
15+
versionName "1.0"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_1_8
28+
targetCompatibility JavaVersion.VERSION_1_8
29+
}
30+
kotlinOptions {
31+
jvmTarget = '1.8'
32+
}
33+
}
34+
35+
dependencies {
36+
37+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
38+
implementation 'androidx.core:core-ktx:1.3.2'
39+
implementation 'androidx.appcompat:appcompat:1.2.0'
40+
implementation 'com.google.android.material:material:1.3.0'
41+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
42+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
43+
testImplementation 'junit:junit:4.13.2'
44+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
45+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
46+
implementation "androidx.navigation:navigation-fragment-ktx:2.3.4"
47+
implementation 'androidx.appcompat:appcompat:1.2.0'
48+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
49+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
50+
implementation 'com.google.android.material:material:1.4.0-alpha02'
51+
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
52+
testImplementation 'junit:junit:4.13.2'
53+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
54+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
55+
implementation 'androidx.fragment:fragment-ktx:1.3.2'
56+
implementation "androidx.core:core-ktx:1.3.2"
57+
implementation 'com.android.support:multidex:1.0.3'
58+
implementation 'androidx.multidex:multidex:2.0.1'
59+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31'
60+
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
61+
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
62+
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
63+
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
64+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
65+
}
66+
67+
apply plugin: 'kotlin-android-extensions'

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.srt.backstackproblem
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.srt.backstackproblem", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.srt.backstackproblem">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
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+
android:theme="@style/AppTheme">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
23+
</application>
24+
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.srt.backstackproblem
2+
3+
import android.os.Bundle
4+
import androidx.fragment.app.Fragment
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.view.ViewGroup
8+
import android.widget.TextView
9+
import androidx.recyclerview.widget.LinearLayoutManager
10+
import androidx.recyclerview.widget.RecyclerView
11+
import androidx.viewpager2.widget.ViewPager2
12+
import kotlinx.android.synthetic.main.fragment_home.view.*
13+
14+
class HomeFragment : Fragment() {
15+
16+
override fun onCreateView(
17+
inflater: LayoutInflater, container: ViewGroup?,
18+
savedInstanceState: Bundle?): View? {
19+
// Inflate the layout for this fragment
20+
val view = inflater.inflate(R.layout.fragment_home, container, false)
21+
22+
view?.go_to_chat_btn?.setOnClickListener {
23+
val viewPagerActivity = activity?.findViewById<ViewPager2>(R.id.view_pager_main_activity)
24+
viewPagerActivity?.currentItem = 1
25+
}
26+
27+
view?.go_to_profile_btn?.setOnClickListener {
28+
val containerId = (view.parent as ViewGroup).id
29+
activity?.supportFragmentManager?.beginTransaction()?.add(containerId, ProfileFragment())?.addToBackStack(null)?.commit()
30+
}
31+
32+
33+
//Fake work
34+
35+
val recyclerView = view?.findViewById(R.id.listRecyclerView) as RecyclerView
36+
val linearLayoutManager = LinearLayoutManager(requireContext())
37+
recyclerView.layoutManager = linearLayoutManager
38+
val data = ArrayList<Data>()
39+
40+
41+
for(num in 1..50) {
42+
data.add(Data(num))
43+
}
44+
45+
46+
val adapter = CustomAdapter(data)
47+
recyclerView.adapter = adapter
48+
49+
return view
50+
}
51+
52+
}
53+
54+
//Fake work
55+
56+
class CustomAdapter(private val dataList: ArrayList<Data>) : RecyclerView.Adapter<CustomAdapter.ViewHolder>() {
57+
58+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
59+
val v = LayoutInflater.from(parent.context).inflate(R.layout.an_item, parent, false)
60+
return ViewHolder(v)
61+
}
62+
63+
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
64+
holder.bindItems(dataList[position])
65+
}
66+
override fun getItemCount(): Int {
67+
return dataList.size
68+
}
69+
70+
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
71+
72+
fun bindItems(data: Data) {
73+
val textView = itemView.findViewById(R.id.theTextView) as TextView
74+
textView.text = data.number.toString()
75+
}
76+
}
77+
}
78+
79+
data class Data(val number: Int)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.srt.backstackproblem
2+
3+
import android.os.Bundle
4+
import androidx.fragment.app.Fragment
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.view.ViewGroup
8+
9+
class HomeFragmentContainer : Fragment() {
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
if(savedInstanceState == null) { // initial transaction should be wrapped like this
14+
childFragmentManager.beginTransaction()
15+
.replace(R.id.fragment_container_home_id, HomeFragment())
16+
.commitAllowingStateLoss()
17+
}
18+
}
19+
20+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
21+
savedInstanceState: Bundle?): View? {
22+
// Inflate the layout for this fragment
23+
val view = inflater.inflate(R.layout.fragment_home_container, container, false)
24+
25+
return view
26+
}
27+
28+
}

0 commit comments

Comments
 (0)