adjust headlines left padding in vertical mode on tablets

add getOrientation()
This commit is contained in:
Andrew Dolgov 2012-06-22 17:16:43 +04:00
parent fafdd4120a
commit fbb131fa0c
6 changed files with 19 additions and 13 deletions

View File

@ -145,7 +145,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
//list.setEmptyView(view.findViewById(R.id.no_headlines));
registerForContextMenu(list);
if (m_onlineServices.isSmallScreen())
if (m_onlineServices.isSmallScreen() || m_onlineServices.getOrientation() % 2 != 0)
view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
Log.d(TAG, "onCreateView, feed=" + m_feed);

View File

@ -444,6 +444,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
return m_smallScreenMode;
}
@Override
public int getOrientation() {
return getWindowManager().getDefaultDisplay().getOrientation();
}
@Override
public void onCreate(Bundle savedInstanceState) {
initDatabase();
@ -510,9 +515,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (!m_compatMode) {
if (!m_smallScreenMode) {
int orientation = getWindowManager().getDefaultDisplay().getOrientation();
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticle != null && orientation % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticle != null && getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(m_selectedArticle != null ? View.VISIBLE : View.GONE);
}
@ -1730,13 +1733,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES));
ft.add(R.id.fragment_container, frag, FRAG_ARTICLE);
} else {
int orientation = getWindowManager().getDefaultDisplay().getOrientation();
findViewById(R.id.feeds_fragment).setVisibility(orientation % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.feeds_fragment).setVisibility(getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
ft.replace(R.id.article_fragment, frag, FRAG_ARTICLE);
if (orientation % 2 == 0) refresh();
if (getOrientation() % 2 == 0) refresh();
}
ft.commit();
}

View File

@ -28,6 +28,7 @@ public interface OnlineServices {
public boolean getUnreadOnly();
public int getApiLevel();
public void setSelectedArticle(Article article);
public int getOrientation();
public void copyToClipboard(String str);
}

View File

@ -149,9 +149,7 @@ public class OfflineActivity extends FragmentActivity implements
if (!m_compatMode) {
if (!m_smallScreenMode) {
int orientation = getWindowManager().getDefaultDisplay().getOrientation();
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticleId != 0 && orientation % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticleId != 0 && getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(m_selectedArticleId != 0 ? View.VISIBLE : View.GONE);
}
@ -1300,4 +1298,9 @@ public class OfflineActivity extends FragmentActivity implements
public boolean activeFeedIsCat() {
return m_activeFeedIsCat;
}
@Override
public int getOrientation() {
return getWindowManager().getDefaultDisplay().getOrientation();
}
}

View File

@ -149,7 +149,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
list.setEmptyView(view.findViewById(R.id.no_headlines));
registerForContextMenu(list);
if (m_offlineServices.isSmallScreen())
if (m_offlineServices.isSmallScreen() || m_offlineServices.getOrientation() % 2 != 0)
view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
getActivity().setProgressBarIndeterminateVisibility(false);

View File

@ -18,4 +18,5 @@ public interface OfflineServices {
public boolean isSmallScreen();
public void setSelectedArticleId(int articleId);
public boolean activeFeedIsCat();
public int getOrientation();
}