Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Deepan tizisdeepan

🎯
Focusing
Block or report user

Report or block tizisdeepan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View VideoPlaybackOldExoPlayer.kt
val mainHandler = Handler()
val url = "YOUR_VIDEO_URL"
val bandwidthMeter = DefaultBandwidthMeter()
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(bandwidthMeter)
val trackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
val player = ExoPlayerFactory.newSimpleInstance(this, trackSelector)
videoView.player = player
val dataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, "ZohoSocial"), bandwidthMeter)
val videoSource = if (url.contains(".m3u8")) HlsMediaSource(Uri.parse(url), dataSourceFactory, mainHandler, null)
else ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url))
View VideoPlaybackNewExoPlayer.kt
val url = "YOUR_VIDEO_URL"
val player = ExoPlayerFactory.newSimpleInstance(this)
videoView.player = player
val dataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, "ZohoSocial"))
val mediaSource = if (url.contains(".m3u8")) DashMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url))
else ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url))
player.prepare(mediaSource)
View BrightnessSubFilter.kt
import android.graphics.Bitmap
import com.zomato.photofilters.imageprocessors.ImageProcessor
import com.zomato.photofilters.imageprocessors.SubFilter
class BrightnessSubFilter(brightness: Int) : SubFilter {
// Value is in integer
private var brightness = 0
init {
this.brightness = brightness
@tizisdeepan
tizisdeepan / LockableBottomSheetBehavior.kt
Created Apr 22, 2019
LockableBottomSheetBehavior can be used to lock a bottom sheet ignoring the swipe to dismiss actions done by the user.
View LockableBottomSheetBehavior.kt
import android.content.Context
import com.google.android.material.bottomsheet.BottomSheetBehavior
import androidx.coordinatorlayout.widget.CoordinatorLayout
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
class LockableBottomSheetBehavior<V : View>(context: Context, attrs: AttributeSet) : BottomSheetBehavior<V>(context, attrs) {
@tizisdeepan
tizisdeepan / SquareLayout.kt
Created Apr 22, 2019
SquareLayout makes sure that the view appears to be a square at all times no matter what it's attributes and children are.
View SquareLayout.kt
import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
class SquareLayout : FrameLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
@tizisdeepan
tizisdeepan / NetworkUtil.kt
Created Apr 22, 2019
Network utility class that helps in identifying whether there is a stable internet connection or not.
View NetworkUtil.kt
import android.content.Context
import android.net.ConnectivityManager
object NetworkUtil {
fun isConnected(context: Context): Boolean {
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetwork = cm.activeNetworkInfo
return activeNetwork != null && activeNetwork.isConnectedOrConnecting
}
}
@tizisdeepan
tizisdeepan / NoGifEditText.kt
Created Apr 22, 2019
EditText that ignores GIF support from Google Keypad.
View NoGifEditText.kt
import android.content.Context
import androidx.core.view.inputmethod.EditorInfoCompat
import androidx.core.view.inputmethod.InputConnectionCompat
import androidx.appcompat.widget.AppCompatEditText
import android.util.AttributeSet
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputConnection
import android.widget.Toast
import com.zoho.zohosocial.utils.RunOnUiThread
@tizisdeepan
tizisdeepan / ClipBoardManager.kt
Last active Apr 22, 2019
A Clip Board utility for copying contents to Clip Board.
View ClipBoardManager.kt
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.widget.Toast
object ClipBoardManager {
fun copy(ctx: Context, text: String, message: String = "") {
val myClipboard = ctx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val myClip = ClipData.newPlainText(message, text)
myClipboard.primaryClip = myClip
@tizisdeepan
tizisdeepan / AnimationlessViewpager.kt
Created Apr 22, 2019
A ViewPager component that has no animation while switching between pages.
View AnimationlessViewpager.kt
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
class AnimationlessViewpager : androidx.viewpager.widget.ViewPager {
var swipeLocked: Boolean = true
constructor(context: Context) : super(context)
@tizisdeepan
tizisdeepan / LockableViewPager.kt
Created Apr 22, 2019
A ViewPager component that disables swipe navigation.
View LockableViewPager.kt
import android.content.Context
import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager
import android.util.AttributeSet
class LockableViewPager : ViewPager {
var swipeLocked: Boolean = true
constructor(context: Context) : super(context)
You can’t perform that action at this time.