Android Open Source - hpush Utils






From Project

Back to project page hpush.

License

The source code is released under:

MIT License

If you think the Android project hpush 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.hpush.utils;
/*from  ww w  . jav a 2s  .  c  o m*/
import java.util.Map;

import android.content.Context;
import android.content.Intent;
import android.os.Build;

import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
import static android.text.format.DateUtils.FORMAT_SHOW_TIME;
import static android.text.format.DateUtils.FORMAT_SHOW_YEAR;
import static android.text.format.DateUtils.formatDateTime;

/**
 * Util-methods.
 *
 * @author Xinyue Zhao
 */
public final class Utils {
  /**
   * There is different between android pre 3.0 and 3.x, 4.x on this wording.
   */
  public static final String ALPHA =
      (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) ? "alpha" : "Alpha";
  /**
   * Convert a timestamps to a readable date in string.
   *
   * @param cxt
   *     {@link android.content.Context}.
   * @param timestamps
   *     A long value for a timestamps.
   *
   * @return A date string format.
   */
  public static String convertTimestamps2DateString(Context cxt, long timestamps) {
    return formatDateTime(cxt, timestamps, FORMAT_SHOW_YEAR | FORMAT_SHOW_DATE |
        FORMAT_SHOW_TIME | FORMAT_ABBREV_MONTH);
  }

  /**
   * Standard sharing app for sharing on actionbar.
   */
  public static Intent getDefaultShareIntent(android.support.v7.widget.ShareActionProvider provider, String subject,
      String body) {
    if (provider != null) {
      Intent i = new Intent(Intent.ACTION_SEND);
      i.setType("text/plain");
      i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
      i.putExtra(android.content.Intent.EXTRA_TEXT, body);
      provider.setShareIntent(i);
      return i;
    }
    return null;
  }

  /**
   * Do some correct on http-header.
   * @param headers The available http-header.
   */
  public static void makeHttpHeaders(Map<String, String> headers) {

    if (headers.get("Accept-Encoding") == null) {
      headers.put("Accept-Encoding", "gzip");
    }
    if (headers.get("Content-Type") == null) {
      headers.put("Content-Type", "application/x-www-form-urlencoded");
    }
    if (headers.get("Content-Length") == null) {
      headers.put("Content-Length", "0");
    }
  }

}




Java Source Code List

com.hpush.app.App.java
com.hpush.app.activities.BasicActivity.java
com.hpush.app.activities.DailiesActivity.java
com.hpush.app.activities.MainActivity.java
com.hpush.app.activities.SettingActivity.java
com.hpush.app.activities.WebViewActivity.java
com.hpush.app.adapters.DailiesListAdapter.java
com.hpush.app.adapters.MainViewPagerAdapter.java
com.hpush.app.adapters.MessagesListAdapter.java
com.hpush.app.fragments.AboutDialogFragment.java
com.hpush.app.fragments.AdFragment.java
com.hpush.app.fragments.AppListImpFragment.java
com.hpush.app.fragments.BookmarksListFragment.java
com.hpush.app.fragments.DailiesLstFragment.java
com.hpush.app.fragments.GPlusFragment.java
com.hpush.app.fragments.MessagesListFragment.java
com.hpush.bus.BookmarkAllEvent.java
com.hpush.bus.BookmarkMessageEvent.java
com.hpush.bus.BookmarkedEvent.java
com.hpush.bus.ClickMessageCommentsEvent.java
com.hpush.bus.ClickMessageEvent.java
com.hpush.bus.ClickMessageLinkEvent.java
com.hpush.bus.DeleteAccountEvent.java
com.hpush.bus.EULAConfirmedEvent.java
com.hpush.bus.EULARejectEvent.java
com.hpush.bus.EditSettingsEvent.java
com.hpush.bus.GCMRegistedEvent.java
com.hpush.bus.InsertAccountEvent.java
com.hpush.bus.LoadAllEvent.java
com.hpush.bus.LoginedGPlusEvent.java
com.hpush.bus.LogoutGPlusEvent.java
com.hpush.bus.RemoveAllEvent.java
com.hpush.bus.SelectMessageEvent.java
com.hpush.bus.ShareMessageEvent.java
com.hpush.bus.ShowActionBar.java
com.hpush.bus.SortAllEvent.java
com.hpush.bus.UpdateCurrentTotalMessagesEvent.java
com.hpush.data.DailyListItem.java
com.hpush.data.Daily.java
com.hpush.data.FunctionType.java
com.hpush.data.MessageListItem.java
com.hpush.data.Message.java
com.hpush.data.Status.java
com.hpush.data.SyncList.java
com.hpush.db.BookmarksTbl.java
com.hpush.db.DB.java
com.hpush.db.DailyTbl.java
com.hpush.db.DatabaseHelper.java
com.hpush.db.MessagesTbl.java
com.hpush.gcm.ChangeSettingsTask.java
com.hpush.gcm.GcmBroadcastReceiver.java
com.hpush.gcm.GcmIntentService.java
com.hpush.gcm.RegGCMTask.java
com.hpush.gcm.SyncTask.java
com.hpush.gcm.UnregGCMTask.java
com.hpush.utils.Prefs.java
com.hpush.utils.Utils.java
com.hpush.views.FontTextView.java
com.hpush.views.OnViewAnimatedClickedListener2.java
com.hpush.views.OnViewAnimatedClickedListener3.java
com.hpush.views.OnViewAnimatedClickedListener.java
com.hpush.views.SortActionViewProvider.java
com.hpush.views.WebViewEx.java