Skip to content

Instantly share code, notes, and snippets.

View piyush-malaviya's full-sized avatar

Piyush Malaviya piyush-malaviya

  • Ahmedabad, Gujarat, India
View GitHub Profile
@slightfoot
slightfoot / ThemedListPreference.java
Last active November 9, 2018 19:33
Themed ListPreference
import android.content.res.TypedArray;
import android.view.ContextThemeWrapper;
import android.util.AttributeSet;
import android.content.Context;
import android.preference.ListPreference;
public class ThemedListPreference extends ListPreference
{
@TakWolf
TakWolf / DisplayUtil.java
Created January 4, 2015 08:25
Android px, sp, dp convert util
package com.takwolf.android.util;
import android.content.Context;
public class DisplayUtil {
/**
* 将px值转换为dip或dp值,保证尺寸大小不变
*/
public static int px2dip(Context context, float pxValue) {
@Antarix
Antarix / MultiPartUtility.java
Created October 13, 2015 08:38
Uploading Multiple files at once with Post and Header parameter in Android
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
public interface AvailabilityChecker {
Observable<ValidationResult<String>> isEmailAvailable(@NonNull String email);
Observable<ValidationResult<String>> isUsernameAvailable(@NonNull String email);
ValidationResult<String> isEmailAvailableSync(@NonNull String email);
ValidationResult<String> isUsernameAvailableSync(@NonNull String email);
}
@lopspower
lopspower / README.md
Last active February 24, 2021 23:51
Configuration of proguard-rules.pro

Proguard Configuration

Twitter

1) Enable Proguard in your build.gradle module :

android {
    //...
 buildTypes {
@piyush-malaviya
piyush-malaviya / ContactHelper.java
Last active December 22, 2021 06:06
Contact helper class for fetching all contact details from contact id.
public class ContactHelper {
private static final String TAG = ContactHelper.class.getSimpleName();
public static ModelContact getContactDetails(final Context context, String contactId) {
ModelContact contact = new ModelContact();
contact.setContactId(contactId);
Cursor cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI,
@lopspower
lopspower / README.md
Last active May 11, 2022 02:47
Android Tools Attributes

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
@alphamu
alphamu / AA Transition App theme between light and dark themes
Last active September 9, 2022 21:59
Example of how to change themes at runtime with a smooth animation. In this example, we just switch between a light and a dark theme. The activity animation is defined in the theme and as such will be default on all activities with the set theme. [Demo Video here](http://youtu.be/Ps0phswbHls).
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
public class TransitionThemeActivity extends AppCompatActivity implements View.OnClickListener {
@unforgiven512
unforgiven512 / irrecord_key_and_button_namespace.md
Last active February 6, 2023 16:40
Organized list of LIRC button names

lirc -- keys & buttons namespace

The list was obtained using the following command...

# irrecord --list-namespace

...and was obtained from [this website][1].

@faisalraja
faisalraja / preferences.dart
Created January 17, 2019 03:03
SharedPreference helper for flutter
class Preference {
static SharedPreferences _prefs;
static Map<String, dynamic> _memoryPrefs = Map<String, dynamic>();
static Future<SharedPreferences> load() async {
if (_prefs == null) {
_prefs = await SharedPreferences.getInstance();
}
return _prefs;
}