Back to project page JiangHomeStyle_Android_Phone.
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.
package com.cidesign.jianghomestylephone.async; /* www . j a v a2s.c o m*/ import java.util.HashMap; import java.util.List; import android.app.Activity; import android.os.AsyncTask; import android.support.v4.view.ViewPager; import android.view.View; import com.cidesign.jianghomestylephone.R; import com.cidesign.jianghomestylephone.adapter.StoryViewpagerAdapter; import com.cidesign.jianghomestylephone.db.DatabaseHelper; import com.cidesign.jianghomestylephone.entity.ArticleEntity; import com.cidesign.jianghomestylephone.tools.LoadingDataFromDB; import com.cidesign.jianghomestylephone.tools.WidgetCache; public class AsyncInitStoryData extends AsyncTask<Void, Void, List<ArticleEntity>> { private Activity activity; private int screenWidth; private LoadingDataFromDB loadingDataFromDB = null; private DatabaseHelper dbHelper; // ????????????? private ViewPager storyViewPager; private StoryViewpagerAdapter storyViewpagerAdapter; private HashMap<Integer, View> widgetCache; public AsyncInitStoryData(Activity activity, DatabaseHelper dbHelper, int screenWidth) { this.activity = activity; this.dbHelper = dbHelper; this.screenWidth = screenWidth; } @Override protected void onPreExecute() { loadingDataFromDB = new LoadingDataFromDB(); widgetCache = WidgetCache.getInstance().getViewCache(); storyViewPager = (ViewPager) widgetCache.get(R.id.storyViewPager); } @Override protected List<ArticleEntity> doInBackground(Void... params) { return loadingDataFromDB.loadStoryArticle(dbHelper.getArticleListDataDao()); } @Override protected void onPostExecute(List<ArticleEntity> list) { if (list != null && list.size() > 0) { storyViewpagerAdapter = new StoryViewpagerAdapter(); storyViewpagerAdapter.setActivity(activity); storyViewpagerAdapter.setScreenWidth(screenWidth); storyViewpagerAdapter.getList().addAll(list); storyViewPager.setAdapter(storyViewpagerAdapter); } } }