Skip to content

Instantly share code, notes, and snippets.

View nisrulz's full-sized avatar
🌌
Coding in the MultiVerse

Nishant Srivastava nisrulz

🌌
Coding in the MultiVerse
View GitHub Profile
@nisrulz
nisrulz / Activity.java
Last active March 11, 2016 09:48
RecyclerView implementation
// USAGE
// Data set
final ArrayList<ViewModel> viewModelArrayList = new ArrayList<>();
for (int i = 0; i < 100; i++) {
viewModelArrayList.add(new Order(i, "VM Name " + i));
}
// Recyclerview
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
@nisrulz
nisrulz / grayscale_imageview.java
Created December 25, 2015 05:52
Apply grayscale filter to ImageView in android
ImageView imgview = (ImageView)findViewById(R.id.imageView_grayscale);
imgview.setImageBitmap(bitmap);
// Apply grayscale filter
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imgview.setColorFilter(filter);
@nisrulz
nisrulz / AndroidManifest.xml
Created February 15, 2016 06:36 — forked from billmote/AndroidManifest.xml
When pushing code from your IDE, wake the device and show the activity.
<?xml version="1.0" encoding="utf-8"?>
<!-- Add this as a debug manifest so the permissions won't be required by your production app -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
</manifest>
@nisrulz
nisrulz / build.gradle
Created February 26, 2016 04:31
Change name of apk via gradle property in android
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.company.packagename"
minSdkVersion 7
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
@nisrulz
nisrulz / update.sh
Created April 21, 2016 18:28 — forked from kaushikgopal/update.sh
My morning cli ritual
echo "y" | android update sdk --no-ui; echo "yes" | apm upgrade; softwareupdate -i -a; brew update; brew upgrade; brew cleanup; brew cask cleanup; npm update npm -g; npm update -g; gem update
@nisrulz
nisrulz / DoubleBackPressExit.java
Created June 21, 2016 05:19
Get back press work only at second press and notify user to press again to exit.
private static long back_pressed;
@Override
public void onBackPressed(){
if (back_pressed + 2000 > System.currentTimeMillis()) super.onBackPressed();
else Toast.makeText(getBaseContext(), "Press once again to exit!", Toast.LENGTH_SHORT).show();
back_pressed = System.currentTimeMillis();
}
@nisrulz
nisrulz / ScanForWiFI.java
Created June 21, 2016 05:22
Scan for wireless network
public class WifiTester extends Activity {
TextView mainText;
WifiManager mainWifi;
WifiReceiver receiverWifi;
List<ScanResult> wifiList;
StringBuilder sb = new StringBuilder();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
@nisrulz
nisrulz / README.md
Created July 4, 2016 17:08 — forked from JakeWharton/README.md
A JUnit @rule which launches an activity when your test starts. Stop extending gross ActivityInstrumentationBarfCase2!
@nisrulz
nisrulz / filter.regexp
Created July 10, 2016 10:16 — forked from stepango/filter.regexp
Filter for logcat
^(?!(NotificationManager|Timeline|SensorManager|Configs|libc-netbsd|art|stetho|Choreographer|CliptrayUtils|BubblePopupHelper|ViewRootImpl|libEGL|System.out|PhoneWindow))
@nisrulz
nisrulz / config
Created July 13, 2016 06:18 — forked from donnfelker/config
Watch or Unwatch a file in git
# Goes in your .git/config file
[alias]
# Temporarily stop tracking a file in git.
# usage: git unwatch path/to/file
unwatch = update-index --assume-unchanged
# Resume tracking a file in git.
# usage: git watch path/to/file
watch = update-index --no-assume-unchanged