Skip to content

Instantly share code, notes, and snippets.

View RobertApikyan's full-sized avatar

Robert Apikyan RobertApikyan

  • V-Mobile
  • Armenia, Yerevan
View GitHub Profile
/*
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.example.robert.materialtabs;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
<?xml version="1.0" encoding="utf-8"?>
<TabWidget xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="?android:actionBarSize"
android:layout_margin="10dp"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:visibility="gone"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.robert.materialtabs.MainActivity">
<com.example.robert.materialtabs.SlidingTabLayout
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
{
"Item": {
"BackgroundLink": "https://files.parsetfss.com/ff52c3df-2896-47df-b8ae-f54a832fa777/tfss-4c09e2b0-cf1d-47a2-a5db-565679ba74dc-iowaspeedwaylogo.jpg",
"ChatEnabled": true,
"ConvoID": 15155,
"CreateDate": "/Date(1453765097003)/",
"Description": "Iowa Speedway is a 7/8-mile paved oval motor racing track in Newton, Iowa aka The Fastest short track on the planet.",
"Email": "",
"Facebook": "IowaSpeedway",
"Hash": "IowaSpeedway",
infix fun <T> Boolean.then(param:T):T? = if(this) param else null
infix fun <T> T.ifNot(param: T):T? = if (this.isNull()) param else this
{
val isFirst = false
Log.d("loog","${isFirst then "First" ifNot "Second"}")
}
// output "Second"
@RobertApikyan
RobertApikyan / MainActivity.kt
Created March 23, 2018 07:11
MainActivity code for segmented controll
package example.com.segmentedcontrollsupport
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControl
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
private void onCaptureClick() {
if (mMapBoxMap!=null){
mMapBoxMap.snapshot((Bitmap snapshot) ->
SendScreenshotDialogFragment
.show(snapshot,mainActivity.getSupportFragmentManager()));
}
}
public static DialogFragment show(Bitmap bitmap, FragmentManager fragmentManager){
DialogFragment dialog = SendScreenshotDialogFragment.newInstance(bitmap);
dialog.show(fragmentManager, "SendScreenshotDialogFragment");
return dialog;
}
fun Date.toUTC(): Date {
var milliseconds = time
val offset = TimeZone.getDefault().getOffset(milliseconds).toLong()
milliseconds -= offset
return Date(milliseconds)
}