Search in sources :

Example 6 with Status

use of com.tutuanle.chatapp.models.Status in project Chat-app by TuTuanLe.

the class StoryAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull StoryViewHolder holder, @SuppressLint("RecyclerView") int position) {
    UserStatus userStatus = userStatuses.get(position);
    Status lastStatus = userStatus.getStatuses().get(userStatus.getStatuses().size() - 1);
    Glide.with(context).load(lastStatus.getImageUrl()).into(holder.binding.image);
    Glide.with(context).load(lastStatus.getImageUrl()).into(holder.binding.imageUserStatus);
    holder.binding.circularStatusView.setPortionsCount(userStatus.getStatuses().size());
    if (selectedItem == position) {
        holder.binding.frameLayout.setBackgroundResource(R.drawable.button_bg);
    } else {
        holder.binding.frameLayout.setBackgroundColor(0);
    }
    holder.binding.frameLayout.setOnClickListener(v -> {
        int previousItem = selectedItem;
        selectedItem = position;
        notifyItemChanged(previousItem);
        notifyItemChanged(position);
    });
    holder.binding.circularStatusView.setOnClickListener(view -> {
        ArrayList<MyStory> myStories = new ArrayList<>();
        for (Status status : userStatus.getStatuses()) {
            myStories.add(new MyStory(status.getImageUrl()));
        }
        new StoryView.Builder(((MainScreenActivity) context).getSupportFragmentManager()).setStoriesList(// Required
        myStories).setStoryDuration(// Default is 2000 Millis (2 Seconds)
        5000).setTitleText(// Default is Hidden
        userStatus.getName()).setSubtitleText(// Default is Hidden
        "").setTitleLogoUrl(// Default is Hidden
        userStatus.getProfileImage()).setStoryClickListeners(new StoryClickListeners() {

            @Override
            public void onDescriptionClickListener(int position1) {
            // your action
            }

            @Override
            public void onTitleIconClickListener(int position1) {
            // your action
            }
        }).build().show();
    });
}
Also used : UserStatus(com.tutuanle.chatapp.models.UserStatus) Status(com.tutuanle.chatapp.models.Status) StoryClickListeners(omari.hamza.storyview.callback.StoryClickListeners) ArrayList(java.util.ArrayList) MyStory(omari.hamza.storyview.model.MyStory) UserStatus(com.tutuanle.chatapp.models.UserStatus) SuppressLint(android.annotation.SuppressLint)

Aggregations

Status (com.tutuanle.chatapp.models.Status)6 UserStatus (com.tutuanle.chatapp.models.UserStatus)6 ArrayList (java.util.ArrayList)4 SuppressLint (android.annotation.SuppressLint)2 FirebaseStorage (com.google.firebase.storage.FirebaseStorage)2 StorageReference (com.google.firebase.storage.StorageReference)2 TopStatusAdapter (com.tutuanle.chatapp.adapters.TopStatusAdapter)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 StoryClickListeners (omari.hamza.storyview.callback.StoryClickListeners)2 MyStory (omari.hamza.storyview.model.MyStory)2 ProgressDialog (android.app.ProgressDialog)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 MenuItem (android.view.MenuItem)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 OnSuccessListener (com.google.android.gms.tasks.OnSuccessListener)1 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)1 DataSnapshot (com.google.firebase.database.DataSnapshot)1