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 WordRepository { | |
private WordDao mWordDao; | |
private LiveData<List<Word>> mAllWords; | |
WordRepository(Application application) { | |
WordRoomDatabase db = WordRoomDatabase.getDatabase(application); | |
mWordDao = db.wordDao(); | |
mAllWords = mWordDao.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
// inner-class, extends possibility of async (since only one can be extended at the time) | |
// private so can't be a loose-filed class.. | |
// populates the DB with a dao coming from other thread(?) | |
private static class PopulateDbAsync extends AsyncTask<Void, Void, Void> { | |
private final StorageDao sDao; | |
PopulateDbAsync(StorageDatabase db) { sDao = db.storageDao(); } | |
@Override |
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"?> | |
<layout> | |
<!-- possible data objects coming later --> | |
<android.support.constraint.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" |
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
// Works // | |
public class MainActivity extends AppCompatActivity { | |
// ... | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); |
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 StorageListAdapter extends RecyclerView.Adapter<StorageListAdapter.StorageViewHolder> { | |
static RecyclerviewClickListener _listener; | |
// | |
// internal class ViewHolder | |
// | |
static class StorageViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener | |
{ | |
// the repeating item in the adapter |
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 com.mwb.digitalstorage.database; | |
import android.app.Application; | |
import androidx.lifecycle.LiveData; | |
import android.os.AsyncTask; | |
import com.mwb.digitalstorage.model.Storage; | |
import java.util.List; |
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 com.mwb.digitalstorage.database; | |
import com.mwb.digitalstorage.model.Shelf; | |
import com.mwb.digitalstorage.model.Storage; | |
import androidx.lifecycle.LiveData; | |
import androidx.room.Dao; | |
import androidx.room.Insert; | |
import androidx.room.Query; |
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"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
<data> | |
<variable | |
name="vm" | |
type="com.mwb.digitalstorage.viewmodel.ToolbarActivityViewModel"/> | |
</data> | |
<androidx.appcompat.widget.Toolbar |
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 Boolean checkNewCat(String catName) | |
{ | |
this.hasCategory.observe(this.getApplication(), new Observer<Boolean>() { | |
@Override | |
public void onChanged(Boolean aBoolean) | |
{ | |
componentRepository.getComponentCategories().observe(this.getApplication(), new Observer<List<ComponentCat>>() { | |
@Override | |
public void onChanged(@Nullable final List<ComponentCat> componentCats) | |
{ |
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 com.mwb.digitalstorage.adapter; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import com.mwb.digitalstorage.R; | |
import com.mwb.digitalstorage.StorageActivity; |
OlderNewer