Skip to content

Instantly share code, notes, and snippets.

View devrath's full-sized avatar
💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it

Devrath devrath

💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it
View GitHub Profile
@devrath
devrath / dynamicPlottingOfPoints.java
Last active November 25, 2015 14:37
Dynamic plotPoints send to server and RePlot it
//Use this code to get Device's height and width and save them to variable, like this
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int width = displaymetrics.widthPixels;
//After getting your X and Y use below mentioned function to get percentage
int percentageX= (int)((x*100)/width)
int percentageY= (int)((y*100)/height)
@devrath
devrath / CustomProgressDialogAndroid.java
Created December 15, 2015 03:45
Showing a Custom Loader in Android
------------------------------------------------------------------------------------------------------------------------------
TransparentProgressDialog.java
public class TransparentProgressDialog extends Dialog {
private ImageView iv;
public TransparentProgressDialog(Context context, int resourceIdOfImage) {
super(context, R.style.TransparentProgressDialog);
WindowManager.LayoutParams wlmp = getWindow().getAttributes();
@devrath
devrath / MasterUtil.Java
Created December 15, 2015 04:55
List of all the functions that can be used in All the projects
public class CommonFunctions {
public static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
public static Activity context;
/*********************************************Network Check*********************************/
public static boolean isOnline(Activity _context) {
context=_context;
@devrath
devrath / CustomFont.java
Created December 15, 2015 04:59
Loading a custom font for a TextView from a custom class
public class CustomTV_Sam_bold extends TextView {
Context context;
public CustomTV_Sam_bold(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
init();
}
public CustomTV_Sam_bold(Context context, AttributeSet attrs) {
super(context, attrs);
@devrath
devrath / MyCustomStyles.xml
Created March 21, 2016 09:20
Usage Of Styles In The Application
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowBackground">@color/main_color</item>
</style>
<style name="AppTheme.RootView">
@devrath
devrath / UtilToast.java
Created March 21, 2016 11:04
Util Class For The Toast Functionality In Android
import android.content.Context;
import android.widget.Toast;
/**
* Some utility methods related with the Toast class.
*
* @author Devrath
*/
public class ToastUtils {
@devrath
devrath / UtilSnackBar.java
Created March 23, 2016 07:53
Utilities For Snackbar
package com.godiswithme.Utils;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.support.design.widget.Snackbar;
import android.view.View;
import com.godiswithme.R;
@devrath
devrath / Dimen.java
Created April 21, 2016 11:16
Update Dimensions Using String Value
protected int UpdateDimens(String imageName)
{
int identifier = getResources().getIdentifier(imageName, "dimens",getPackageName());
//int strId = getResources().getIdentifier(imageName, "string", getPackageName());
System.out.println(">>>>>>"+identifier);
try {
return identifier;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
@devrath
devrath / GCM_Integration.java
Created May 11, 2016 06:11
Simple GCM Integration
// In the OnCreate Method Start a background thread
new LongOperation().execute("");
private class LongOperation extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
@devrath
devrath / Camera.Java
Last active May 30, 2016 08:27
Camera front and back feature
surface_view_camera_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"