-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HomePage Activities, Adapters, RecycleView
- Loading branch information
Showing
14 changed files
with
351 additions
and
15 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
app/src/main/java/org/myd/instagramclone/adapters/PostAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.myd.instagramclone.adapters | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import com.github.marlonlom.utilities.timeago.TimeAgo | ||
import com.google.firebase.firestore.ktx.firestore | ||
import com.google.firebase.firestore.toObject | ||
import com.google.firebase.ktx.Firebase | ||
import org.myd.instagramclone.R | ||
import org.myd.instagramclone.databinding.PostRvBinding | ||
import org.myd.instagramclone.models.Post | ||
import org.myd.instagramclone.models.User | ||
import org.myd.instagramclone.utils.USER_NODE | ||
|
||
|
||
class PostAdapter(var context : Context, private var postList : ArrayList<Post>) : RecyclerView.Adapter<PostAdapter.MyHolder>() { | ||
inner class MyHolder(var binding : PostRvBinding) : RecyclerView.ViewHolder(binding.root) | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyHolder { | ||
val binding = PostRvBinding.inflate(LayoutInflater.from(context), parent, false) | ||
return MyHolder(binding) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return postList.size | ||
} | ||
|
||
override fun onBindViewHolder(holder: MyHolder, position: Int) { | ||
Firebase.firestore.collection(USER_NODE).document(postList[position].uid).get().addOnSuccessListener { | ||
val user = it.toObject<User>() | ||
Glide.with(context).load(user!!.image).placeholder(R.drawable.user).into(holder.binding.profileImage) | ||
holder.binding.name.text = user.name | ||
} | ||
Glide.with(context).load(postList[position].postUrl).placeholder(R.drawable.loading).into(holder.binding.postImage) | ||
|
||
val text = TimeAgo.using(postList.get(position).time.toLong()) | ||
|
||
holder.binding.time.text = text | ||
holder.binding.caption.text = postList[position].caption | ||
holder.binding.like.setOnClickListener { | ||
holder.binding.like.setImageResource(R.drawable.red_like) | ||
} | ||
|
||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/org/myd/instagramclone/adapters/ReelAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.myd.instagramclone.adapters | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.squareup.picasso.Picasso | ||
import org.myd.instagramclone.R | ||
import org.myd.instagramclone.databinding.ReelDgBinding | ||
import org.myd.instagramclone.models.Reel | ||
|
||
class ReelAdapter(var context: Context, var reelList:ArrayList<Reel>) : RecyclerView.Adapter<ReelAdapter.ViewHolder>() { | ||
inner class ViewHolder(var binding: ReelDgBinding) : RecyclerView.ViewHolder(binding.root) | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
var binding = ReelDgBinding.inflate(LayoutInflater.from(context), parent, false) | ||
return ViewHolder(binding) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return reelList.size | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
Picasso.get().load(reelList[position].profileLink).placeholder(R.drawable.user).into(holder.binding.profileImage) | ||
holder.binding.caption.text = reelList[position].caption | ||
holder.binding.videoView.setVideoPath(reelList[position].reelUrl) | ||
holder.binding.videoView.setOnPreparedListener { | ||
holder.binding.progressBar.visibility = View.GONE | ||
holder.binding.videoView.start() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,94 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<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=".fragments.HomeFragment"> | ||
tools:context=".fragments.HomeFragment" > | ||
|
||
<!-- TODO: Update blank fragment layout --> | ||
<TextView | ||
<com.google.android.material.appbar.MaterialToolbar | ||
android:id="@+id/materialToolbar2" | ||
style="@style/Base.Theme.InstagramClone" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="This is the HomeFragment" /> | ||
android:layout_height="wrap_content" | ||
android:background="@color/white" | ||
android:minHeight="?attr/actionBarSize" | ||
android:theme="?attr/actionBarTheme" | ||
android:visibility="visible" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:title="Instagram" | ||
app:titleMarginStart="30dp" /> | ||
|
||
</FrameLayout> | ||
<androidx.core.widget.NestedScrollView | ||
android:id="@+id/nestedScrollView" | ||
android:layout_width="match_parent" | ||
android:layout_height="80dp" | ||
android:visibility="visible" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/materialToolbar2"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<de.hdodenhof.circleimageview.CircleImageView | ||
android:id="@+id/imageView3" | ||
android:layout_width="50dp" | ||
android:layout_height="50dp" | ||
android:src="@drawable/user" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_bias="0.3" /> | ||
|
||
<ImageView | ||
android:id="@+id/imageView4" | ||
android:layout_width="20dp" | ||
android:layout_height="20dp" | ||
android:contentDescription="@string/todo" | ||
android:src="@android:drawable/ic_menu_add" | ||
app:backgroundTint="#4788F6" | ||
app:layout_constraintBottom_toBottomOf="@+id/imageView3" | ||
app:layout_constraintEnd_toEndOf="@+id/imageView3" | ||
app:layout_constraintHorizontal_bias="0.25" | ||
app:layout_constraintStart_toEndOf="@+id/imageView3" | ||
app:layout_constraintTop_toBottomOf="@+id/imageView3" | ||
app:layout_constraintVertical_bias="0.14" /> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginStart="32dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/imageView3" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</androidx.core.widget.NestedScrollView> | ||
|
||
<View | ||
android:id="@+id/divider" | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:layout_marginTop="8dp" | ||
android:background="?android:attr/listDivider" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/nestedScrollView"/> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/post_rv" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_marginTop="8dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/divider" | ||
tools:listitem="@layout/post_rv" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.