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 / gist:d22808cc98b84fef5131
Created August 3, 2015 05:17
Using isFinish() to avoid bad tolken error
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@40b47bd8 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:452)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:283)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
at android.view.Window$LocalWindowManager.addView(Window.java:532)
at android.app.Dialog.show(Dialog.java:269)
...
---------------------------------------------
@devrath
devrath / LongDecimalConversion
Created August 6, 2015 14:28
Long decimal conversion
vHolder.txtWalletDebit.setText(new BigDecimal(mMyWallet.get(position).getDebit()).toPlainString());
@devrath
devrath / CheckingNullForClassInJava.java
Created August 10, 2015 07:38
CheckingNullForClassInJava
if (login.getPatient_profile() instanceof PatientProfile){
System.out.print("--------------->????--Is an intanceOf");
startMainActivity(true);
}
else {
System.out.print("----nnoooo-------->????--Not an intanceOf");
startMainActivity(false);
}
@devrath
devrath / DateTimeSeperatelyJavaUtil.java
Created August 17, 2015 09:21
Getting Data and time seperately
public class UtilDateTimeConv {
//FORMAT THE SERVER IS SENDING DATE & TIME ----- > yyyy-MM-dd'T'hh:mm:ss
//////////////////////////// FORMAT - ONE - DETAILS ////////////////////////////////
//FORMAT-ONE-DATE ------------------------------ > MMM dd, yyyy --- > JULY 05, 2015
//FORMAT-ONE-TIME ------------------------------ > hh:mm a -------- > 5:45 PM
//////////////////////////// FORMAT - ONE - DETAILS ////////////////////////////////
//FORMAT-ONE-DATE
@devrath
devrath / addRemoveClearRecyclerViewObject.java
Created August 20, 2015 13:25
Used to remove, add and clear the items in listview. all methods to be placed in adapter and accessed from activity
public void removeAt(int position) {
items.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, items.size());
}
public void clearAll() {
items.clear();
notifyDataSetChanged();
}
@devrath
devrath / EmailWebUrlValidation.java
Created August 26, 2015 13:58
Email and WebUrl Validation
if (!android.util.Patterns.EMAIL_ADDRESS.matcher(emailId).matches()){
inputemail.setError(inputemail.getResources().getString(R.string.mail_Id_invalid));
valid = false;
}
@devrath
devrath / EditTextDateValidation.java
Created September 7, 2015 13:36
Validation date in EditText for android while user is clicking
//SOURCE: http://stackoverflow.com/questions/16889502/how-to-mask-an-edittext-to-show-the-dd-mm-yyyy-date-format
EditText date;
date = (EditText)findViewById(R.id.whichdate);
date.addTextChangedListener(tw);
TextWatcher tw = new TextWatcher() {
private String current = "";
@devrath
devrath / ExpandableListView Using RecyclerView.java
Created September 28, 2015 05:50
ExpandableListView using recyclerview. That also can have multiple adapters based on groups
ExpandableListAdapter.java |
---------------------------------------
import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@devrath
devrath / VollyGetPostRequest.java
Last active March 21, 2017 13:50
Reusable class, VOLLY - LIBRARY for GET and POST requests in android
How to Use:
AppController.java is a Application class
RequestQueueHelperWithTimeout.java, GsonRequest.java are the Util classes
........
Gradle:
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile('org.apache.httpcomponents:httpmime:4.3.6') {
@devrath
devrath / gsonToModelObject.java
Created November 24, 2015 17:14
Parsing String to model object
private void plotAllThePoints() {
InputStream source = new ByteArrayInputStream(mWord.getPatternMetaData().getBytes());
Reader reader = new InputStreamReader(source);
retraceData = gson.fromJson(reader, DataSetTwo.class);
Toast.makeText(ActDrawAreaTwo.this,retraceData.getStroke_points().get(0).getMain_dots().get(0).getDotOne().toString(),Toast.LENGTH_LONG).show();
}