Search in sources :

Example 1 with MyModel

use of csacre15.ipl.be.myapp.model.MyModel in project Synthese_2BIN by TheYoungSensei.

the class Builder method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    this.mainModel = new MyModel();
    LaFeteAdaptater mainAdaptateur = new LaFeteAdaptater(getApplicationContext());
    mainAdaptateur.open();
    mainModel.setAdaptateur(mainAdaptateur);
}
Also used : MyModel(csacre15.ipl.be.myapp.model.MyModel) LaFeteAdaptater(csacre15.ipl.be.myapp.dao.LaFeteAdaptater)

Example 2 with MyModel

use of csacre15.ipl.be.myapp.model.MyModel in project Synthese_2BIN by TheYoungSensei.

the class SMSReceiver method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    MyModel mainModel = ((Builder) context.getApplicationContext()).getModel();
    Bundle bundle = intent.getExtras();
    Object[] pdus = (Object[]) bundle.get("pdus");
    SmsMessage[] messages = new SmsMessage[pdus.length];
    String message = "";
    String tel = "";
    for (int i = 0; i < pdus.length; i++) {
        messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
        message += messages[i].getMessageBody();
        tel = messages[i].getOriginatingAddress();
    }
    String[] decoded = message.split(";");
    if (decoded[0].equalsIgnoreCase("#laFete")) {
        if (decoded.length != 4) {
            Toast.makeText(context, "Petit Coquin", Toast.LENGTH_LONG).show();
        } else {
            mainModel.ajouterUtil(decoded[1], decoded[2], decoded[3], tel);
        }
    } else {
        Toast.makeText(context, "Petit Coquin", Toast.LENGTH_LONG).show();
    }
}
Also used : SmsMessage(android.telephony.SmsMessage) MyModel(csacre15.ipl.be.myapp.model.MyModel) Bundle(android.os.Bundle) Builder(csacre15.ipl.be.myapp.Builder)

Aggregations

MyModel (csacre15.ipl.be.myapp.model.MyModel)2 Bundle (android.os.Bundle)1 SmsMessage (android.telephony.SmsMessage)1 Builder (csacre15.ipl.be.myapp.Builder)1 LaFeteAdaptater (csacre15.ipl.be.myapp.dao.LaFeteAdaptater)1