remove custom fragment constructors

This commit is contained in:
Andrew Dolgov 2013-04-26 13:16:53 +04:00
parent dc6e9d3389
commit cd7f9529a7
12 changed files with 52 additions and 69 deletions

View File

@ -49,13 +49,7 @@ public class ArticleFragment extends Fragment implements GestureDetector.OnDoubl
private OnlineActivity m_activity; private OnlineActivity m_activity;
private GestureDetector m_detector; private GestureDetector m_detector;
public ArticleFragment() { public void initialize(Article article) {
super();
}
public ArticleFragment(Article article) {
super();
m_article = article; m_article = article;
} }

View File

@ -50,7 +50,8 @@ public class ArticlePager extends Fragment {
Article article = m_articles.get(position); Article article = m_articles.get(position);
if (article != null) { if (article != null) {
ArticleFragment af = new ArticleFragment(article); ArticleFragment af = new ArticleFragment();
af.initialize(article);
if (m_prefs.getBoolean("dim_status_bar", false) && getView() != null && !m_activity.isCompatMode()) { if (m_prefs.getBoolean("dim_status_bar", false) && getView() != null && !m_activity.isCompatMode()) {
getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
@ -68,13 +69,7 @@ public class ArticlePager extends Fragment {
} }
public ArticlePager() { public void initialize(Article article, Feed feed) {
super();
}
public ArticlePager(Article article, Feed feed) {
super();
m_article = article; m_article = article;
m_feed = feed; m_feed = feed;
} }

View File

@ -72,7 +72,9 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
if (article != null) { if (article != null) {
Article original = GlobalState.getInstance().m_loadedArticles.findById(article.id); Article original = GlobalState.getInstance().m_loadedArticles.findById(article.id);
ArticlePager ap = new ArticlePager(original != null ? original : article, feed); ArticlePager ap = new ArticlePager();
ap.initialize(original != null ? original : article, feed);
ft.replace(R.id.feeds_fragment, ap, FRAG_ARTICLE); ft.replace(R.id.feeds_fragment, ap, FRAG_ARTICLE);
ap.setSearchQuery(intent.getStringExtra("searchQuery")); ap.setSearchQuery(intent.getStringExtra("searchQuery"));
@ -80,14 +82,16 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
setTitle(feed.title); setTitle(feed.title);
} else { } else {
if (feed != null) { if (feed != null) {
HeadlinesFragment hf = new HeadlinesFragment(feed); HeadlinesFragment hf = new HeadlinesFragment();
hf.initialize(feed);
ft.replace(R.id.feeds_fragment, hf, FRAG_HEADLINES); ft.replace(R.id.feeds_fragment, hf, FRAG_HEADLINES);
setTitle(feed.title); setTitle(feed.title);
} }
if (cat != null) { if (cat != null) {
FeedsFragment ff = new FeedsFragment(cat); FeedsFragment ff = new FeedsFragment();
ff.initialize(cat);
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS); ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
setTitle(cat.title); setTitle(cat.title);
@ -214,7 +218,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
HeadlinesFragment hf = new HeadlinesFragment(fFeed); HeadlinesFragment hf = new HeadlinesFragment();
hf.initialize(fFeed);
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
ft.commit(); ft.commit();
@ -246,7 +251,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
FeedsFragment ff = new FeedsFragment(cat); FeedsFragment ff = new FeedsFragment();
ff.initialize(cat);
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS); ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
ft.addToBackStack(null); ft.addToBackStack(null);

View File

@ -62,12 +62,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
private boolean m_enableFeedIcons; private boolean m_enableFeedIcons;
private boolean m_feedIconsChecked = false; private boolean m_feedIconsChecked = false;
public FeedsFragment() { public void initialize(FeedCategory cat) {
}
public FeedsFragment(FeedCategory cat) {
m_activeCategory = cat; m_activeCategory = cat;
} }

View File

@ -67,10 +67,12 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
public void run() { public void run() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
HeadlinesFragment hf = new HeadlinesFragment(feed, article); HeadlinesFragment hf = new HeadlinesFragment();
hf.initialize(feed, article);
hf.setSearchQuery(searchQuery); hf.setSearchQuery(searchQuery);
ArticlePager af = new ArticlePager(article != null ? hf.getArticleById(article.id) : new Article(), feed); ArticlePager af = new ArticlePager();
af.initialize(article != null ? hf.getArticleById(article.id) : new Article(), feed);
af.setSearchQuery(searchQuery); af.setSearchQuery(searchQuery);
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
@ -238,7 +240,8 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
ArticlePager af = new ArticlePager(fArticle, fFeed); ArticlePager af = new ArticlePager();
af.initialize(fArticle, fFeed);
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
ft.commit(); ft.commit();

View File

@ -82,11 +82,11 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
return m_selectedArticles; return m_selectedArticles;
} }
public HeadlinesFragment(Feed feed) { public void initialize(Feed feed) {
m_feed = feed; m_feed = feed;
} }
public HeadlinesFragment(Feed feed, Article activeArticle) { public void initialize(Feed feed, Article activeArticle) {
m_feed = feed; m_feed = feed;
if (activeArticle != null) { if (activeArticle != null) {
@ -94,10 +94,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
} }
} }
public HeadlinesFragment() {
//
}
@Override @Override
public boolean onContextItemSelected(MenuItem item) { public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item AdapterContextMenuInfo info = (AdapterContextMenuInfo) item

View File

@ -48,16 +48,10 @@ public class OfflineArticleFragment extends Fragment implements GestureDetector.
private OfflineActivity m_activity; private OfflineActivity m_activity;
private GestureDetector m_detector; private GestureDetector m_detector;
public OfflineArticleFragment() { public void initialize(int articleId) {
super();
}
public OfflineArticleFragment(int articleId) {
super();
m_articleId = articleId; m_articleId = articleId;
} }
@Override @Override
public boolean onContextItemSelected(MenuItem item) { public boolean onContextItemSelected(MenuItem item) {
/* AdapterContextMenuInfo info = (AdapterContextMenuInfo) item /* AdapterContextMenuInfo info = (AdapterContextMenuInfo) item

View File

@ -86,7 +86,10 @@ public class OfflineArticlePager extends Fragment {
getView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN); getView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
} }
return new OfflineArticleFragment(m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID))); OfflineArticleFragment oaf = new OfflineArticleFragment();
oaf.initialize(m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID)));
return oaf;
} }
return null; return null;
@ -116,13 +119,7 @@ public class OfflineArticlePager extends Fragment {
} }
} }
public OfflineArticlePager() { public void initialize(int articleId, int feedId, boolean isCat) {
super();
}
public OfflineArticlePager(int articleId, int feedId, boolean isCat) {
super();
m_feedId = feedId; m_feedId = feedId;
m_isCat = isCat; m_isCat = isCat;
m_articleId = articleId; m_articleId = articleId;

View File

@ -68,14 +68,20 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
boolean isCat = intent.getBooleanExtra("isCat", false); boolean isCat = intent.getBooleanExtra("isCat", false);
if (articleId != -10000) { if (articleId != -10000) {
ft.replace(R.id.feeds_fragment, new OfflineArticlePager(articleId, feedId, isCat), FRAG_ARTICLE); OfflineArticlePager oap = new OfflineArticlePager();
oap.initialize(articleId, feedId, isCat);
ft.replace(R.id.feeds_fragment, oap, FRAG_ARTICLE);
} else { } else {
if (feedId != -10000) { if (feedId != -10000) {
ft.replace(R.id.feeds_fragment, new OfflineHeadlinesFragment(feedId, isCat), FRAG_HEADLINES); OfflineHeadlinesFragment ohf = new OfflineHeadlinesFragment();
ohf.initialize(feedId, isCat);
ft.replace(R.id.feeds_fragment, ohf, FRAG_HEADLINES);
} }
if (catId != -10000) { if (catId != -10000) {
ft.replace(R.id.feeds_fragment, new OfflineFeedsFragment(catId), FRAG_FEEDS); OfflineFeedsFragment off = new OfflineFeedsFragment();
off.initialize(catId);
ft.replace(R.id.feeds_fragment, off, FRAG_FEEDS);
} }
} }
@ -187,7 +193,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
OfflineFeedsFragment ff = new OfflineFeedsFragment(catId); OfflineFeedsFragment ff = new OfflineFeedsFragment();
ff.initialize(catId);
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS); ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
ft.addToBackStack(null); ft.addToBackStack(null);
@ -234,7 +241,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment(feedId, isCat); OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
hf.initialize(feedId, isCat);
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
ft.commit(); ft.commit();

View File

@ -42,11 +42,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
private Cursor m_cursor; private Cursor m_cursor;
private OfflineFeedsActivity m_activity; private OfflineFeedsActivity m_activity;
public OfflineFeedsFragment() { public void initialize(int catId) {
//
}
public OfflineFeedsFragment(int catId) {
m_catId = catId; m_catId = catId;
} }

View File

@ -52,8 +52,11 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
int articleId = i.getIntExtra("article", 0); int articleId = i.getIntExtra("article", 0);
String searchQuery = i.getStringExtra("searchQuery"); String searchQuery = i.getStringExtra("searchQuery");
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment(feedId, isCat); OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
OfflineArticlePager af = new OfflineArticlePager(articleId, feedId, isCat); hf.initialize(feedId, isCat);
OfflineArticlePager af = new OfflineArticlePager();
af.initialize(articleId, feedId, isCat);
hf.setActiveArticleId(articleId); hf.setActiveArticleId(articleId);

View File

@ -70,15 +70,11 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
}; };
public OfflineHeadlinesFragment(int feedId, boolean isCat) { public void initialize(int feedId, boolean isCat) {
m_feedId = feedId; m_feedId = feedId;
m_feedIsCat = isCat; m_feedIsCat = isCat;
} }
public OfflineHeadlinesFragment() {
//
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();