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
public class MainActivity extends AppCompatActivity | |
implements NavigationView.OnNavigationItemSelectedListener { | |
@BindView(R.id.toolbar) | |
Toolbar toolbar; | |
@BindView(R.id.nav_view) | |
NavigationView navigationView; | |
@BindView(R.id.drawer_layout) | |
DrawerLayout drawer; |
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"?> | |
<actions> | |
<action intentName="actions.intent.TAKE_COURSE"> | |
<parameter name="course"> | |
<entity-set-reference | |
entityType="org.schematype.Course" | |
urlFilter="https://www.course.org/*"> | |
</entity-set-reference> | |
</parameter> | |
<fulfillment urlTemplates="{url}?referrer=actions-on-google-previous"/> |
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
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.example.android.app"> | |
... | |
<application> | |
... | |
<provider android:name="MySliceProvider" | |
android:authorities="com.example.android.app" | |
android:exported="true" > | |
<intent-filter> | |
<action android:name="android.intent.action.VIEW" /> |
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
dependencies { | |
--- | |
// Room components | |
implementation 'android.arch.persistence.room:runtime:1.1.1' | |
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1' | |
// Lifecycle components | |
implementation 'android.arch.lifecycle:extensions:1.1.1' | |
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1' | |
} |
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
@Dao | |
interface HabitDao { | |
@Insert | |
fun insert(habit: Habits) | |
@Query("DELETE FROM habitClass") | |
fun deleteAll() | |
@Query("SELECT * FROM habitClass ORDER BY habit ASC" ) |
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
@Database(entities = {Habit.class}, version = 1) | |
public abstract class HabitRoomDatabase extends RoomDatabase{ | |
public abstract HabitDao wordDao(); | |
//SINGLETON | |
private static HabitRoomDatabase INSTANCE; | |
static HabitRoomDatabase getDatabase(final Context context) { | |
if (INSTANCE == null) { |
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
@Entity(tableName = "habitClass") | |
data class Habit(@PrimaryKey | |
@ColumnInfo(name = "habit") val mHabit: 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
class HabitViewModel(application: Application) : AndroidViewModel(application) { | |
private val habitRepository: HabitRepository | |
internal val allWords: LiveData<List<Habit>> | |
init { | |
habitRepository = HabitRepository(application) | |
allWords = habitRepository.getAllWords() | |
} |
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
class HabitListAdapter internal constructor(context: Context) : RecyclerView.Adapter<HabitListAdapter.HabitViewHolder>() { | |
private val mInflater: LayoutInflater | |
private var habitsList: List<Habit>? = null | |
init { | |
mInflater = LayoutInflater.from(context) | |
} | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HabitViewHolder { |
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
class MainActivity : AppCompatActivity() { | |
val NEW_WORD_ACTIVITY_REQUEST_CODE = 1 | |
private var mWordViewModel: HabitViewModel?= null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) |
OlderNewer