Skip to content

Instantly share code, notes, and snippets.

View artzmb's full-sized avatar
Working from home

Artem Nikonov artzmb

Working from home
View GitHub Profile
@artzmb
artzmb / gist:30c01894ac8bce89b1ed
Last active August 29, 2015 14:14
Send PUSH message
<?php
// API access key from Google API's Console
define('API_ACCESS_KEY', 'Не палимся');
$registrationIds = array("Не палимся");
// prep the bundle
$msg = array
(
@artzmb
artzmb / gist:0494d4c50897af514f91
Last active August 29, 2015 14:20
Retrofit error
JSONObject body;
try {
body = new JSONObject(new String(((TypedByteArray) ((RetrofitError) spiceException.getCause()).getResponse().getBody()).getBytes()));
} catch (JSONException e) {
e.printStackTrace();
}
@artzmb
artzmb / gist:b444e86eec19acf7cd34
Created July 22, 2015 11:48
Get version and build number
try {
PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
textViewVersion.setText(String.format("%s (%d)", info.versionName, info.versionCode));
} catch (PackageManager.NameNotFoundException e) {
// Whatever
}
@artzmb
artzmb / gist:aa6c57a33606a7e8aa88
Created July 22, 2015 14:41
Change style of a popup menu that pops up by hardware menu button
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>
@artzmb
artzmb / Contact.java
Created December 5, 2015 23:02 — forked from rogerhu/Contact.java
Endless scrolling with RecyclerVIew
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.List;
public class Contact {
private String mName;
private boolean mOnline;
public Contact(String name, boolean online) {
public class MainActivity extends AppCompatActivity {
public static class Shop {
public int id;
public String name;
public List<Coordinate> coordinates = new ArrayList<>();
@Override
public String toString() {
String str = id + " (" + name + ") [ ";
@artzmb
artzmb / layout#activity_main.xml
Created August 1, 2017 22:55
Android - Selector in vector drawables
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ru.artzmb.solar.MainActivity">
<ImageView
@artzmb
artzmb / AndroidManifest.xml
Last active March 6, 2018 16:51
HTTP Unauthorized interceptor
...
<service android:name=".background.interceptor.HttpUnauthorizedJobIntentService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false" />
...
import com.google.gson.Gson
import com.google.gson.TypeAdapter
import com.google.gson.TypeAdapterFactory
import com.google.gson.reflect.TypeToken
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import com.google.gson.stream.JsonToken
import com.google.gson.stream.MalformedJsonException
class SuddenArrayTypeAdapterFactory : TypeAdapterFactory {