Android Open Source - hpush Basic Activity






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.app.activities;
// ww w .  java  2s .  c  om
import android.content.res.TypedArray;
import android.os.Build;
import android.os.Bundle;

import com.chopping.activities.BaseActivity;
import com.chopping.application.BasicPrefs;
import com.facebook.FacebookException;
import com.facebook.widget.WebDialog;
import com.facebook.widget.WebDialog.OnCompleteListener;
import com.hpush.R;
import com.hpush.bus.ClickMessageCommentsEvent;
import com.hpush.bus.ClickMessageLinkEvent;
import com.hpush.bus.ShareMessageEvent;
import com.hpush.data.MessageListItem;
import com.hpush.utils.Prefs;

/**
 * Abstract {@link android.app.Activity} of the app.
 *
 * @author Xinyue Zhao
 */
public abstract class BasicActivity extends BaseActivity {

  /**
   * Height of action-bar general.
   */
  private int mActionBarHeight;

  //------------------------------------------------
  //Subscribes, event-handlers
  //------------------------------------------------

  /**
   * Handler for {@link com.hpush.bus.ClickMessageCommentsEvent}.
   *
   * @param e
   *     Event {@link com.hpush.bus.ClickMessageCommentsEvent}.
   */
  public void onEvent(ClickMessageCommentsEvent e) {
    long cId = e.getMessage().getId();
    String url = Prefs.getInstance(getApplication()).getHackerNewsCommentsUrl();
    String target = url + cId;
    WebViewActivity.showInstance(this, target, e.getSenderV(), e.getMessage());
  }

  /**
   * Handler for {@link com.hpush.bus.ShareMessageEvent}.
   *
   * @param e
   *     Event {@link com.hpush.bus.ShareMessageEvent}.
   */
  public void onEvent(ShareMessageEvent e) {
    MessageListItem msg = e.getMessage();
    switch (e.getType()) {
    case Facebook:
      Bundle postParams = new Bundle();
      final WebDialog fbDlg = new WebDialog.FeedDialogBuilder(this, getString(R.string.applicationId), postParams)
          .setName(msg.getTitle()).setDescription(msg.getText()).setLink(msg.getUrl()).build();
      fbDlg.setOnCompleteListener(new OnCompleteListener() {
        @Override
        public void onComplete(Bundle bundle, FacebookException e) {
          fbDlg.dismiss();
        }
      });
      fbDlg.show();
      break;
    case Tweet:
      break;
    }
  }

  /**
   * Handler for {@link com.hpush.bus.ClickMessageLinkEvent}.
   *
   * @param e
   *     Event {@link com.hpush.bus.ClickMessageLinkEvent}.
   */
  public void onEvent(ClickMessageLinkEvent e) {
    WebViewActivity.showInstance(this, e.getMessage().getUrl(), e.getSenderV(), e.getMessage());
  }

  //------------------------------------------------

  /**
   * Calculate height of actionbar.
   */
  protected void calcActionBarHeight() {
    int[] abSzAttr;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      abSzAttr = new int[] { android.R.attr.actionBarSize };
    } else {
      abSzAttr = new int[] { R.attr.actionBarSize };
    }
    TypedArray a = obtainStyledAttributes(abSzAttr);
    mActionBarHeight = a.getDimensionPixelSize(0, -1);
  }


  /**
   *
   * @return  Height of action-bar general.
   */
  protected int getActionBarHeight() {
    return mActionBarHeight;
  }

  @Override
  protected BasicPrefs getPrefs() {
    return Prefs.getInstance(getApplication());
  }

}




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