Skip to content

Instantly share code, notes, and snippets.


Kartik Sharma crazyhitty

View GitHub Profile
crazyhitty /
Last active Mar 18, 2020
Issues with RxRoom and Flowable

In RxRoom, Flowable will always emit atleast one item, so using single() and isEmpty() functions won't work as expected.

So, the one where you are checking if projects are cached or not using isEmpty() function, room will still emit one item which would be an empty list object. This happens because even if no values exist in db, Room will still create an empty list first and then try to populate it if any items exist. Finally, it would emit the list object even if it is empty.

You can resolve this issue by updating the areProjectsCached() function in ProjectsCacheImpl.kt like this:

override fun areProjectsCached(): Single<Boolean> =
crazyhitty /
Last active Mar 11, 2018
How to use AsyncTask properly
public class MyActivity extends AppCompatActivity {
private DummyAsyncTask dummyAsyncTask = new DummyAsyncTask(new DummyAsyncTask.StatusCallback() {
public void progressStarted() {
public void onProgress(int progress) {
View build.gradle
android {
signingConfigs {
release {
storeFile file("someDirectory/my_keystore.jks")
storePassword "my_store_pass_here"
keyAlias "my_key_alias_here"
keyPassword "my_key_pass_here"
crazyhitty / .gitignore
Created Mar 14, 2017
Android gitignore
View .gitignore
# Created by,intellij+iml
### Android ###
# Built application files
# Files for the ART/Dalvik VM
crazyhitty /
Created Aug 7, 2016
Maintaining savedInstanceState in a fragment. Source:
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
// Only set fragment when saved instance is null
if(savedInstanceState==null) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
class Main {
public static void main(String[] args) {
for(int i=0; i<26; i++){
public static char[] getAlphabetsAZ(){
char[] alphabetArr=new char[26];
int x=0;