コード例 #1
0
 @Test
 public void objectBooleanAnnotatedTest() {
   Boolean objectBoolean = new Boolean(true);
   save(new BooleanFieldAnnotatedModel(objectBoolean));
   BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
   assertEquals(objectBoolean, model.getBoolean());
 }
コード例 #2
0
ファイル: Main_Nav.java プロジェクト: Pradeet/DAWebmail
    @Override
    public void onPostExecute(String result) {
      timeFinished = System.currentTimeMillis();
      invalidateOptionsMenu();
      Collections.reverse(ScrappingMachine.allemails);
      for (EmailMessage m : ScrappingMachine.allemails)
        m.save(); // now all e-mails are in the database

      // allemails_main creates a temporary arraylist of all emails in
      InboxFragment.allemails_main =
          (ArrayList<EmailMessage>)
              SugarRecord.listAll(EmailMessage.class); // fetch all emails from the
      // database

      Collections.reverse(InboxFragment.allemails_main);
      ScrappingMachine.clear_AllEmailsAL();
      InboxFragment.mAdapter.notifyDataSetChanged();

      long timeTaken = timeFinished - timeStarted;
      new ServerLoader(getApplicationContext())
          .addActionDetails(
              username, Constants.ACTION_MASTERREFRESH, "" + timeTaken, Constants.TRUE);

      Toast.makeText(Main_Nav.this, "Successfully Refreshed", Toast.LENGTH_SHORT).show();
      progdialog.dismiss();
    }
コード例 #3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(tag, "onCreateView");

    View view;

    // instantiate list
    newsList = new ArrayList<News>();

    List<Owner> owner = SugarRecord.listAll(Owner.class);
    if (owner.isEmpty()) {

      view = inflater.inflate(R.layout.fragment_owner_not_login, container, false);

      Toast.makeText(getActivity(), "You didn't log in before.", Toast.LENGTH_SHORT).show();
    } else {

      view = inflater.inflate(R.layout.fragment_news, container, false);
      newsView = (ListView) view.findViewById(R.id.news_list);

      final String userName = owner.get(owner.size() - 1).userName;
      // get songs from device
      getActivity()
          .runOnUiThread(
              new Runnable() {

                @Override
                public void run() {
                  // TODO Auto-generated method stub
                  getNewsList(userName);
                }
              });

      // create and set adapter
      newsAdt = new NewsAdapter(getActivity().getApplicationContext(), newsList);

      newsView.setAdapter(newsAdt);
      newsView.setOnItemLongClickListener(
          new OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) {
              String objectString = newsList.get(pos).getobjectId();

              // alert window
              ShowAlertDialogAndList(objectString);

              return true;
            }
          });
    }
    return view;
  }
コード例 #4
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
      case R.id.action_loginFacebook:
        List<Owner> owner = SugarRecord.listAll(Owner.class);
        if (!owner.isEmpty()) {
          final String userName = owner.get(owner.size() - 1).userName;
          getActivity()
              .runOnUiThread(
                  new Runnable() {

                    @Override
                    public void run() {
                      // TODO Auto-generated method stub
                      getNewsList(userName);
                    }
                  });
        }
    }
    return super.onOptionsItemSelected(item);
  }
コード例 #5
0
ファイル: TaskEditActivity.java プロジェクト: Shiv659/S-Task
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.activity_task_edit);

    titleView = (FloatingLabelEditText) findViewById(R.id.title);
    descriptionView = (FloatingLabelEditText) findViewById(R.id.description);

    titleView.getInputWidget().setSingleLine();
    descriptionView.getInputWidget().setMaxLines(5);

    if (getIntent().hasExtra(App.EXTRA_TASK_ID)) {
      setTitle(R.string.edit_task);
      long taskId = getIntent().getLongExtra(App.EXTRA_TASK_ID, -1);
      task = SugarRecord.findById(Task.class, taskId);
      titleView.setInputWidgetText(task.title);
      descriptionView.setInputWidgetText(task.description);
    } else {
      setTitle(R.string.new_task);
      task = new Task();
    }
  }
コード例 #6
0
ファイル: Repository.java プロジェクト: akbarcandra/SCORE16
 public long count() {
   return SugarRecord.count(classType, null, null);
 }
コード例 #7
0
ファイル: Repository.java プロジェクト: akbarcandra/SCORE16
 public Iterator<T> getAll() {
   return SugarRecord.findAll(classType);
 }
コード例 #8
0
ファイル: Repository.java プロジェクト: akbarcandra/SCORE16
 public T get(long id) {
   return SugarRecord.findById(classType, id);
 }
コード例 #9
0
 @Test
 public void rawBooleanAnnotatedTest() {
   save(new BooleanFieldAnnotatedModel(true));
   BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
   assertEquals(true, model.getRawBoolean());
 }
コード例 #10
0
 @Test
 public void nullBooleanAnnotatedTest() {
   save(new BooleanFieldAnnotatedModel());
   BooleanFieldAnnotatedModel model = SugarRecord.findById(BooleanFieldAnnotatedModel.class, 1);
   assertNull(model.getBoolean());
 }
コード例 #11
0
 @Test
 public void nullRawBooleanExtendedTest() {
   save(new BooleanFieldExtendedModel());
   BooleanFieldExtendedModel model = SugarRecord.findById(BooleanFieldExtendedModel.class, 1);
   assertEquals(false, model.getRawBoolean());
 }