-
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.
feat: add followers and following list
- Loading branch information
1 parent
277f140
commit 271d471
Showing
17 changed files
with
389 additions
and
90 deletions.
There are no files selected for viewing
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,11 @@ | ||
## Setting Up API Key and Base URL | ||
To ensure seamless integration with the APIs, please follow these steps: | ||
|
||
1. Open the project in Android Studio. | ||
2. Locate the `local.properties` file in the root directory of the project. | ||
3. Add the following lines to the `local.properties` file: | ||
|
||
```properties | ||
API_KEY=your_api_key_here | ||
BASE_URL=your_base_url_here | ||
``` |
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
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
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/aurelioklv/githubuser/ui/details/SectionsPagerAdapter.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,23 @@ | ||
package com.aurelioklv.githubuser.ui.details | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
import com.aurelioklv.githubuser.ui.details.follow.FollowFragment | ||
|
||
class SectionsPagerAdapter(activity: AppCompatActivity, private val username: String) : | ||
FragmentStateAdapter(activity) { | ||
override fun getItemCount(): Int { | ||
return 2 | ||
} | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
val fragment = FollowFragment() | ||
fragment.arguments = Bundle().apply { | ||
putInt(FollowFragment.ARG_SECTION_NUMBER, position + 1) | ||
putString(FollowFragment.ARG_USERNAME, username) | ||
} | ||
return fragment | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/aurelioklv/githubuser/ui/details/follow/FollowAdapter.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,60 @@ | ||
package com.aurelioklv.githubuser.ui.details.follow | ||
|
||
import android.content.Intent | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.aurelioklv.githubuser.data.response.FollowerFollowingItem | ||
import com.aurelioklv.githubuser.databinding.UserSearchItemBinding | ||
import com.aurelioklv.githubuser.ui.details.DetailsActivity | ||
import com.bumptech.glide.Glide | ||
|
||
class FollowAdapter : | ||
ListAdapter<FollowerFollowingItem, FollowAdapter.MyViewHolder>(DIFF_CALLBACK) { | ||
class MyViewHolder(private val binding: UserSearchItemBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun bind(item: FollowerFollowingItem) { | ||
Glide.with(itemView.context) | ||
.load(item.avatarUrl) | ||
.into(binding.ivUserAvatar) | ||
binding.tvUsername.text = item.login | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { | ||
val binding = | ||
UserSearchItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return MyViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: MyViewHolder, position: Int) { | ||
val userSearchItem = getItem(position) | ||
holder.bind(userSearchItem) | ||
|
||
holder.itemView.setOnClickListener { | ||
val intent = Intent(holder.itemView.context, DetailsActivity::class.java) | ||
intent.putExtra(DetailsActivity.EXTRA_USERNAME, userSearchItem.login) | ||
holder.itemView.context.startActivity(intent) | ||
} | ||
} | ||
|
||
companion object { | ||
val DIFF_CALLBACK = object : DiffUtil.ItemCallback<FollowerFollowingItem>() { | ||
override fun areItemsTheSame( | ||
oldItem: FollowerFollowingItem, | ||
newItem: FollowerFollowingItem, | ||
): Boolean { | ||
return oldItem == newItem | ||
} | ||
|
||
override fun areContentsTheSame( | ||
oldItem: FollowerFollowingItem, | ||
newItem: FollowerFollowingItem, | ||
): Boolean { | ||
return oldItem == newItem | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.