remove obsolete code

This commit is contained in:
Andrew Dolgov 2013-05-28 13:17:02 +04:00
parent 882824190c
commit 1d82edfc0b
3 changed files with 92 additions and 239 deletions

View File

@ -78,50 +78,19 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
if (m_slidingMenu != null) if (m_slidingMenu != null)
m_slidingMenu.showMenu(); m_slidingMenu.showMenu();
/* if (intent.getParcelableExtra("article") != null) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (m_prefs.getBoolean("enable_cats", false)) {
m_actionbarUpEnabled = true; ft.replace(R.id.feeds_fragment, new FeedCategoriesFragment(), FRAG_CATS);
} else {
ft.replace(R.id.feeds_fragment, new FeedsFragment(), FRAG_FEEDS);
}
Feed feed = (Feed) intent.getParcelableExtra("feed"); ft.commit();
FeedCategory cat = (FeedCategory) intent.getParcelableExtra("category");
Article article = (Article) intent.getParcelableExtra("article");
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); AppRater.appLaunched(this);
checkTrial(true);
if (article != null) {
Article original = GlobalState.getInstance().m_loadedArticles.findById(article.id);
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"));
setTitle(feed.title);
}
ft.commit();
} else { */
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (m_prefs.getBoolean("enable_cats", false)) {
ft.replace(R.id.feeds_fragment, new FeedCategoriesFragment(), FRAG_CATS);
} else {
ft.replace(R.id.feeds_fragment, new FeedsFragment(), FRAG_FEEDS);
}
/* if (!isSmallScreen()) {
ft.replace(R.id.headlines_fragment, new HeadlinesFragment(new Feed(-3, "Fresh articles", false)));
} */
ft.commit();
AppRater.appLaunched(this);
checkTrial(true);
//}
} else { // savedInstanceState != null } else { // savedInstanceState != null
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth");
@ -154,7 +123,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
if (m_menu != null && getSessionId() != null) { if (m_menu != null && getSessionId() != null) {
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS); Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
//ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (m_slidingMenu != null) { if (m_slidingMenu != null) {
@ -162,32 +130,11 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && !m_slidingMenu.isMenuShowing()); m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && !m_slidingMenu.isMenuShowing());
} else { } else {
m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded())); m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded()));
//m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isAdded());
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded()); m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded());
m_menu.findItem(R.id.update_headlines).setVisible(false); m_menu.findItem(R.id.update_headlines).setVisible(false);
} }
/* if (isSmallScreen()) {
m_menu.findItem(R.id.update_headlines).setVisible(hf != null && hf.isAdded());
} else {
m_menu.findItem(R.id.update_headlines).setVisible(false);
} */
/* if (af != null) {
if (af.getSelectedArticle() != null && af.getSelectedArticle().attachments != null && af.getSelectedArticle().attachments.size() > 0) {
if (!isCompatMode()) {
m_menu.findItem(R.id.toggle_attachments).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
m_menu.findItem(R.id.toggle_attachments).setVisible(true);
} else {
if (!isCompatMode()) {
m_menu.findItem(R.id.toggle_attachments).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}
m_menu.findItem(R.id.toggle_attachments).setVisible(false);
}
} */
MenuItem item = m_menu.findItem(R.id.show_feeds); MenuItem item = m_menu.findItem(R.id.show_feeds);
if (getUnreadOnly()) { if (getUnreadOnly()) {
@ -253,32 +200,24 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
if (!openAsFeed) { if (!openAsFeed) {
if (false && isSmallScreen()) { if (fc != null) {
fc.setSelectedCategory(null);
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
intent.putExtra("category", cat);
startActivityForResult(intent, 0);
} else {
if (fc != null) {
fc.setSelectedCategory(null);
}
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
FeedsFragment ff = new FeedsFragment();
ff.initialize(cat);
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
ft.addToBackStack(null);
ft.commit();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
m_actionbarUpEnabled = true;
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
} }
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
FeedsFragment ff = new FeedsFragment();
ff.initialize(cat);
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
ft.addToBackStack(null);
ft.commit();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
m_actionbarUpEnabled = true;
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
} else { } else {
if (fc != null) { if (fc != null) {
@ -364,26 +303,15 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
} }
public void openFeedArticles(Feed feed) { public void openFeedArticles(Feed feed) {
/* if (isSmallScreen()) { GlobalState.getInstance().m_loadedArticles.clear();
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
GlobalState.getInstance().m_activeFeed = feed; Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
GlobalState.getInstance().m_loadedArticles.clear(); intent.putExtra("feed", feed);
intent.putExtra("article", (Article)null);
intent.putExtra("searchQuery", (String)null);
intent.putExtra("feed", feed); startActivityForResult(intent, HEADLINES_REQUEST);
intent.putExtra("article", new Article()); overridePendingTransition(R.anim.right_slide_in, 0);
startActivityForResult(intent, 0);
} else { */
GlobalState.getInstance().m_loadedArticles.clear();
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
intent.putExtra("feed", feed);
intent.putExtra("article", (Article)null);
intent.putExtra("searchQuery", (String)null);
startActivityForResult(intent, HEADLINES_REQUEST);
overridePendingTransition(R.anim.right_slide_in, 0);
//}
} }
public void onArticleSelected(Article article, boolean open) { public void onArticleSelected(Article article, boolean open) {
@ -395,27 +323,14 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
if (open) { if (open) {
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
/* if (isSmallScreen()) { Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
intent.putExtra("feed", hf.getFeed());
intent.putExtra("article", article);
intent.putExtra("searchQuery", hf.getSearchQuery());
//GlobalState.getInstance().m_loadedArticles.clear(); startActivityForResult(intent, HEADLINES_REQUEST);
overridePendingTransition(R.anim.right_slide_in, 0);
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
intent.putExtra("feed", hf.getFeed());
intent.putExtra("article", article);
intent.putExtra("searchQuery", hf.getSearchQuery());
startActivityForResult(intent, 0);
} else { */
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
intent.putExtra("feed", hf.getFeed());
intent.putExtra("article", article);
intent.putExtra("searchQuery", hf.getSearchQuery());
startActivityForResult(intent, HEADLINES_REQUEST);
overridePendingTransition(R.anim.right_slide_in, 0);
//}
} else { } else {
initMenu(); initMenu();
} }

View File

@ -89,15 +89,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
} }
setLoadingStatus(R.string.blank, false); setLoadingStatus(R.string.blank, false);
//findViewById(R.id.loading_container).setVisibility(View.GONE);
initMenu(); initMenu();
/* if (!isSmallScreen()) {
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
container.setWeightSum(3f);
} */
if (!isCompatMode() && !isSmallScreen()) { if (!isCompatMode() && !isSmallScreen()) {
((ViewGroup)findViewById(R.id.headlines_fragment)).setLayoutTransition(new LayoutTransition()); ((ViewGroup)findViewById(R.id.headlines_fragment)).setLayoutTransition(new LayoutTransition());
((ViewGroup)findViewById(R.id.feeds_fragment)).setLayoutTransition(new LayoutTransition()); ((ViewGroup)findViewById(R.id.feeds_fragment)).setLayoutTransition(new LayoutTransition());
@ -164,7 +158,6 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
if (m_menu != null) { if (m_menu != null) {
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS); Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS); Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
//OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
if (m_slidingMenu != null) { if (m_slidingMenu != null) {
@ -172,18 +165,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && !m_slidingMenu.isMenuShowing()); m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && !m_slidingMenu.isMenuShowing());
} else { } else {
m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded())); m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded()));
//m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isAdded());
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded()); m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded());
} }
/* m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded()));
m_menu.setGroupVisible(R.id.menu_group_article, af != null && af.isAdded());
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded()); */
//m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && getSelectedArticleCount() == 0);
//m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.isAdded() && getSelectedArticleCount() != 0);
MenuItem item = m_menu.findItem(R.id.show_feeds); MenuItem item = m_menu.findItem(R.id.show_feeds);
if (getUnreadOnly()) { if (getUnreadOnly()) {
@ -208,31 +192,24 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
onFeedSelected(catId, true, true); onFeedSelected(catId, true, true);
} else { } else {
/* if (isSmallScreen()) { if (fc != null) {
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class); fc.setSelectedFeedId(-1);
intent.putExtra("category", catId); }
startActivityForResult(intent, 0); FragmentTransaction ft = getSupportFragmentManager()
} else { */ .beginTransaction();
if (fc != null) {
fc.setSelectedFeedId(-1);
}
FragmentTransaction ft = getSupportFragmentManager() OfflineFeedsFragment ff = new OfflineFeedsFragment();
.beginTransaction(); ff.initialize(catId);
OfflineFeedsFragment ff = new OfflineFeedsFragment(); ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
ff.initialize(catId); ft.addToBackStack(null);
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ft.addToBackStack(null); m_actionbarUpEnabled = true;
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
getSupportActionBar().setDisplayHomeAsUpEnabled(true); ft.commit();
m_actionbarUpEnabled = true;
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
ft.commit();
//}
} }
} }
@ -243,54 +220,31 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
public void onFeedSelected(final int feedId, final boolean isCat, boolean open) { public void onFeedSelected(final int feedId, final boolean isCat, boolean open) {
if (open) { if (open) {
/* if (isSmallScreen()) { if (!isSmallScreen()) {
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
container.setWeightSum(3f);
}
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class); new Handler().postDelayed(new Runnable() {
intent.putExtra("feed", feedId); @Override
intent.putExtra("isCat", isCat); public void run() {
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
startActivityForResult(intent, 0); OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
hf.initialize(feedId, isCat);
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
} else { */ ft.commit();
/* if (!isCompatMode()) {
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container); if (m_slidingMenu != null) {
float wSum = container.getWeightSum(); m_slidingMenu.showContent();
if (wSum <= 2.0f) { getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ObjectAnimator anim = ObjectAnimator.ofFloat(container, "weightSum", wSum, 3.0f); m_actionbarUpEnabled = true;
anim.setDuration(200);
anim.start();
} }
} */
// ^ no idea why the animation hangs half the time :(
if (!isSmallScreen()) {
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
container.setWeightSum(3f);
} }
}, 10);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
OfflineHeadlinesFragment hf = new OfflineHeadlinesFragment();
hf.initialize(feedId, isCat);
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
ft.commit();
if (m_slidingMenu != null) {
m_slidingMenu.showContent();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
m_actionbarUpEnabled = true;
}
}
}, 10);
//}
} }
} }
@ -326,30 +280,17 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
initMenu(); initMenu();
if (open) { if (open) {
/* if (isSmallScreen()) { OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); Intent intent = new Intent(OfflineFeedsActivity.this, OfflineHeadlinesActivity.class);
intent.putExtra("feed", hf.getFeedId());
intent.putExtra("isCat", hf.getFeedIsCat());
intent.putExtra("article", articleId);
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class); startActivityForResult(intent, 0);
intent.putExtra("feed", hf.getFeedId());
intent.putExtra("isCat", hf.getFeedIsCat());
intent.putExtra("article", articleId);
startActivityForResult(intent, 0); overridePendingTransition(R.anim.right_slide_in, 0);
} else { */
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineHeadlinesActivity.class);
intent.putExtra("feed", hf.getFeedId());
intent.putExtra("isCat", hf.getFeedIsCat());
intent.putExtra("article", articleId);
startActivityForResult(intent, 0);
overridePendingTransition(R.anim.right_slide_in, 0);
//}
} else { } else {
refresh(); refresh();
} }

View File

@ -141,10 +141,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded()); m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && hf.isVisible());
//m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.getSelectedArticleCount() == 0);
//m_menu.setGroupVisible(R.id.menu_group_headlines_selection, hf != null && hf.getSelectedArticleCount() != 0);
Fragment af = getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); Fragment af = getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);