Skip to content

Instantly share code, notes, and snippets.

public class LiteratureAdapter extends RecyclerView.Adapter {
private List<Literature> mLiteratureList;
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView;
switch (viewType) {
case Literature.TYPE_BOOK:
@ernestkamara
ernestkamara / AdbCommands
Created June 26, 2018 08:42 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
public class PaginationActivity extends AppCompatActivity {
// removed for brevity..
private PublishProcessor<Integer> paginator = PublishProcessor.create();
private ProgressBar progressBar;
private boolean loading = false;
private int pageNumber = 1;
private final int VISIBLE_THRESHOLD = 1;
private int lastVisibleItem, totalItemCount;
@EfeBudak
EfeBudak / BitmapUtils.java
Last active August 10, 2018 04:46
Vector drawable to bitmap
public static BitmapDescriptor generateBitmapDescriptorFromRes(
Context context, int resId) {
Drawable drawable = ContextCompat.getDrawable(context, resId);
drawable.setBounds(
0,
0,
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight());
Bitmap bitmap = Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@Pulimet
Pulimet / AdbCommands
Last active July 8, 2024 08:00
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@AgiMaulana
AgiMaulana / Adding Badge to BottomNavigationView
Created August 16, 2017 18:00
Adding badge (such as notification count) in bottom nav menu item on android
navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(this);
navigation.setSelectedItemId(R.id.navigation_store);
BottomNavigationMenuView bottomNavigationMenuView =
(BottomNavigationMenuView) navigation.getChildAt(0);
View v = bottomNavigationMenuView.getChildAt(2); // number of menu from left
new QBadgeView(this).bindTarget(v).setBadgeNumber(5);
/**
* compile 'q.rorbin:badgeview:1.1.2'
* https://github.com/qstumn/BadgeView
@adavis
adavis / CommonExtensions.kt
Last active April 2, 2024 20:51
Common Android Extensions in Kotlin
fun View.visible() {
visibility = View.VISIBLE
}
fun View.invisible() {
visibility = View.INVISIBLE
}
fun View.gone() {
visibility = View.GONE
@jemshit
jemshit / proguard-rules.pro
Last active June 13, 2024 07:25
Proguard Rules for Android libraries
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
### RxJava, RxAndroid (https://gist.github.com/kosiara/487868792fbd3214f9c9)
-keep class rx.schedulers.Schedulers {
public static <methods>;
@jaisonfdo
jaisonfdo / SocialConnection.java
Last active September 4, 2021 16:24
Connect social media account in a single line of code in Android.For more information, check out my detailed guide here : http://droidmentor.com/connect-social-media-account/
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.text.TextUtils;
import android.widget.Toast;
/**