Esempio n. 1
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   Log.i("GTAG", "mAct bus: " + bus.hashCode());
   Log.i("GTAG", "mAct managerA: " + managerA.get().hashCode());
   Log.i("GTAG", "mAct managerA: " + managerA.get().hashCode());
   Log.i("GTAG", "mAct managerA: " + managerA.get().hashCode());
 }
  private void handleAnalytics(Intent intent) {
    String action = null, label = "";
    switch (intent.getAction()) {
      case ACTION_START:
      case ACTION_STOP:
      case ACTION_FINISH_ALARM:
      case ACTION_RESET:
        action = intent.getAction().replace("com.vngrs.android.pomodoro.action.", "");
        if (intent.getAction().equals(ACTION_START)) {
          label = ActivityType.fromValue(intent.getIntExtra(EXTRA_ACTIVITY_TYPE, 0)).toString();
        } else {
          label = pomodoroMaster.getActivityType().toString();
        }
        break;
      default:
        break;
    }

    if (action != null) {
      /* [ANALYTICS:EVENT]
       * TRIGGER:   Taking one of the Pomodoro Actions.
       * CATEGORY:  'Pomodoro'
       * ACTION:    'Feedback'
       * LABEL:     Activity Type if the action is Start
       * [/ANALYTICS]
       */
      analytics.get().sendEvent("Pomodoro", action, label);

      ContentValues values = new ContentValues();
      values.put(PomodoroDatabase.PomodoroColumns.ACTION, action);
      values.put(PomodoroDatabase.PomodoroColumns.ACTIVITY_TYPE, label);
      getContentResolver().insert(Pomodoros.CONTENT_URI, values);
    }
  }
 @Nullable
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   ListView list = (ListView) inflater.inflate(R.layout.fragment_sessions, null);
   list.setAdapter(new Adapter(getActivity(), mDbHelper.get().getSessions()));
   list.setOnItemClickListener(
       new AdapterView.OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           openSessionScreen(id);
         }
       });
   return list;
 }
Esempio n. 4
0
 public void brew() {
   heater.get().on();
   pump.pump();
   System.out.println(" [_]P coffee! [_]P ");
   heater.get().off();
 }
  @Override
  public List<NowAdapter.NowItem> loadInBackground() {
    if (!TraktCredentials.get(getContext()).hasCredentials()) {
      return null;
    }

    // get all trakt friends
    List<Friend> friends =
        SgTrakt.executeAuthenticatedCall(
            getContext(), traktUsers.get().friends(UserSlug.ME, Extended.FULL), "get friends");
    if (friends == null) {
      return null;
    }

    int size = friends.size();
    if (size == 0) {
      return null; // no friends, done.
    }

    // estimate list size
    List<NowAdapter.NowItem> items = new ArrayList<>(size + 1);

    // add header
    items.add(new NowAdapter.NowItem().header(getContext().getString(R.string.friends_recently)));

    // add last watched movie for each friend
    for (int i = 0; i < size; i++) {
      Friend friend = friends.get(i);

      // at least need a userSlug
      if (friend.user == null) {
        continue;
      }
      String userSlug = friend.user.ids.slug;
      if (TextUtils.isEmpty(userSlug)) {
        continue;
      }

      // get last watched episode
      List<HistoryEntry> history =
          SgTrakt.executeCall(
              getContext(),
              traktUsers
                  .get()
                  .history(
                      new UserSlug(userSlug),
                      HistoryType.MOVIES,
                      1,
                      1,
                      Extended.DEFAULT_MIN,
                      null,
                      null),
              "get friend movie history");
      if (history == null || history.size() == 0) {
        continue; // no history
      }

      HistoryEntry entry = history.get(0);
      if (entry.watched_at == null || entry.movie == null) {
        // missing required values
        continue;
      }

      String avatar =
          (friend.user.images == null || friend.user.images.avatar == null)
              ? null
              : friend.user.images.avatar.full;
      // trakt has removed image support: currently displaying no image
      NowAdapter.NowItem nowItem =
          new NowAdapter.NowItem()
              .displayData(entry.watched_at.getMillis(), entry.movie.title, null, null)
              .tmdbId(entry.movie.ids == null ? null : entry.movie.ids.tmdb)
              .friend(friend.user.username, avatar, entry.action);
      items.add(nowItem);
    }

    // only have a header? return nothing
    if (items.size() == 1) {
      return Collections.emptyList();
    }

    return items;
  }
Esempio n. 6
0
 public void brew() {
   heater.get().on();
   pump.pump();
   Window.alert(" [_]P coffee! [_]P ");
   heater.get().off();
 }