Search in sources :

Example 1 with StoryClickListeners

use of omari.hamza.storyview.callback.StoryClickListeners in project Chat-app by TuTuanLe.

the class TopStatusAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull TopStatusViewHolder holder, 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());
    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)

Example 2 with StoryClickListeners

use of omari.hamza.storyview.callback.StoryClickListeners 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)2 UserStatus (com.tutuanle.chatapp.models.UserStatus)2 ArrayList (java.util.ArrayList)2 StoryClickListeners (omari.hamza.storyview.callback.StoryClickListeners)2 MyStory (omari.hamza.storyview.model.MyStory)2 SuppressLint (android.annotation.SuppressLint)1