public static void startDownload(
      Context context, Magazine magazine, boolean isTemp, String tempUrlKey) {
    String fileUrl = magazine.getItemUrl();
    String filePath = magazine.getItemPath();
    if (magazine.isSample()) {
      fileUrl = magazine.getSamplePdfUrl();
      filePath = magazine.getSamplePdfPath();
    } else if (isTemp) {
      fileUrl = tempUrlKey;
    }
    Log.d(
        TAG,
        "isSample: " + magazine.isSample() + "\nfileUrl: " + fileUrl + "\nfilePath: " + filePath);
    EasyTracker.getTracker().sendView("Downloading/" + FilenameUtils.getBaseName(filePath));
    DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(fileUrl));
    request
        .setVisibleInDownloadsUi(false)
        .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
        .setDescription(magazine.getSubtitle())
        .setTitle(magazine.getTitle() + (magazine.isSample() ? " Sample" : ""))
        .setDestinationInExternalFilesDir(context, null, FilenameUtils.getName(filePath));
    // TODO should use cache directory?
    magazine.setDownloadManagerId(dm.enqueue(request));

    MagazineManager magazineManager = new MagazineManager(context);
    magazineManager.removeDownloadedMagazine(context, magazine);
    magazineManager.addMagazine(magazine, Magazine.TABLE_DOWNLOADED_MAGAZINES, true);
    magazine.clearMagazineDir();
    EventBus.getDefault().post(new LoadPlistEvent());
  }
Example #2
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    // Get the item that was clicked
    NSDictionary item = (NSDictionary) getListAdapter().getItem(position);

    NSObject action;
    if ((action = item.objectForKey("subcontent")) != null) {
      NSArrayWrapper wrapper = new NSArrayWrapper((NSArray) action);

      Intent intent = new Intent(this, Info.class);
      intent.putExtra("class", this.getClass().getCanonicalName());
      intent.putExtra(
          "tracking", getIntent().getStringExtra("tracking") + "/" + item.objectForKey("title"));
      intent.putExtra("content", wrapper);
      startActivity(intent);

    } else if ((action = item.objectForKey("url")) != null
        || (action = item.objectForKey("url-android")) != null) {
      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(((NSString) action).toString()));
      // Handle external activities as described in
      // http://developer.android.com/training/implementing-navigation/descendant.html#external-activities
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

      // We can't call the code in the onCreate as we may be opening the play store, so track it
      // here.
      EasyTracker.getTracker()
          .sendView(getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));
      Log.i(
          "Tracking", getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));

      startActivity(intent);
    } else if ((action = item.objectForKey("html")) != null) {
      Intent intent = new Intent(this, InfoWebActivity.class);
      intent.putExtra("class", this.getClass().getCanonicalName());

      EasyTracker.getTracker()
          .sendView(getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));
      Log.i(
          "Tracking", getIntent().getStringExtra("tracking") + " > " + item.objectForKey("title"));

      intent.putExtra("page", ((NSString) action).toString());
      startActivity(intent);
    } else if ((action = item.objectForKey("association")) != null) {
      Toast.makeText(
              this, "TODO: implement the association for " + action.toString(), Toast.LENGTH_SHORT)
          .show();
      System.err.println(action);
    } else {
      System.err.println("WHAT THE F**K IS THIS SHIT?");
    }
  }
    @Override
    protected void onPostExecute(final Provider data) {
      mAuthTask = null;

      if (data == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        builder
            .setTitle(R.string.no_network)
            .setMessage(R.string.error_no_network)
            .setNeutralButton(R.string.close_button, null);

        mAD = builder.create();
        mAD.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              public void onDismiss(DialogInterface dialog) {
                getActivity().finish();
              }
            });
        mAD.show();
        return;
      }
      Cache.provider = data;

      if (Cache.provider.isDemo && mAD == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        builder
            .setTitle(R.string.no_campus)
            .setMessage(R.string.error_no_campus)
            .setNeutralButton(R.string.continue_button, null);

        mAD = builder.create();
        mAD.show();
      }

      // TODO: make sure we still exist
      getActivity().setTitle(Cache.provider.name);
      setListAdapter(new LocationArrayAdapter(getActivity(), Cache.provider.locations));

      EasyTracker.getTracker()
          .sendEvent(
              "dataLoad",
              "provider",
              Cache.provider.name + " - " + Cache.provider.locations.size() + " locs",
              0L);
      EasyTracker.getTracker()
          .sendTiming(
              "dataLoad", System.currentTimeMillis() - startTime, "provider", Cache.provider.name);
    }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    boolean isValid = false;
    switch (item.getItemId()) {
      case R.id.savetaskMI:
        isValid = editATaskAction();
        if (isValid == true) finish();
        break;

      case R.id.addtaskMI:
        isValid = createATaskAction();
        if (isValid == true) {
          initilizeVariables();
          initilizeForNewTask();
          titleInputext.setText("");
          descriptionInputText.setText("");

          if (drawer.isMenuShowing()) drawer.toggle();

          toastWithGravity("Task Added!");
        }
        EasyTracker.getTracker()
            .sendEvent("UI-ActionBar", "Add Task-Append", "ActionBar", (long) 0);
        break;

      case R.id.proximityMI:
        AlertDialog diaBox = locationEditText();
        diaBox.show();
        EasyTracker.getTracker().sendEvent("UI-ActionBar", "Add Proximity", "ActionBar", (long) 0);
        break;

      case R.id.alarmMI:
        drawer.toggle(false);
        EasyTracker.getTracker()
            .sendEvent("UI-ActionBar", "Toggle Alarm Menu", "ActionBar", (long) 0);
        break;

      case R.id.backMI:
        EasyTracker.getTracker().sendEvent("UI-ActionBar", "back To Main", "ActionBar", (long) 0);
        finish();
        break;
    }

    return super.onOptionsItemSelected(item);
  }
Example #5
0
  private void initGCM() {
    try {
      // Make sure the device has the proper dependencies.
      GCMRegistrar.checkDevice(this);

      final String regId = GCMRegistrar.getRegistrationId(this);
      if (regId.equals("")) {
        // Automatically registers application on startup.
        GCMRegistrar.register(this, SENDER_ID);
      }
    } catch (Exception e) {
      EasyTracker.getTracker().trackException("cannot init GCM", e, false);
    }
  }
  @Override
  public void onTrackNameAvailable(String trackId, String trackName) {
    String trackType = null;

    switch (mViewType) {
      case TracksDropdownFragment.VIEW_TYPE_SESSIONS:
        trackType = getString(R.string.title_sessions);
        break;
      case TracksDropdownFragment.VIEW_TYPE_OFFICE_HOURS:
        trackType = getString(R.string.title_office_hours);
        break;
      case TracksDropdownFragment.VIEW_TYPE_SANDBOX:
        trackType = getString(R.string.title_sandbox);
        break;
    }

    EasyTracker.getTracker().sendView(trackType + ": " + getTitle());
    LOGD("Tracker", trackType + ": " + mTracksDropdownFragment.getTrackName());
  }
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "on create called...");
    activity = this;
    setContentView(R.layout.activity_show_reminder);
    // For hide Keyboard
    View view = (View) findViewById(R.id.reminders);
    Util.setupUI(view, this);
    EasyTracker.getInstance().setContext(getApplicationContext());
    tracker = EasyTracker.getTracker();
    tracker.trackView("List of Reminders Digital_Diary");
    getIds();
    addListener();
    Util.addGoogleAds(this);

    // setContentView(R.layout.custom_adapter);

  }
Example #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    GoPrefs.init(this);

    progress = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progress.setMax(100);
    progress.setProgress(10);

    LinearLayout lin = new LinearLayout(this);

    ImageView img = new ImageView(this);
    img.setImageResource(R.drawable.ic_launcher);
    img.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    lin.setOrientation(LinearLayout.VERTICAL);

    lin.addView(img);

    FrameLayout frame = new FrameLayout(this);
    frame.addView(progress);
    message_tv = new TextView(this);
    message_tv.setText("starting");
    message_tv.setTextColor(0xFF000000);
    message_tv.setPadding(7, 0, 0, 0);
    frame.addView(message_tv);

    lin.addView(frame);

    alert_dlg =
        new AlertDialog.Builder(this)
            .setCancelable(false)
            .setTitle(R.string.loading_sgf)
            .setView(lin)
            .show();

    EasyTracker.getTracker()
        .trackEvent("ui_action", "load_sgf", getIntent().getData().toString(), null);
    new Thread(this).start();
  }
Example #9
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setTitle(R.string.title_info);

    EasyTracker.getInstance().setContext(this);

    NSArrayWrapper wrapper = (NSArrayWrapper) getIntent().getParcelableExtra("content");
    NSArray content;
    if (wrapper != null) {
      content = wrapper.array;
    } else {
      try {
        content =
            (NSArray)
                XMLPropertyListParser.parse(getResources().openRawResource(R.raw.info_content));

      } catch (Exception ex) {
        Log.e("[Hydra.Info]", "Failed to parse the info content!");
        ex.printStackTrace();
        this.finish();
        return;
      }
    }

    if (getIntent() != null) {
      if (getIntent().getStringExtra("tracking") == null) {
        getIntent().putExtra("tracking", "Info");
      } else {
        EasyTracker.getTracker().sendView(getIntent().getStringExtra("tracking"));
        Log.i("Tracking", getIntent().getStringExtra("tracking"));
      }
    }

    setListAdapter(new InfoList(this, content));
  }
 @Override
 public void onStart() {
   super.onStart();
   EasyTracker.getTracker().trackView("Sort Dialog");
 }
 /**
  * Google Analytics helper method for easy event tracking.
  *
  * @param label
  */
 public void fireTrackerEvent(String label) {
   EasyTracker.getTracker().trackEvent("ShowInfo", "Click", label, (long) 0);
 }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setHasOptionsMenu(true);
   EasyTracker.getTracker().trackView("Employee Profile");
 }
 @Override
 public void onStart() {
   super.onStart();
   EasyTracker.getTracker().sendView(mTopicLeaf.getName() + " Guides");
 }
Example #14
0
 @Override
 public void onStart() {
   super.onStart();
   EasyTracker.getTracker().trackView("Add TVDb Shows");
 }