MiStoryView is a simple configurable library to integrate stories features into your social media android application.

Overview

MiStoryView

MiStoryView is a simple configurable library to integrate stories features into your social media android application.

Preview

image

Key features

  • Set a list of image URLs in MiStoryView.
  • Customize duration for the particular story (in milliseconds).
  • Set any of the predefined animations, while swiping between multiple stories.
  • Move to the back and forth story by tapping on the right and left parts of an image.
  • Hold story by just simply touch on it.
  • Move to the whole next story or exit full story view, if a user is at the last item of the story.
  • Move to the whole previous story or exit the full story view, if a user is at the first item of the story.
  • Story indicator color changes once it is seen.

Usage

Dependencies

  • Step 1: Add the JitPack repository in your project build.gradle file
allprojects {
	    repositories {
		    ...
		    maven { url 'https://jitpack.io' }
	    }
    }

or

If Android studio version is Arctic Fox or upper then add it in your settings.gradle:

 dependencyResolutionManagement {
    		repositories {
        		...
        		maven { url 'https://jitpack.io' }
    		}
	   }
  • Step 2: Add the dependency in your app module build.gradle file
dependencies {
		    ...
	        implementation 'com.github.Mindinventory:MIStoryView:0.0.1'
	}

Implementation

  • Step 1 : Provide a list of stories. (Note : Use MiUserStoryModel class only to provide list of stories)

      class MainViewModel : ViewModel() {
              val mListOfUsers: ArrayList<MiUserStoryModel> = ArrayList()
    
              init {
                      mListOfUsers.add(MiUserStoryModel("1", "Johny Curtis", ArrayList()).also {
                              it.userStoryList.add(
                                      MiStoryModel(
                                      "https://i.picsum.photos/id/0/5616/3744.jpg?hmac=3GAAioiQziMGEtLbfrdbcoenXoWAW-zlyEAMkfEdBzQ",
                                      "Johny Depp",
                                      "10:08 PM"
                                      )
                              )
                              it.userStoryList.add(
                                      MiStoryModel(
                                      "https://i.picsum.photos/id/1/5616/3744.jpg?hmac=kKHwwU8s46oNettHKwJ24qOlIAsWN9d2TtsXDoCWWsQ",
                                      "Johny Depp",
                                      "07:50 AM"
                                      )
                              )
                      })
              }
    
              fun updateListOfUser(mListOfUsers: ArrayList<MiUserStoryModel>) {
                      this.mListOfUsers.clear()
                      this.mListOfUsers.addAll(mListOfUsers)
              }        
              
      }
    
  • Step 2 : Inflate recyclerview in your layout file.

      <androidx.recyclerview.widget.RecyclerView
              android:id="@+id/rvStory"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:clipToPadding="false"
              android:orientation="vertical"
              android:padding="@dimen/dp_8"
              app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              tools:listitem="@layout/item_user_story" />
    
  • Step 3 : Create a recyclerview row item, which consists MiStoryView class.

      // See row item of sample app.
    
  • Step 4 : Create an adapter object and a resultAPI launcher to launch story detail view from your activity.

      class MainActivity : AppCompatActivity() {
              // This is necessary snippet to listen the changes of seen stories data,
              // when user come back to the origin activity.
    
              private val launcher =
                      registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
                      try {
                              if (it.resultCode == Activity.RESULT_OK) {
                                      val list = arrayListOf<MiUserStoryModel>()
    
                                      it.data?.hasExtra(MiStoryDisplayActivity.MI_LIST_OF_STORY)
                                      ?.let { hasMiStoryList ->
                                           if (hasMiStoryList) {
                                              it.data?.getParcelableArrayListExtra<MiUserStoryModel>(
                                              MiStoryDisplayActivity.MI_LIST_OF_STORY
                                              )?.let { listOfUserStories ->
                                                      list.addAll(listOfUserStories)
                                              }
                                           }
                                      }
    
                                      if (!mViewModel.mListOfUsers.containsAll(list)) {
                                           storyAdapter.setUserStoryData(list)
                                           mViewModel.updateListOfUser(list)
                                      }
                              }
                      } catch (e: Exception) {
                              e.printStackTrace()
                      }
              }
    
              // onCreateView here and invoke initView() method in it.
    
              private fun initView() {
                      // Initialize your adapter here.
                      // Provide launcher and list of stories from viewmodel for example
                      // in constructor of that adapter.
    
                      with(mBinding.rvStory) {
                          ...
                          storyAdapter = StoryAdapter(mViewModel.mListOfUsers, { launcher }, { this@MainActivity })
                          adapter = storyAdapter
                      }
              }
      }
    
  • Step 5 : Create a recyclerview adapter. Must implement touch event of root view and dispatch that event to MiStoryView to launch Story detail view.

      class StoryAdapter(
              private val launcher: ActivityResultLauncher<Intent>,
              private val launcherCallBack: () -> ActivityResultLauncher<Intent>,
              private val activityCallBack: () -> AppCompatActivity
      ) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
              override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
                      // inflate your row item layout here
              }
    
              @SuppressLint("ClickableViewAccessibility")
              override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
                      if (holder is StoryViewHolder) {
                              holder.mBinding.apply {
                                      // Dispatch touch event of root view
                                      // to MiStoryView to open full screen
                                      // story preview view.
                                      root.setOnTouchListener { view, motionEvent ->
                                              msvStory.dispatchTouchEvent(motionEvent)
                                              true
                                      }
    
                                      msvStory.apply {
                                              setActivity(activityCallBack.invoke())
                                              setLauncher(launcherCallBack.invoke())
                                              if (listOfUseStory.isNotEmpty()) {
                                                      setImageUrls(listOfUseStory, holder.adapterPosition)
                                              }
                                      }
                                      tvUserName.text = mDataList[holder.adapterPosition].userName
                              }
                      }
              }
    
              // Other override methods here
              // Define viewholder class here
              
              fun setUserStoryData(mDataList: ArrayList<MiUserStoryModel>) {
                  this.listOfUseStory.clear()
                  this.listOfUseStory = mDataList
                  notifyDataSetChanged()
              }
      }
    

XML Properties

Properties Description
miPageTransformer Set different animation while switching between stories
miPendingIndicatorColor Set color for unseen story
miStoryImageRadius Set size of round image
miStoryItemIndicatorWidth Set width of progress indicator
miSpaceBetweenImageAndIndicator Set margin between two progress bar indicator
miVisitedIndicatorColor Set color for seen story
miFullScreenProgressBarHeight Set height of progress in full story view
miFullScreenGapBetweenProgressBar Set margin between two progress bar indicator in full story view
miFullScreenProgressBarPrimaryColor Set primary color of progress bar in full story view
miFullScreenProgressBarSecondaryColor Set secondary color of progress bar in full story view
miFullScreenSingleStoryDisplayTime Set time for particular story (i.e in milliseconds)

That's it 👍 and you're good to go 🚀

Guideline to report an issue/feature request

It would be very helpful for us, if the reporter can share the below things to understand the root cause of the issue.

  • Library version.
  • Code snippet.
  • Logs if applicable.
  • Screenshot/video with steps to reproduce the issue.

LICENSE!

MIStoryView is MIT-licensed.

Let us know!

If you use our open-source libraries in your project, please make sure to credit us and Give a star to www.mindinventory.com

Please feel free to use this component and Let us know if you are interested to building Apps or Designing Products.

app development
You might also like...
A study into creating a fully automatic FRC robot

AutoFRC This is a study into creating a fully automatic FRC robot. This process relies on several key algorithms: pose estiation: using the WpiLib Dif

Kafka Streams Processor to unwrap CØSMOS blocks into CØSMOS transactions
Kafka Streams Processor to unwrap CØSMOS blocks into CØSMOS transactions

Kafka Processor CØSMOS-Block A Kafka Streams Processor to unwrap CØSMOS blocks into CØSMOS transactions. Purpose The Kafka Processor CØSMOS-Block is b

Relationship-app-android - An app with features aimed towards me and my girlfriend

RelationshipApp Android An Android app with features aimed towards me and my gir

Flexible switch is a responsive switch with some nice features which developers can use for making awesome switches on android platform.

flexible-switch It is a responsive switch in android, it can resize itself according to its size. It's recommended to use it with ConstraintLayout to

A fork of CloudStream-3, with additional features and changes

CloudStream-3XXX A fork of CloudStream-3, with additional features and changes. Features All features of CloudStream 3, corresponding to this commit h

The app features real-time chatting between different users on daily topics

DailyDiscuss The app features real-time chatting between different users on daily topics. The app comes with 2 types of user interface: Admin who crea

Forge 1.8.9 mod with miscellaneous (primarily dungeons-related) QOL features for Hypixel Skyblock.

AmbientAddons-Forge A work-in-progress Forge 1.8.9 port of the AmbientAddons ChatTriggers module. Currently includes only chest features (block reroll

Simple view which allow you to customise your pizza's toppings and size as per your choice.
Simple view which allow you to customise your pizza's toppings and size as per your choice.

TwistedPizzaToppingsView Overview Simple view which allows options to customize your pizza toppings and size as per your choice. Features Android 12 s

Simple Kotlin application that displays the currently available network interfaces on your machine

Network-Interface-Checker Simple Kotlin application that displays the currently available network interfaces on your machine. An executable jar can be

Comments
  • Release second version

    Release second version

    Features:

    • Set a list of URLs consisting of Images/GIFs/Video in MiStoryView.
    • Set the fixed duration for media type Image/GIF.
    • Set the variable duration or the media type Video.
    • Implemented Exoplayer play/pause when long tap occurred.
    • Managed next/previous story invocation.
    • Implemented play/pause GIF media when a long tap occurred.
    opened by BhavnikDesai 0
Releases(0.0.3)
  • 0.0.1(May 13, 2022)

    • Initial launch
    1. Set a list of image URLs in MiStoryView.
    2. Set duration for the particular story (in milliseconds).
    3. Set any of the predefined animations, while swiping between multiple stories.
    4. Move to the back and forth story by tapping on the right and left parts of an image.
    5. Pause progress while keeping in touch on an image.
    6. Move to the whole next story or exit full story view, if a user is at the last item of the story.
    7. Move to the whole previous story or exit the full story view, if a user is at the first item of the story.
    8. Story indicator color changes once it is seen.
    Source code(tar.gz)
    Source code(zip)
Owner
MindInventory
MindInventory works with Enterprises, Startups, and Agencies since 2011 providing web, mobile app development, enterprise mobility solutions & DevOps services.
MindInventory
The WeeBe application is a social media-type app built on Ktor framework

The WeeBe application is a social media-type app built on Ktor framework that allows users to exchange various content connected with mental health, motivation, psychology, and improving oneself. Users can share posts with texts, images, videos, and links, as well as discuss the content in the comment section

Perpetio 3 Aug 5, 2022
Plugin to integrate EventStoreDB into Ktor-Server!

Ktor Plugin EventStoreDB EventStoreDB is an open-source database technology that stores your critical data in streams of immutable events. It was buil

null 7 Sep 1, 2022
🍓CookHelper - food social network. The Api and Websocket are based on Ktor framework. Dependency injection with Koin library.

CookHelper [ ?? Work in Progress ?? ] CookHelper is a cross-platform application that will allow you to cook a delicious dish from an existing recipe

Arthur 11 Nov 9, 2022
Sample Social Login Project of Spring Boot and Kotlin

Sample-Spring-Boot-Social-Kotlin Sample Social Login Project of Spring Boot and Kotlin dependencies dependencies { implementation("org.springframewor

Seokhyun 2 Oct 11, 2021
A media player, currently only for Android, that allows you to play songs in background for free

Just Listen A music player currently only for android. It is using Audius public APIs to display and get the playlists/songs. Available on google play

null 68 Dec 27, 2022
Astronomy Picture of the Day Nasa(APOD) media listing and show picture details.

Astronomy Picture of the Day Nasa(APOD) media listing and show picture details. Built to learn and use of Latest Android development libs using Coroutines, Flow, Dagger-Hilt, Architecture Components, MVVM, Room, Retrofit, Material Guideline)

pRaNaY 5 Oct 18, 2022
A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted outputs-and displays accurate measurements.

Measure App A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted o

ACM Student Chapter, PESU ECC 1 Oct 15, 2021
A deep learning based mobile application for the multi-class classification of pneumonia into three categories via Chest X-rays

PneumoniaClassifier A deep learning based mobile application for the multi-class classification of pneumonia into three categories via Chest X-rays. W

Timilehin Aregbesola 2 Dec 15, 2021
An Android app where you can view and examine the details of fast food divided into categories.

?? FastFood An Android application where you can view and examine the details of fast food divided into categories. ?? Tech Stack & Open-Source Librar

Muhammed Esad Cömert 3 Oct 7, 2022
Plugin and Desktop app for parsing layout xml into Composable code

composed-xml Inspired by - Recompose composed-xml is a tool for parsing Android layouts into Jetpack Compose code. It can work as both Desktop app or

Bacho Kurtanidze 9 Dec 26, 2022