Skip to content

Instantly share code, notes, and snippets.

interface CryptographyManager {
/**
* This method first gets or generates an instance of SecretKey and then initializes the Cipher
* with the key. The secret key uses [ENCRYPT_MODE][Cipher.ENCRYPT_MODE] is used.
*/
fun getInitializedCipherForEncryption(keyName: String): Cipher
/**
* This method first gets or generates an instance of SecretKey and then initializes the Cipher
Observable.just("Will")
.observeOn(Schedulers.io())
.flatMap({ name ->
updateUserName.execute(name) //returns another Observable<ApiResult> after calling the API
}, {
//this is executed after resolving the last observable emitted, so the result is ready.
name: String, apiResult: ApiResult -> Pair(name, apiResult)
})
.subscribe({ result ->
<?xml version="1.0" encoding="utf-8"?><!-- Clickable and selectableItemBackground are optional -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:minHeight="72dp"
@Heroes84
Heroes84 / height.java
Created October 29, 2019 22:45 — forked from hamakn/height.java
Android: Get height of status, action, navigation bar (pixels)
// status bar height
int statusBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
// action bar height
int actionBarHeight = 0;
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
@Heroes84
Heroes84 / DataManager.java
Created October 25, 2016 07:39
Advanced Android training
package com.bignerdranch.android.nerdfinder.web;
import android.content.Context;
import android.net.Uri;
import android.util.Log;
import com.bignerdranch.android.nerdfinder.exception.UnauthorizedException;
import com.bignerdranch.android.nerdfinder.listener.VenueCheckInListener;
import com.bignerdranch.android.nerdfinder.listener.VenueSearchListener;
@Heroes84
Heroes84 / tytuły
Created August 24, 2016 19:41
infobuzer title
switch($category) {
case 2:
$title = 'zakupy grupowe TRAVEL PODRÓŻE';
break;
case 11:
$title = 'zakupy grupowe KRAKÓW';
break;
case 10:
$title = 'zakupy grupowe WARSZAWA - okazje cenowe, kody kupony rabatowe, oferty promocyjne';
break;
@Heroes84
Heroes84 / gson.java
Last active July 8, 2016 09:24
GSON TypeToken
/get json array from json string
JsonArray jarray = jobject.getAsJsonArray("reportRecords");
//get a list of reportRecords using Gson
Gson mGson = new Gson();
Type listType = new TypeToken<List<DataMetrics>>(){}.getType();
List<DataMetrics> dataMetricsList = mGson.fromJson(reportRecordsJsonArray, listType);
//Filter only the ones with a specific name
List<DataMetrics> dataMetricsFilteredList = dataMetricsList.stream().filter(dataMetric -> dateMetric.getName.equals("Client::Sync"));
@Heroes84
Heroes84 / Fragment backstack Manager.java
Last active July 8, 2016 09:24
Fragment backstack manager to access fragment all time in stack
package com.chimeraprime.prizecam.tools.fragment;
import android.os.Bundle;
import android.support.v4.BuildConfig;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;