This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template format="4" | |
revision="1" | |
name="Tab Layout Activity with recyclerview" | |
description="Creates a new Tab activity within fragment classes with recyclerview"> | |
<category value="Activity"/> | |
<parameter | |
id="mainActivityClass" | |
name="Activity Name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<recipe> | |
<instantiate from="src/app_package/Activity.kt.ftl" | |
to="${escapeXmlAttribute(srcOut)}/${mainActivityClass}.kt" /> | |
<instantiate from="src/app_package/TabFragment.kt.ftl" | |
to="${escapeXmlAttribute(srcOut)}/${tabFragmentClass}.kt" /> | |
<instantiate from="src/app_package/Adapter.kt.ftl" | |
to="${escapeXmlAttribute(srcOut)}/${itemAdapterClass}.kt" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ${packageName} | |
import android.os.Bundle | |
import android.support.design.widget.TabLayout | |
import android.support.v4.view.ViewPager | |
import android.support.v7.app.AppCompatActivity | |
import kotlinx.android.synthetic.main.${mainActivityLayout}.* | |
class ${mainActivityClass}: AppCompatActivity(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ${packageName} | |
import android.support.v7.widget.RecyclerView | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import kotlinx.android.synthetic.main.${itemLayout}.view.* | |
class ${itemAdapterClass} : RecyclerView.Adapter<${itemAdapterClass}.ViewHolder>() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ${packageName} | |
import android.os.Bundle | |
import android.support.v4.app.Fragment | |
import android.support.v7.widget.DefaultItemAnimator | |
import android.support.v7.widget.LinearLayoutManager | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import kotlinx.android.synthetic.main.${tabFragmentLayout}.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ${packageName} | |
import android.support.v4.app.Fragment | |
import android.support.v4.app.FragmentManager | |
import android.support.v4.app.FragmentPagerAdapter | |
class ViewPagerAdapter(manager: FragmentManager) : FragmentPagerAdapter(manager) { | |
private val mFragmentList = ArrayList<Fragment>() | |
private val mFragmentTitleList = ArrayList<String>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical"> | |
<android.support.design.widget.TabLayout | |
android:id="@+id/tab_layout" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<LinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.v4.widget.SwipeRefreshLayout | |
android:id="@+id/swipe" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/recycler" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="vertical"> | |
<TextView | |
android:id="@+id/tv_item" | |
android:layout_width="wrap_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun isAppInBackground(context: Context): Boolean { | |
var isInBackground = true | |
val am = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager | |
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) { | |
val runningProcesses = am.runningAppProcesses | |
for (processInfo in runningProcesses) { | |
if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { | |
for (activeProcess in processInfo.pkgList) { | |
if (activeProcess == context.packageName) { | |
isInBackground = false |
OlderNewer