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 GestureDetector m_detector;
public ArticleFragment() {
super();
}
public ArticleFragment(Article article) {
super();
public void initialize(Article article) {
m_article = article;
}

View File

@ -50,7 +50,8 @@ public class ArticlePager extends Fragment {
Article article = m_articles.get(position);
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()) {
getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
@ -68,13 +69,7 @@ public class ArticlePager extends Fragment {
}
public ArticlePager() {
super();
}
public ArticlePager(Article article, Feed feed) {
super();
public void initialize(Article article, Feed feed) {
m_article = article;
m_feed = feed;
}

View File

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

View File

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

View File

@ -67,10 +67,12 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
public void run() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
HeadlinesFragment hf = new HeadlinesFragment(feed, article);
HeadlinesFragment hf = new HeadlinesFragment();
hf.initialize(feed, article);
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);
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
@ -238,7 +240,8 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
FragmentTransaction ft = getSupportFragmentManager()
.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.commit();

View File

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

View File

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

View File

@ -86,7 +86,10 @@ public class OfflineArticlePager extends Fragment {
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;
@ -116,13 +119,7 @@ public class OfflineArticlePager extends Fragment {
}
}
public OfflineArticlePager() {
super();
}
public OfflineArticlePager(int articleId, int feedId, boolean isCat) {
super();
public void initialize(int articleId, int feedId, boolean isCat) {
m_feedId = feedId;
m_isCat = isCat;
m_articleId = articleId;

View File

@ -68,14 +68,20 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
boolean isCat = intent.getBooleanExtra("isCat", false);
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 {
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) {
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()
.beginTransaction();
OfflineFeedsFragment ff = new OfflineFeedsFragment(catId);
OfflineFeedsFragment ff = new OfflineFeedsFragment();
ff.initialize(catId);
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
ft.addToBackStack(null);
@ -234,7 +241,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
FragmentTransaction ft = getSupportFragmentManager()
.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.commit();

View File

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

View File

@ -52,8 +52,11 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
int articleId = i.getIntExtra("article", 0);
String searchQuery = i.getStringExtra("searchQuery");
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment(feedId, isCat);
OfflineArticlePager af = new OfflineArticlePager(articleId, feedId, isCat);
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
hf.initialize(feedId, isCat);
OfflineArticlePager af = new OfflineArticlePager();
af.initialize(articleId, feedId, isCat);
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_feedIsCat = isCat;
}
public OfflineHeadlinesFragment() {
//
}
@Override
public void onDestroy() {
super.onDestroy();