Skip to content

Instantly share code, notes, and snippets.

View amatkivskiy's full-sized avatar
🇺🇦

Andrii Matkivskyi amatkivskiy

🇺🇦
View GitHub Profile
@amatkivskiy
amatkivskiy / TestCustomDrawerViewActivity
Created July 6, 2015 06:07
Example of Material Drawer with CustomView.
namespace Sample
{
using Android.App;
using Android.OS;
using Android.Widget;
using Mikepenz.MaterialDrawer;
using Android.Support.V7.App;
[Activity(MainLauncher = true, Label = "TestCustomDrawerViewActivity", Theme = "@style/MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus")]
public class TestCustomDrawerViewActivity : AppCompatActivity
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
public class EmptyRecyclerView extends RecyclerView {
@Nullable
public static Intent createIntent(Context context, int contentId, Class<?> referrer) {
Intent intent = new Intent(context, ContentDetailsActivity.class);
intent.putExtra(CONTENT_ID, contentId);
Referrers.putReferrer(intent, referrer);
return intent;
}
// Check whether back stack exists.
if (Referrers.hasReferrer(getIntent())) {
// If the current back stack exists just navigate to parent activity.
Class parentActivityClass = Referrers.getReferrer(getIntent());
Intent intent = new Intent(this, parentActivityClass).setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
this.startActivity(intent);
} else {
// If ItemDetailsActivity was open for example from the notification then create back stack manually.
Intent collectionsIntent = ContentCollectionActivity.createIntent(this, null);
boolean isFavourite = false;
for (MediaItem item : mediaItemList) {
if (item.getId().equalsIgnoreCase(currentItem.getId())) {
isFavourite = true;
}
}
public List<Pair<Character,MediaItem>> convert(List<Character> characters) {
List<Pair<Character,MediaItem>> downloads = new ArrayList<>();
for (Character character : characters) {
if (character.getItems() == null) {
continue;
}
for (MediaItem item : character.getItems()) {
downloads.add(new Pair<>(character, item));
}
public int findFirstValue(List<MediaItem> items) {
return Stream.stream(items)
.filter(new Func1<MediaItem, Boolean>() {
@Override
public Boolean call(MediaItem item) {
return item.isActive;
}
})
.map(new Func1<MediaItem, Pair<Integer, String>>() {
@Override
boolean find(List<MediaItem> data) {
return Stream.stream(data)
.any(new solid.functions.Func1<MediaItem, Boolean>() {
@Override
public Boolean call(MediaItem item) {
return item.isActive;
}
});
}
@amatkivskiy
amatkivskiy / maping-teamplate.txt
Created June 19, 2017 12:58
Slack incoming body mapping template (for AWS Gateway)
## convert HTML POST data or HTTP GET query string to JSON
## get the raw post data from the AWS built-in variable and give it a nicer name
#if ($context.httpMethod == "POST")
#set($rawAPIData = $input.path('$'))
## escape any quotes
#set($rawAPIData = $rawAPIData.replace('"', '\"'))
#elseif ($context.httpMethod == "GET")
#set($rawAPIData = $input.params().querystring)
#set($rawAPIData = $rawAPIData.toString())
#!/bin/bash
if [[ -z "${CI_PULL_REQUEST}" ]]; then
echo "---> Making build outside of Pull Request (building single commit or branch)"
./gradlew gnagCheck
else
echo "---> Making build for Pull Request"
# In the env variable CI_PULL_REQUEST CircleCI provides the URL of the PR (like https://github.com/amatkivskiy/sample/pull/3)
# But for the Gnag task we need PR number (simply 3)
# ${CI_PULL_REQUEST##*/} means that we simply get '3' from the URL provided in CI_PULL_REQUEST/