Skip to content

Instantly share code, notes, and snippets.

View ponnamkarthik's full-sized avatar

Karthik Ponnam ponnamkarthik

View GitHub Profile
@ponnamkarthik
ponnamkarthik / PlayerActivity.java
Last active April 17, 2018 13:50
RTMP Player using Exo Media Player Library
//initiate Player
//Create a default TrackSelector
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
//Create the player
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
PlayerView playerView = findViewById(R.id.simple_player);
playerView.setPlayer(player);
import android.net.Uri;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
import net.butterflytv.rtmp_client.RtmpClient;
import java.io.IOException;
@ponnamkarthik
ponnamkarthik / ViewPagerActivity.java
Created September 15, 2017 12:59
ViewPage Scrolling Duration
try {
Field mScroller = null;
mScroller = ViewPager.class.getDeclaredField("mScroller");
mScroller.setAccessible(true);
ViewPagerScroller scroller = new ViewPagerScroller(viewPager.getContext());
mScroller.set(viewPager, scroller);
} catch (Exception e) {
Log.e("GHM", "error ", e);
}
@ponnamkarthik
ponnamkarthik / HttpUtil.java
Last active September 19, 2017 11:05 — forked from jalvarado91/HttpUtil.java
Ok Http Callback Wrap
package com.example.jalvarado.mlsview.utils;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import java.io.IOException;
@ponnamkarthik
ponnamkarthik / SendMessage.java
Last active December 17, 2018 21:45
Send Message in Android with Delivery and Sent Report
private void sendSms() {
try {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(
SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);
@ponnamkarthik
ponnamkarthik / FragmentClass.java
Created September 23, 2017 21:00
How to add MapFragment inside a Fragment Android
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
MapFragment mapFragment = (MapFragment) getActivity().getFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap map) {
@ponnamkarthik
ponnamkarthik / avd_loading_bar.xml
Created October 2, 2017 13:31 — forked from nickbutcher/avd_loading_bar.xml
A prototype of a loading indicator utilizing repeated gradients. See https://twitter.com/crafty/status/914830571196571648
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
@ponnamkarthik
ponnamkarthik / titlecase.java
Created October 15, 2017 20:00
Convert Text to Titlecase in Java
public static String toTitleCase(String str)
{
String[] words = str.trim().split(" ");
StringBuilder ret = new StringBuilder();
for(int i = 0; i < words.length; i++)
{
if(words[i].trim().length() > 0)
{
Log.e("words[i].trim",""+words[i].trim().charAt(0));
ret.append(Character.toUpperCase(words[i].trim().charAt(0)));
@ponnamkarthik
ponnamkarthik / JustifyTextView.java
Created October 30, 2017 14:00
Justify TextView android
package com.ghm.rtoexam.utils;
/**
* Created by ponna on 16-08-2017.
*/
import android.content.Context;
import android.graphics.Canvas;
import android.support.v7.widget.AppCompatTextView;
import android.text.Layout;
@ponnamkarthik
ponnamkarthik / progaurd-android.txt
Created November 3, 2017 14:15
Progaurd android
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see