Realm Problem After Installed

org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_131
Advertisements

React Native

Problem with Real Device

  1. Create a new folder => android/app/src/main/assetsjust create the folder assets in “android/app/src/main/”
  2. Run this command:
    react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

    This command will create 2 files:

    1. index.android.bundle
    2. index.android.bundle.meta
  3. run command
    react-native run-android

sometime you may get the error like…but it’s ok.

shareimprove this answer

1- Create a new folder => android/app/src/main/assets
2- Run this command =>

 react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res  

This command will create 2 files : index.android.bundle & index.android.bundle.meta

3- run command => react-native run-android

Create Multiple Model Realm

public boolean synceTransaction(final List<T> list){

    if(list.size() == 0) return false;

    Realm.init(getContext());

    realm = Realm.getInstance(getConfiguration());

    realm.executeTransactionAsync(new Realm.Transaction() {
        @Override
        public void execute(Realm realm) {
            for(int i = 0;i<list.size();i++) {
                realm.insert(list.get(i));
            }
        }
    }, new Realm.Transaction.OnSuccess() {
        @Override
        public void onSuccess() {
            Log.d("Status", "Successfully");
        }
    }, new Realm.Transaction.OnError() {
        @Override
        public void onError(Throwable error) {
            Log.d("Error", error.getMessage());
        }
    });

    return true;
}

//set this configuration to allow create multiple realm model in android
public RealmConfiguration getConfiguration() {
    return new RealmConfiguration
            .Builder()
            .name("transaction-realm")
            .schemaVersion(10)
            .deleteRealmIfMigrationNeeded()
            .build();
}

public void setConfiguration(RealmConfiguration configuration) {
    this.configuration = configuration;
}

Relationship Model

public class PayReceiptModelRealm extends RealmObject {
    private String AccountNo;
    private String PaymentGatewayNo;
    private String Token;
    public RealmList<TransactionModel> TransactionList = new RealmList<>();//don't forget to initialize this therefor it won't work
}

public class TransactionModel extends RealmObject {
    @PrimaryKey
    private int ID;
}


How to access views insde the actionLayout in menu

<menu xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <group
        android:visible="true"
        android:id="@+id/menu">
        <item
            android:id="@+id/nav_dashboard"
            android:icon="@drawable/ic_dashboard_home"
            android:title="Dashboard" />
        <item
            android:id="@+id/nav_time_sheet"
            android:icon="@drawable/ic_time_sheet"
            android:title="Time Sheet" />
        <item
            android:id="@+id/nav_setting"
            android:icon="@drawable/ic_settings"
            android:title="Setting" />

        <item
            android:id="@+id/nav_messaging"
            android:icon="@drawable/ic_chat"
            android:title="Chat" />

        <item
            android:id="@+id/nav_syn"
            android:icon="@drawable/ic_syncronize"
            android:title="Syncronize"/>

        <item
            android:id="@+id/nav_switcher"
            android:icon="@drawable/ic_mode"
            android:title="Offline Mode"
            android:clickable="false"
            app:actionLayout="@layout/layout_switcher_button" />
    </group>
</menu>


NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
MenuItem itemMenus = navigationView.getMenu().findItem(R.id.nav_switcher);
LinearLayout tracks = (LinearLayout) itemMenus.getActionView();
Switch switcher_mode = (Switch) tracks.findViewById(R.id.nav_drawer_switch);
switcher_mode.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Log.d("Hello","Hi");
    }
});

Create a free website or blog at WordPress.com.

Up ↑