Skip to content

Instantly share code, notes, and snippets.

View lalitsharma1607's full-sized avatar

Lalit Sharma lalitsharma1607

  • Algorythma LLC, Abu Dhabi
  • Abu Dhabi, UAE
View GitHub Profile
@lalitsharma1607
lalitsharma1607 / FileUtils.java
Created April 26, 2017 10:04
Human readable file size format with units | Format file size as MB, GB etc
public class FileUtils{
public static String readableFileSize(long size) {
if(size <= 0) return "0";
final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}
}
@lalitsharma1607
lalitsharma1607 / FacebookLogin.java
Created October 10, 2017 09:26
Facebook Login in android
private CallbackManager callbackManager;
private LoginManager loginManager;
private ProgressDialog mProgressDialog;
public FragmentLogin() {
}
@Nullable
private void scaleAndAnimateToTop() {
ScaleAnimation animation = new ScaleAnimation(5.0f, 1.0f, 5.0f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setDuration(1000);
mView.startAnimation(animation);
}
private void animateInArc() {
Path path = new Path();
path.arcTo(0f, 0f, 500f, 500f, 90f, 270f, true);
@lalitsharma1607
lalitsharma1607 / Utils.java
Created May 14, 2018 05:21
Handling the jerk while changing full screen mode to normal mode
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
/*handling full screen to normal screen mode*/
WindowManager.LayoutParams attributes = getWindow().getAttributes();
attributes.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
getWindow().setAttributes(attributes);
@lalitsharma1607
lalitsharma1607 / AuthInterceptor.java
Created October 24, 2018 17:04
Authentication Intercepter
package com.taxiqq.driver.network;
import android.content.Context;
import android.content.SharedPreferences;
import java.io.IOException;
import okhttp3.Credentials;
import okhttp3.Interceptor;
import okhttp3.Request;