Android Open Source - JiangHomeStyle_Android_Phone Main Activity






From Project

Back to project page JiangHomeStyle_Android_Phone.

License

The source code is released under:

Apache License

If you think the Android project JiangHomeStyle_Android_Phone 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.cidesign.jianghomestylephone;
// ww  w  .  j ava  2 s. c  om
import com.androidquery.AQuery;
import com.cidesign.jianghomestylephone.async.AsyncInitCommunityData;
import com.cidesign.jianghomestylephone.async.AsyncInitData;
import com.cidesign.jianghomestylephone.async.AsyncInitHomeData;
import com.cidesign.jianghomestylephone.async.AsyncInitHumanityData;
import com.cidesign.jianghomestylephone.async.AsyncInitLandscapeData;
import com.cidesign.jianghomestylephone.async.AsyncInitStoryData;
import com.cidesign.jianghomestylephone.db.DatabaseHelper;
import com.cidesign.jianghomestylephone.entity.ArticleEntity;
import com.cidesign.jianghomestylephone.http.ArticalOperation;
import com.cidesign.jianghomestylephone.service.DownloadService;
import com.cidesign.jianghomestylephone.tools.JiangCategory;
import com.cidesign.jianghomestylephone.tools.StorageUtils;
import com.cidesign.jianghomestylephone.tools.WidgetCache;
import com.cidesign.jianghomestylephone.widget.CustomScrollView;
import com.cidesign.jianghomestylephone.widget.PopMenu;
import com.google.analytics.tracking.android.EasyTracker;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends JiangActivity
{
  private static final String TAG = MainActivity.class.getSimpleName();

  private AQuery aq;
  private DatabaseHelper dbHelper;
  private LayoutInflater inflater = null;

  private ArticalOperation aOper = null;

  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    EasyTracker.getInstance().setContext(this);

    aq = new AQuery(this);
    dbHelper = new DatabaseHelper(this);

    inflater = LayoutInflater.from(this);

    WidgetCache.getInstance().init(this);

    ImageView logoBtnClick = (ImageView) findViewById(R.id.logoBtnClick);
    logoBtnClick.setOnClickListener(new View.OnClickListener()
    {
      @Override
      public void onClick(View v)
      {
        ((CustomScrollView) WidgetCache.getInstance().getViewCache().get(R.id.mainScrollView)).smoothScrollTo(0, 0);
      }
    });

    new AsyncInitData(this, dbHelper, inflater, screenWidth).execute();
  }

  @Override
  public void onStart()
  {
    super.onStart();
    EasyTracker.getInstance().activityStart(this);
    // ??????????????????????????????????
    aOper = new ArticalOperation(this, aq, dbHelper);
    aOper.getArticleInfo();
  }

  @Override
  public void onResume()
  {
    super.onResume();
    IntentFilter counterActionFilter = new IntentFilter(DownloadService.BROADCAST_UPDATE_DATA_ACTION);  
        registerReceiver(updateArticleReceiver, counterActionFilter);
  }
  
  @Override
  public void onPause()
  {
    super.onPause();
    unregisterReceiver(updateArticleReceiver);
  }
  
  @Override
  public void onStop()
  {
    super.onStop();
    EasyTracker.getInstance().activityStop(this);
  }

  public void PopMenuClick(View target)
  {
    PopMenu.initPopuWindow(getBaseContext(), this.findViewById(R.id.topBarLayout), R.layout.popmenu,screenWidth);
  }

  public void DetailArticleClick(View target)
  {
    if (target.getTag() != null && (target.getTag() instanceof ArticleEntity))
    {
      ArticleEntity aEntity = (ArticleEntity) target.getTag();
      String url = "file://" + StorageUtils.FILE_ROOT + aEntity.getServerID() + "/doc/main.phone.html";
      Intent intent = new Intent(this, DetailActivity.class);
      intent.putExtra("url", url);
      intent.putExtra("title", aEntity.getTitle());
      this.startActivity(intent);
    }
  }
  
  private BroadcastReceiver updateArticleReceiver = new BroadcastReceiver()
  {
    public void onReceive(Context context, Intent intent)
    {
      int modelType = intent.getIntExtra("MODEL_TYPE", -1);  
      //String serverId = intent.getStringExtra("serverID");
      Log.i(TAG, "Receive broadcast event");
      new AsyncInitHomeData(MainActivity.this, dbHelper,inflater, screenWidth).execute();
      
      if (modelType == JiangCategory.LANDSCAPE)
      {
        Log.i(TAG, "update articles of landscape");
        new AsyncInitLandscapeData(MainActivity.this, dbHelper, screenWidth).execute();
              
      }
      else if (modelType == JiangCategory.HUMANITY)
      {
        Log.i(TAG, "update articles of humanity");
        new AsyncInitHumanityData(MainActivity.this, dbHelper, screenWidth).execute();        
      }
      else if (modelType == JiangCategory.STORY)
      {
        Log.i(TAG, "update articles of story");
        new AsyncInitStoryData(MainActivity.this, dbHelper, screenWidth).execute();
      }
      else if (modelType == JiangCategory.COMMUNITY)
      {
        Log.i(TAG, "update articles of community");
        new AsyncInitCommunityData(MainActivity.this, dbHelper, screenWidth).execute();        
      }
    }
  };
}




Java Source Code List

com.cidesign.jianghomestylephone.DetailActivity.java
com.cidesign.jianghomestylephone.JiangActivity.java
com.cidesign.jianghomestylephone.MainActivity.java
com.cidesign.jianghomestylephone.SplashActivity.java
com.cidesign.jianghomestylephone.adapter.CommunityViewpagerAdapter.java
com.cidesign.jianghomestylephone.adapter.HumanityViewpagerAdapter.java
com.cidesign.jianghomestylephone.adapter.LandscapeViewpagerAdapter.java
com.cidesign.jianghomestylephone.adapter.LayoutCaculateAdapter.java
com.cidesign.jianghomestylephone.adapter.StoryViewpagerAdapter.java
com.cidesign.jianghomestylephone.async.AsyncDownTask.java
com.cidesign.jianghomestylephone.async.AsyncInitCommunityData.java
com.cidesign.jianghomestylephone.async.AsyncInitData.java
com.cidesign.jianghomestylephone.async.AsyncInitHomeData.java
com.cidesign.jianghomestylephone.async.AsyncInitHumanityData.java
com.cidesign.jianghomestylephone.async.AsyncInitLandscapeData.java
com.cidesign.jianghomestylephone.async.AsyncInitStoryData.java
com.cidesign.jianghomestylephone.db.DatabaseConfigUtil.java
com.cidesign.jianghomestylephone.db.DatabaseHelper.java
com.cidesign.jianghomestylephone.entity.ArticleEntity.java
com.cidesign.jianghomestylephone.entity.FileListEntity.java
com.cidesign.jianghomestylephone.entity.LayoutEntity.java
com.cidesign.jianghomestylephone.entity.RelativeLayoutRulesEntity.java
com.cidesign.jianghomestylephone.http.ArticalOperation.java
com.cidesign.jianghomestylephone.http.DownLoadThread.java
com.cidesign.jianghomestylephone.service.DownloadService.java
com.cidesign.jianghomestylephone.tools.CategoryDataLoadingLogic.java
com.cidesign.jianghomestylephone.tools.FileOperationTools.java
com.cidesign.jianghomestylephone.tools.JiangCategory.java
com.cidesign.jianghomestylephone.tools.LayoutMarginSetting.java
com.cidesign.jianghomestylephone.tools.LoadingDataFromDB.java
com.cidesign.jianghomestylephone.tools.LoadingImageTools.java
com.cidesign.jianghomestylephone.tools.MD5Tools.java
com.cidesign.jianghomestylephone.tools.StorageUtils.java
com.cidesign.jianghomestylephone.tools.TimeTools.java
com.cidesign.jianghomestylephone.tools.WidgetCache.java
com.cidesign.jianghomestylephone.tools.XmlParseTools.java
com.cidesign.jianghomestylephone.version.NetworkTool.java
com.cidesign.jianghomestylephone.version.VersionConfig.java
com.cidesign.jianghomestylephone.version.VersionUpdate.java
com.cidesign.jianghomestylephone.widget.CommunityRelativeLayout.java
com.cidesign.jianghomestylephone.widget.CustomScrollView.java
com.cidesign.jianghomestylephone.widget.HScrollViewTouchLogic.java
com.cidesign.jianghomestylephone.widget.HumanityRelativeLayout.java
com.cidesign.jianghomestylephone.widget.LandscapeRelativeLayout.java
com.cidesign.jianghomestylephone.widget.PopMenu.java
com.cidesign.jianghomestylephone.widget.StoryRelativeLayout.java
org.apache.tools.zip.AbstractUnicodeExtraField.java
org.apache.tools.zip.AsiExtraField.java
org.apache.tools.zip.CentralDirectoryParsingZipExtraField.java
org.apache.tools.zip.ExtraFieldUtils.java
org.apache.tools.zip.FallbackZipEncoding.java
org.apache.tools.zip.GeneralPurposeBit.java
org.apache.tools.zip.JarMarker.java
org.apache.tools.zip.NioZipEncoding.java
org.apache.tools.zip.Simple8BitZipEncoding.java
org.apache.tools.zip.UnicodeCommentExtraField.java
org.apache.tools.zip.UnicodePathExtraField.java
org.apache.tools.zip.UnixStat.java
org.apache.tools.zip.UnparseableExtraFieldData.java
org.apache.tools.zip.UnrecognizedExtraField.java
org.apache.tools.zip.UnsupportedZipFeatureException.java
org.apache.tools.zip.Zip64ExtendedInformationExtraField.java
org.apache.tools.zip.Zip64Mode.java
org.apache.tools.zip.Zip64RequiredException.java
org.apache.tools.zip.ZipConstants.java
org.apache.tools.zip.ZipEightByteInteger.java
org.apache.tools.zip.ZipEncodingHelper.java
org.apache.tools.zip.ZipEncoding.java
org.apache.tools.zip.ZipEntry.java
org.apache.tools.zip.ZipExtraField.java
org.apache.tools.zip.ZipFile.java
org.apache.tools.zip.ZipLong.java
org.apache.tools.zip.ZipOutputStream.java
org.apache.tools.zip.ZipShort.java
org.apache.tools.zip.ZipUtil.java