Android Open Source - foxail_reader Base Activity






From Project

Back to project page foxail_reader.

License

The source code is released under:

GNU General Public License

If you think the Android project foxail_reader 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 org.foxail.android.reader.activity;
/*w w  w.jav a  2 s  .com*/
import org.foxail.android.reader.R;
import org.foxail.android.reader.client.ClientFactory;
import org.foxail.android.reader.model.News;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.Toast;

public class BaseActivity extends Activity {
  
  private final static String TAG = "org.foxail.android.reader.activity.BaseActivity";
  protected final static int DIALOG_ALERT_COMMON = 0;
  protected final static int DIALOG_PROGRESS_COMMON = 10;
  
  protected ProgressDialog pDialog;
  protected ClientFactory clientFactory = ClientFactory.getInstance();

    @Override
    protected Dialog onCreateDialog(int id, Bundle bundle) {
      String title = null;
      String msg = null;
      if (bundle != null) {
        title = bundle.getString("title");
        msg = bundle.getString("msg");
      }
      if (isEmpty(title)) title = getString(R.string.title_notice);
      
      switch (id) {
      case DIALOG_ALERT_COMMON: 
        return new AlertDialog.Builder(BaseActivity.this)
            //.setIconAttribute(android.R.attr.alertDialogIcon)
            .setTitle(title)
            .setMessage(msg)
            .setPositiveButton(getString(R.string.button_ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
          dialog.dismiss();
          removeDialog(DIALOG_ALERT_COMMON);
                }
            })
            .create();
        
      case DIALOG_PROGRESS_COMMON:
            pDialog = new ProgressDialog(BaseActivity.this);
            //pDialog.setIconAttribute(android.R.attr.alertDialogIcon);
            pDialog.setTitle(title);
            pDialog.setMessage(msg);
            pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            return pDialog;
            
      default:
          return null;
      }
    }
    
    /**
     * ?????
     */
    protected void closePDialog() {
    if (pDialog.isShowing()) {
      pDialog.dismiss();
    }
    }
  
  /**
   * ??????????
   * 
   * @param msg
   */
    protected void showToast(String msg){
    Toast toast = Toast.makeText(BaseActivity.this, msg, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
  }
  
  /**
   * ???????????
   * 
   * @param str
   * @return boolean
   */
    protected boolean isEmpty(String str) {
    return (str == null || str.length() <= 0); 
  }
    
    /**
     * ????
     * 
     * @param id
     * @param title
     */
    protected void share(News news) {
    //????
    Intent intent=new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, R.string.button_share);
    intent.putExtra(Intent.EXTRA_TEXT, news.getTitle() + " " + news.getShareUrl());
    startActivity(Intent.createChooser(intent, getTitle()));
    }

}




Java Source Code List

org.foxail.android.common.CommonUtil.java
org.foxail.android.common.http.ConnectionManager.java
org.foxail.android.common.http.HttpConnection.java
org.foxail.android.common.volley.HtmlRequest.java
org.foxail.android.reader.activity.BaseActivity.java
org.foxail.android.reader.activity.FavoritesActivity.java
org.foxail.android.reader.activity.MainActivity.java
org.foxail.android.reader.activity.NewsActivity.java
org.foxail.android.reader.client.ClientFactory.java
org.foxail.android.reader.client.Client.java
org.foxail.android.reader.client.CnBetaClient.java
org.foxail.android.reader.model.News.java