Android Open Source - InitHub-Android Subject Intent Service






From Project

Back to project page InitHub-Android.

License

The source code is released under:

MIT License

If you think the Android project InitHub-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.solutiosoft.android.inithub.service;
/*from   w w  w  . java  2  s  .  c  o m*/
import java.util.ArrayList;

import android.app.IntentService;
import android.content.ContentValues;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.solutiosoft.android.inithub.ApiHelper;
import com.solutiosoft.android.inithub.dao.InitHubDatabaseManager;
import com.solutiosoft.android.inithub.entities.Subject;
import com.solutiosoft.android.inithub.provider.SubjectProvider;

public class SubjectIntentService extends IntentService {
  private static final String TAG = "SubjectIntentService";

  public SubjectIntentService() {
    super("SubjectIntentService");
  }

  @Override
  public IBinder onBind(Intent intent) {
    // TODO: Return the communication channel to the service.
    throw new UnsupportedOperationException("Not yet implemented");
  }

  @Override
  protected void onHandleIntent(Intent intent) {
    ApiHelper api = ApiHelper.getInstance(this.getApplicationContext());
    ArrayList<Subject> list = api.getSubjectList();
    InitHubDatabaseManager db = new InitHubDatabaseManager(this.getApplicationContext());
    Log.d(TAG, "%%%%%%%%%% here 1");
    if(list != null){
      Log.d(TAG, "%%%%%%%%%% here 2");
      for(Subject subject : list){
        Log.d(TAG, "%%%%%%%%%% here 3");
        if(!db.subjectExists(subject.getRemoteId())){
          Log.d(TAG, "%%%%%%%%%% here 4");
          ContentValues values = new ContentValues();
            values.put(InitHubDatabaseManager.SUBJECT_SHORT_DESC, subject.getShortDesc());
            values.put(InitHubDatabaseManager.SUBJECT_LONG_DESC, subject.getLongDesc());
            values.put(InitHubDatabaseManager.SUBJECT_FIRST_NAME, subject.getFirstName());
            values.put(InitHubDatabaseManager.SUBJECT_LAST_NAME, subject.getLastName());
            values.put(InitHubDatabaseManager.SUBJECT_INITIATIVE, subject.getInitiative());
            values.put(InitHubDatabaseManager.SUBJECT_REMOTE_ID, subject.getRemoteId());
            getContentResolver().insert(SubjectProvider.CONTENT_URI, values);
        }
      }
    }
    
  }
}




Java Source Code List

com.solutiosoft.android.inithub.AlarmReceiver.java
com.solutiosoft.android.inithub.ApiHelper.java
com.solutiosoft.android.inithub.BootupReceiver.java
com.solutiosoft.android.inithub.Constants.java
com.solutiosoft.android.inithub.Utils.java
com.solutiosoft.android.inithub.dao.InitHubDatabaseManager.java
com.solutiosoft.android.inithub.dao.SubjectDatabaseHelper.java
com.solutiosoft.android.inithub.entities.Message.java
com.solutiosoft.android.inithub.entities.Subject.java
com.solutiosoft.android.inithub.entities.User.java
com.solutiosoft.android.inithub.provider.MessageProvider.java
com.solutiosoft.android.inithub.provider.SubjectProvider.java
com.solutiosoft.android.inithub.service.MessageIntentService.java
com.solutiosoft.android.inithub.service.SubjectIntentService.java
com.solutiosoft.android.inithub.ui.InboxActivity.java
com.solutiosoft.android.inithub.ui.LoginActivity.java
com.solutiosoft.android.inithub.ui.MessageActivity.java
com.solutiosoft.android.inithub.ui.MessageAddActivity.java
com.solutiosoft.android.inithub.ui.SettingsActivity.java
com.solutiosoft.android.inithub.ui.SplashActivity.java
com.solutiosoft.android.inithub.ui.SubjectActivity.java