Skip to content

Commit

Permalink
・Helperの名前にPersonを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuu-mA committed Oct 29, 2017
1 parent 7c991c5 commit 9197869
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Expand Up @@ -7,11 +7,11 @@
import io.realm.RealmResults;


public abstract class AbstractRealmHelper<T extends RealmObject> {
public abstract class AbstractPersonRealmHelper<T extends RealmObject> {

protected final Realm mRealm;

public AbstractRealmHelper() {
public AbstractPersonRealmHelper() {
mRealm = getRealm();
}

Expand Down
@@ -1,12 +1,9 @@
package com.pengin.poinsetia.konkatsudiary.Model;

import com.pengin.poinsetia.konkatsudiary.Model.AbstractRealmHelper;
import com.pengin.poinsetia.konkatsudiary.Model.Person;

import io.realm.Realm;
import io.realm.RealmResults;

public class ItemRealmHelper extends AbstractRealmHelper<Person> {
public class PersonRealmHelper extends AbstractPersonRealmHelper<Person> {

public static void insertOneShot(Person person) {
executeTransactionOneShot(insertTransaction(person));
Expand Down
Expand Up @@ -25,7 +25,7 @@
import android.widget.Spinner;
import android.widget.TextView;

import com.pengin.poinsetia.konkatsudiary.Model.ItemRealmHelper;
import com.pengin.poinsetia.konkatsudiary.Model.PersonRealmHelper;
import com.pengin.poinsetia.konkatsudiary.Model.Person;
import com.pengin.poinsetia.konkatsudiary.R;

Expand All @@ -47,7 +47,7 @@ public class PersonFragment extends Fragment implements OnRecyclerListener,View.
// RecyclerViewとAdapter
private RecyclerView mRecyclerView = null;
private PersonAdapter mAdapter = null;
private ItemRealmHelper mRealmHelper;
private PersonRealmHelper mRealmHelper;

public interface RecyclerFragmentListener {
void onRecyclerEvent();
Expand Down Expand Up @@ -107,7 +107,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
Realm.init(mActivity);
// Helperの作成
// リストの初期表示
mRealmHelper = new ItemRealmHelper();
mRealmHelper = new PersonRealmHelper();
// where
RealmResults<Person> results = mRealmHelper.findAll();
int listSize = results.size();
Expand Down Expand Up @@ -187,7 +187,7 @@ private void createList(Person person) {
if (person.getAge()!=0 &&
!person.getName().equals("")) {
// insert
ItemRealmHelper.insertOneShot(person);
PersonRealmHelper.insertOneShot(person);
// where
RealmResults<Person> results = mRealmHelper.findAll();
// positionでソート
Expand Down

0 comments on commit 9197869

Please sign in to comment.