Skip to content

Commit 591d28d

Browse files
author
elgroup
committed
latest commit cotains complete flow
1 parent 88ba09c commit 591d28d

File tree

8 files changed

+156
-20
lines changed

8 files changed

+156
-20
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ dependencies {
3434
androidTestImplementation 'androidx.test:runner:1.2.0'
3535
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
3636

37+
//recyler view
38+
implementation 'androidx.recyclerview:recyclerview:1.0.0'
3739
//support design
3840
implementation 'com.google.android.material:material:1.0.0-rc01'
3941

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package app.com.getin.Callbacks
2+
3+
interface CallBack {
4+
fun ItemClicked(pos:Int)
5+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.example.backstack_bottomnavigation.adapters
2+
3+
import android.content.Context
4+
import android.graphics.drawable.Drawable
5+
6+
import android.view.LayoutInflater
7+
import android.view.View
8+
import android.view.ViewGroup
9+
import android.widget.ImageView
10+
import android.widget.RadioButton
11+
import android.widget.TextView
12+
import androidx.recyclerview.widget.RecyclerView
13+
import app.com.getin.Callbacks.CallBack
14+
import com.example.backstack_bottomnavigation.R
15+
16+
class Adapter(var ctx:Context, var array:ArrayList<String>, var callBack: CallBack): RecyclerView.Adapter<Adapter.ViewHolderItem>(){
17+
override fun getItemCount(): Int {
18+
return array.size;
19+
}
20+
21+
override fun onBindViewHolder(item : ViewHolderItem, pos: Int) {
22+
item.itemView.setOnClickListener {
23+
callBack.ItemClicked(pos)
24+
}
25+
item.user_name_text.setText(array.get(pos))
26+
/* Glide.with(ctx)
27+
.load(Constants.baseurl +array.get(pos)?.qrcode_url)
28+
.apply(RequestOptions()
29+
.diskCacheStrategy( DiskCacheStrategy.ALL )
30+
.placeholder(R.color.white)).listener(object : RequestListener<Drawable> {
31+
override fun onLoadFailed(e: GlideException?, model: Any, target: Target<Drawable>, isFirstResource: Boolean): Boolean {
32+
// profile_image_loading_progress.setVisibility(View.GONE)
33+
return false
34+
}
35+
36+
override fun onResourceReady(resource: Drawable, model: Any, target: Target<Drawable>, dataSource: DataSource, isFirstResource: Boolean): Boolean {
37+
38+
// profile_image_loading_progress.setVisibility(View.GONE)
39+
return false
40+
}
41+
})
42+
.into(item.qr_code_imgv)
43+
44+
*/
45+
46+
}
47+
48+
override fun onCreateViewHolder(parent: ViewGroup, p1: Int): ViewHolderItem {
49+
val viewHolder = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view, null, false)
50+
viewHolder.setLayoutParams(RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT))
51+
return ViewHolderItem(viewHolder)
52+
}
53+
54+
55+
class ViewHolderItem(itemLayoutView: View) : RecyclerView.ViewHolder(itemLayoutView) {
56+
57+
var user_image:ImageView
58+
var user_name_text:TextView
59+
init {
60+
61+
user_image=itemLayoutView.findViewById(R.id.user_image)
62+
user_name_text=itemLayoutView.findViewById(R.id.user_name_text)
63+
}
64+
}
65+
}

app/src/main/java/com/example/backstack_bottomnavigation/fragments/MidFragment.kt

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ import androidx.fragment.app.Fragment
66
import android.view.LayoutInflater
77
import android.view.View
88
import android.view.ViewGroup
9+
import android.widget.LinearLayout
910
import android.widget.TextView
1011
import androidx.fragment.app.FragmentManager
12+
import androidx.recyclerview.widget.LinearLayoutManager
13+
import androidx.recyclerview.widget.RecyclerView
14+
import app.com.getin.Callbacks.CallBack
1115
import com.example.backstack_bottomnavigation.R
16+
import com.example.backstack_bottomnavigation.adapters.Adapter
1217

1318

1419
// TODO: Rename parameter arguments, choose names that match
@@ -20,9 +25,16 @@ private const val ARG_PARAM2 = "param2"
2025
* A simple [Fragment] subclass.
2126
*
2227
*/
23-
class MidFragment : Fragment() {
24-
lateinit var detail:TextView
28+
class MidFragment : Fragment(), CallBack {
29+
override fun ItemClicked(pos: Int) {
30+
childFragmentManager.beginTransaction().add(R.id.mid_container,DetailFragment()).addToBackStack(null).commit()
31+
}
32+
2533
lateinit var mrootview:View
34+
lateinit var recyler_view:RecyclerView
35+
lateinit var linearLayoutManager:LinearLayoutManager
36+
lateinit var adapter:Adapter
37+
lateinit var arrayList:ArrayList<String>
2638
override fun onCreateView(
2739
inflater: LayoutInflater, container: ViewGroup?,
2840
savedInstanceState: Bundle?
@@ -35,15 +47,14 @@ lateinit var detail:TextView
3547
}
3648

3749
private fun init() {
50+
arrayList=ArrayList<String>()
51+
arrayList.addAll(resources.getStringArray(R.array.hero_names))
52+
recyler_view=mrootview.findViewById(R.id.recyler_view)
53+
linearLayoutManager= LinearLayoutManager(this.activity, RecyclerView.VERTICAL,false)
54+
recyler_view.layoutManager=linearLayoutManager
55+
adapter= Adapter(activity!!,arrayList,this)
56+
recyler_view.adapter=adapter
3857

39-
detail= mrootview.findViewById(R.id.detail)
40-
detail.setOnClickListener {
41-
detail()
42-
}
43-
}
44-
45-
fun detail(){
46-
childFragmentManager.beginTransaction().add(R.id.mid_container,DetailFragment()).addToBackStack(null).commit()
4758
}
4859

4960
fun getchildFragmentManager(): FragmentManager {
64.9 KB
Loading

app/src/main/res/layout/fragment_mid.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@
99
android:orientation="vertical"
1010
android:gravity="center"
1111
android:layout_width="match_parent" android:layout_height="match_parent">
12-
<TextView
13-
android:id="@+id/detail"
14-
android:layout_marginTop="20dp"
15-
android:layout_width="wrap_content"
16-
android:gravity="center"
17-
android:background="@drawable/background_layout"
18-
android:textColor="@color/orange"
19-
android:textSize="20dp"
20-
android:layout_height="wrap_content"
21-
android:text="@string/my_profile"/>
12+
13+
<androidx.recyclerview.widget.RecyclerView
14+
android:id="@+id/recyler_view"
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"></androidx.recyclerview.widget.RecyclerView>
17+
2218
</LinearLayout>
2319
<!-- TODO: Update blank fragment layout -->
2420
<FrameLayout
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="wrap_content"
7+
android:background="@android:color/background_light"
8+
tools:layout_editor_absoluteY="81dp">
9+
10+
11+
<ImageView
12+
android:id="@+id/user_image"
13+
android:layout_width="69dp"
14+
android:layout_height="69dp"
15+
android:layout_marginStart="8dp"
16+
android:layout_marginTop="8dp"
17+
android:layout_marginLeft="8dp"
18+
android:layout_marginBottom="8dp"
19+
android:src="@drawable/ic_deadpool"
20+
app:layout_constraintBottom_toBottomOf="parent"
21+
app:layout_constraintStart_toStartOf="parent"
22+
app:layout_constraintTop_toTopOf="parent"
23+
/>
24+
25+
26+
<TextView
27+
android:id="@+id/user_name_text"
28+
android:layout_width="228dp"
29+
android:layout_height="28dp"
30+
android:layout_marginStart="8dp"
31+
android:layout_marginTop="8dp"
32+
android:text=""
33+
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
34+
android:textSize="22sp"
35+
36+
app:layout_constraintStart_toEndOf="@+id/user_image"
37+
app:layout_constraintTop_toTopOf="parent"
38+
tools:text="@tools:sample/full_names"
39+
android:layout_marginLeft="8dp" />
40+
41+
42+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,19 @@
1313
<string name="mid_fragment">Mid fragment</string>
1414
<string name="Profile_fragment">Its me Aryan</string>
1515
<string name="my_profile">More about me</string>
16+
<string-array name="hero_names">
17+
<item>Iron man</item>
18+
<item>Thor</item>
19+
<item>Caption America</item>
20+
<item>Hulk</item>
21+
<item>Deadpool</item>
22+
<item>Black widow</item>
23+
<item>Scarlett witch</item>
24+
<item>Vision</item>
25+
<item>Hawk eye</item>
26+
<item>Star lord</item>
27+
<item>Gamora</item>
28+
<item>Rocket</item>
29+
<item>Gamora</item>
30+
</string-array>
1631
</resources>

0 commit comments

Comments
 (0)