Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainTabsActivity extends ScreenBaseActivity implements ActionBarHolder, NotificationsClickable {
- private RelativeLayout mHidedTabs;
- private RelativeLayout mShowMoreTabsButton;
- private RelativeLayout actionBar;
- private RelativeLayout additionalTabsContainer;
- private RelativeLayout backButton;
- private TabWidget tabWidget;
- private ImageView mShowMoreTabsIcon;
- private ImageView notifIcon;
- private ImageView openMenu;
- private ImageView arrowMenu;
- private TextView mShowMoreTabText;
- private TextView mSecurity;
- private TextView mVideo;
- private TextView mContactUs;
- private TextView mSocial;
- private TextView mShare;
- private TextView mScreenTitle;
- private TabHost mTabHost;
- private TabManager mTabManager;
- private SettingsAll settingsAll;
- private StorageManager manager;
- private TokenSubscriber subscriber;
- private ColorScheme colorScheme;
- private IconPack icon;
- private String token;
- private static Settings settings;
- public MainTabsActivity() {
- this.manager = new StorageManager();
- this.subscriber = new TokenSubscriber();
- this.settingsAll = NetworkDataSingleton.getInstance().getMenuSettings();
- this.colorScheme = settingsAll.getColorScheme();
- this.icon = settingsAll.getIconPack();
- this.settings = NetworkDataSingleton.getInstance().getSettings();
- setActionListener(new ScreenActionListener());
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main_tabs_container);
- setToken();
- initOnCreate();
- registerGCM();
- }
- private void setToken() {
- if (manager.getToken(this) != null) {
- token = manager.getToken(this);
- } else {
- NetworkDataSingleton.getInstance().subscribeToken(subscriber);
- }
- }
- private void initOnCreate() {
- initActionBarButton();
- saveUIReferences();
- init();
- initTabs();
- }
- private void initActionBarButton() {
- actionBar = (RelativeLayout) findViewById(R.id.action_bar);
- notifIcon = (ImageView) findViewById(R.id.notif_settings);
- backButton = (RelativeLayout) findViewById(R.id.back_button);
- openMenu = (ImageView) findViewById(R.id.open_menu);
- arrowMenu = (ImageView) findViewById(R.id.arrow_menu);
- backButton.setVisibility(View.GONE);
- setActionBarColors();
- showNotificationGroups(token);
- }
- private void setActionBarColors() {
- String actionBarColor = getActionBarColor();
- if (actionBarColor != null){
- actionBar.setBackgroundColor(Color.parseColor(actionBarColor));
- }
- setMenuIconColor(arrowMenu, getMenuTextColor(), 0, false, false);
- setMenuIconColor(openMenu, getMenuTextColor(), 0, false, false);
- setMenuIconColor(notifIcon, getMenuTextColor(), getHomeSettingsIcon(), false, false);
- }
- private void setMenuIconColor(ImageView iv, String color, int icon, boolean isEmpty, boolean isColored){
- if (icon != 0 && !isEmpty){
- iv.setImageResource(icon);
- }
- if (color != null && !isColored){
- iv.setColorFilter(Color.parseColor(color));
- }
- }
- private void init() {
- ImageView ivBg = (ImageView) findViewById(R.id.bg);
- AppssonApplication.getsImageLoader().displayImage(NetworkDataSingleton.getInstance().getTheme().getBackgroundImageUrl(), ivBg, AppssonApplication.getmImageOptions(true));
- }
- private void setupTab(String tag, String name, int imgResource,
- Class fragmentClass) {
- View tabview = createTabView(name, imgResource);
- mTabManager.addTab(mTabHost.newTabSpec(tag).setIndicator(tabview),
- fragmentClass, null);
- }
- private void setupHidedTab(String tag, Class fragmentClass) {
- mTabManager.addHidedTab(tag, fragmentClass, null);
- }
- private View createTabView(String text, int imgResource) {
- View view = LayoutInflater.from(this).inflate(R.layout.tab_view, null);
- ImageView iv = (ImageView) view.findViewById(R.id.tabsIcon);
- iv.setImageResource(imgResource);
- TextView tv = (TextView) view.findViewById(R.id.tabsText);
- String tabTextColor = getMenuTextColor();
- String tabPressedBg = getLinksBtnColor();
- int tabTextSize = getMenuTextFontSize();
- if (!settingsAll.getIconPack().getIconType().equalsIgnoreCase(ScreenBaseActivity.ICON_TYPE_COLORED)){
- iv.setColorFilter(Color.parseColor(tabTextColor));
- }
- view.setBackground(makeSelector(tabPressedBg));
- initMenuItemTextView(tv, getMenuTypeface(), text, tabTextSize, tabTextColor, null);
- return view;
- }
- public static StateListDrawable makeSelector(String color) {
- StateListDrawable res = new StateListDrawable();
- res.setExitFadeDuration(400);
- res.addState(new int[]{android.R.attr.state_selected}, new ColorDrawable(Color.parseColor(color)));
- res.addState(new int[]{}, new ColorDrawable(Color.TRANSPARENT));
- return res;
- }
- @Override
- public void initActionBar(String title) {
- if (mScreenTitle != null) {
- int textSize = getMenuTextFontSize();
- String textColor = getMenuTextColor();
- initMenuItemTextView(mScreenTitle, getMenuTypeface(), title, textSize, textColor, null);
- }
- }
- private void initMenuItemTextView(TextView tv, Typeface typeface, String title, int txtSize, String txtColor, String bg) {
- if (title != null) {
- tv.setText(title);
- }
- if (typeface != null) {
- tv.setTypeface(typeface);
- }
- if (txtSize != 0){
- tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, txtSize);
- }
- if (txtColor != null){
- tv.setTextColor(Color.parseColor(txtColor));
- }
- if (bg != null){
- tv.setBackgroundColor(Color.parseColor(bg));
- }
- }
- @Override
- public void showNotifIcon(boolean isVisible) {
- if (!isVisible) {
- notifIcon.setVisibility(View.GONE);
- } else {
- notifIcon.setVisibility(View.VISIBLE);
- }
- }
- @Override
- public void backClick(Fragments fragmentName) {
- if (fragmentName.equals(Fragments.SETTINGS)) {
- backButton.setVisibility(View.VISIBLE);
- backButton.setOnClickListener(new BackBtnListener());
- }
- if (fragmentName.equals(Fragments.NOTIFICATION)) {
- backButton.setVisibility(View.VISIBLE);
- backButton.setOnClickListener(new BackToSettings());
- }
- if (fragmentName.equals(Fragments.TW_POST) || fragmentName.equals(Fragments.FB_POST)
- || fragmentName.equals(Fragments.FEED_POST) || fragmentName.equals(Fragments.MANUAL_POST)){
- backButton.setVisibility(View.VISIBLE);
- backButton.setOnClickListener(new BackToNews());
- }
- }
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- if (currentFragment != Fragments.VIDEO) {
- if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- setContentView(R.layout.main_land);
- findViewById(R.id.email).setOnClickListener(
- new AppssonEmailClickListener());
- } else {
- initOnCreate();
- }
- }
- }
- @Override
- protected void onPause() {
- super.onPause();
- }
- @Override
- protected void onResume() {
- super.onResume();
- Singleton.get_instance(this).setmCurrentActivity(this.getClass());
- CommonUtils.hideKeyboard(this);
- }
- @Override
- protected void onNewIntent(Intent intent) {
- getForStartIntent(intent);
- super.onNewIntent(intent);
- }
- public static class TabManager implements TabHost.OnTabChangeListener {
- private final FragmentActivity mActivity;
- private RelativeLayout hidedTabsContainer;
- private RelativeLayout moreButton;
- private ImageView moreIcon;
- private final TabHost mTabHost;
- private final int mContainerId;
- private RelativeLayout hideBackBtn;
- private final HashMap<String, TabInfo> mTabs = new HashMap<String, TabInfo>();
- TabInfo mLastTab;
- static final class TabInfo {
- private final String tag;
- private final Class<?> clss;
- private final Bundle args;
- private Fragment fragment;
- TabInfo(String _tag, Class<?> _class, Bundle _args) {
- tag = _tag;
- clss = _class;
- args = _args;
- }
- }
- static class DummyTabFactory implements TabHost.TabContentFactory {
- private final Context mContext;
- public DummyTabFactory(Context context) {
- mContext = context;
- }
- @Override
- public View createTabContent(String tag) {
- View v = new View(mContext);
- v.setMinimumWidth(0);
- v.setMinimumHeight(0);
- return v;
- }
- }
- public TabManager(FragmentActivity activity, TabHost tabHost,
- int containerId, RelativeLayout hideBackBtn) {
- mActivity = activity;
- mTabHost = tabHost;
- mContainerId = containerId;
- mTabHost.setOnTabChangedListener(this);
- this.hideBackBtn = hideBackBtn;
- }
- public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
- tabSpec.setContent(new DummyTabFactory(mActivity));
- String tag = tabSpec.getTag();
- TabInfo info = new TabInfo(tag, clss, args);
- info.fragment = mActivity.getSupportFragmentManager()
- .findFragmentByTag(tag);
- if (info.fragment != null && !info.fragment.isDetached()) {
- FragmentTransaction ft = mActivity.getSupportFragmentManager()
- .beginTransaction();
- ft.detach(info.fragment);
- ft.commit();
- }
- mTabs.put(tag, info);
- mTabHost.addTab(tabSpec);
- }
- public void addHidedTab(String tag, Class<?> clss, Bundle args) {
- TabInfo info = new TabInfo(tag, clss, args);
- info.fragment = mActivity.getSupportFragmentManager()
- .findFragmentByTag(tag);
- if (info.fragment != null && !info.fragment.isDetached()) {
- FragmentTransaction ft = mActivity.getSupportFragmentManager()
- .beginTransaction();
- ft.detach(info.fragment);
- ft.commit();
- }
- mTabs.put(tag, info);
- }
- @Override
- public void onTabChanged(String tabId) {
- hideBackBtn.setVisibility(View.GONE);
- if (tabId.equalsIgnoreCase(TabItem.TAB_PREFIX + TabItem.EMPTY_MORE.ordinal())) {
- return;
- }
- if (hidedTabsContainer != null) {
- if (hidedTabsContainer.getVisibility() == View.VISIBLE) {
- hidedTabsContainer.setVisibility(View.INVISIBLE);
- }
- if (!tabId.startsWith(TabHidedItem.TAB_PREFIX)) {
- moreIcon.clearColorFilter();
- SettingsAll settingsAll = NetworkDataSingleton.getInstance().getMenuSettings();
- ColorScheme menuColor = settingsAll.getColorScheme();
- if (menuColor != null && menuColor.getUseCustom()){
- moreButton.setBackgroundColor(Color.parseColor(menuColor.getMenuBackground()));
- moreIcon.setColorFilter(Color.parseColor(menuColor.getMenuText()));
- } else {
- moreButton.setBackgroundResource(R.drawable.tab_more_bg_selector);
- moreIcon.setColorFilter(Color.parseColor(Constants.WHITE_COLOUR));
- }
- }
- }
- TabInfo newTab = mTabs.get(tabId);
- if (mLastTab != newTab) {
- mActivity.getSupportFragmentManager().popBackStack(null,
- FragmentManager.POP_BACK_STACK_INCLUSIVE);
- FragmentTransaction ft = mActivity.getSupportFragmentManager()
- .beginTransaction();
- if (mLastTab != null) {
- if (mLastTab.fragment != null) {
- ft.detach(mLastTab.fragment);
- }
- }
- if (newTab != null) {
- if (newTab.fragment == null) {
- newTab.fragment = Fragment.instantiate(mActivity,
- newTab.clss.getName(), newTab.args);
- ft.replace(mContainerId, newTab.fragment, newTab.tag);
- } else {
- ft.attach(newTab.fragment);
- }
- }
- mLastTab = newTab;
- ft.commit();
- mActivity.getSupportFragmentManager()
- .executePendingTransactions();
- }
- if (tabId.startsWith(TabHidedItem.TAB_PREFIX)) {
- mTabHost.setCurrentTab(TabItem.EMPTY_MORE.ordinal());
- }
- }
- public void setHiddenTabsContainer(RelativeLayout hiddenTabsContainer) {
- this.hidedTabsContainer = hiddenTabsContainer;
- }
- public void setMoreButton(RelativeLayout moreButton) {
- this.moreButton = moreButton;
- }
- public void setMoreIcon(ImageView moreIcon) {
- this.moreIcon = moreIcon;
- }
- }
- private void initTabs() {
- initHidedTabs(mHidedTabs);
- mTabHost = (TabHost) findViewById(android.R.id.tabhost);
- mTabHost.setup();
- mTabManager = new TabManager(this, mTabHost, R.id.fragment_container, backButton);
- mTabManager.setHiddenTabsContainer(mHidedTabs);
- mTabManager.setMoreButton(mShowMoreTabsButton);
- mTabManager.setMoreIcon(mShowMoreTabsIcon);
- for (TabItem tab : TabItem.values()) {
- setupTab(TabItem.TAB_PREFIX + tab.ordinal(), tab.getTabTitle(this),
- tab.getSelector(), tab.getActionClass());
- }
- for (TabHidedItem tab : TabHidedItem.values()) {
- setupHidedTab(
- TabHidedItem.TAB_PREFIX + String.valueOf(tab.ordinal()),
- tab.getActionClass());
- }
- initLocation();
- }
- private String getTabBgColor(){
- String color = getBgColor();
- if (color.equalsIgnoreCase("#000000")){
- color = color.replace("#", "#FF");
- return color;
- } else {
- return color;
- }
- }
- private void initHidedTabs(RelativeLayout container) {
- tabWidget = (TabWidget) findViewById(android.R.id.tabs);
- additionalTabsContainer = (RelativeLayout) findViewById(R.id.additional_tabs_container);
- mShowMoreTabsButton = (RelativeLayout) findViewById(R.id.more_button);
- mShowMoreTabsIcon = (ImageView) findViewById(R.id.more_icon);
- additionalTabsContainer.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- showAdditionalTabs();
- }
- });
- mVideo = (TextView) container.findViewById(R.id.tab_video);
- mContactUs = (TextView) container.findViewById(R.id.tab_contact_us);
- mSocial = (TextView) container.findViewById(R.id.tab_social);
- mShare = (TextView) container.findViewById(R.id.tab_share);
- mSecurity = (TextView) container.findViewById(R.id.tab_security);
- String tabTextColor = getMenuTextColor();
- String tabBgColor = getTabBgColor();
- int tabTextSize = getMenuTextFontSize();
- if (colorScheme != null && colorScheme.getUseCustom()){
- tabWidget.setBackgroundColor(Color.parseColor(tabBgColor));
- initMenuItemTextView(mVideo, getMenuTypeface(), settings.getMenuVideosTitle(), tabTextSize, tabTextColor, tabBgColor);
- initMenuItemTextView(mContactUs, getMenuTypeface(), settings.getMenuContactsTitle(), tabTextSize, tabTextColor, tabBgColor);
- initMenuItemTextView(mSocial, getMenuTypeface(), settings.getMenuSocialsTitle(), tabTextSize, tabTextColor, tabBgColor);
- initMenuItemTextView(mShare, getMenuTypeface(), settings.getMenuShareTitle(), tabTextSize, tabTextColor, tabBgColor);
- initMenuItemTextView(mSecurity, getMenuTypeface(), settings.getMenuSecurityTitle(), tabTextSize, tabTextColor, tabBgColor);
- } else {
- tabWidget.setBackgroundResource(R.drawable.tab_more_bg_selector);
- }
- mShowMoreTabsButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- showAdditionalTabs();
- }
- });
- mVideo.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
- + TabHidedItem.VIDEO.ordinal());
- }
- });
- mContactUs.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
- + TabHidedItem.CONTACT_US.ordinal());
- }
- });
- mSocial.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
- + TabHidedItem.SOCIAL.ordinal());
- }
- });
- mShare.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
- + TabHidedItem.SHARE.ordinal());
- }
- });
- if (NetworkDataSingleton.getInstance().getSettings().getEnableSecurityMenu()) {
- mSecurity.setVisibility(View.VISIBLE);
- mSecurity.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
- + TabHidedItem.SECURITY.ordinal());
- }
- });
- } else {
- mSecurity.setVisibility(View.GONE);
- }
- }
- private void showAdditionalTabs() {
- if (mHidedTabs.getVisibility() != View.VISIBLE) {
- mHidedTabs.setVisibility(View.VISIBLE);
- if (colorScheme != null && colorScheme.getUseCustom()){
- mShowMoreTabsButton.setBackgroundColor(Color.parseColor(getTabBgColor()));
- } else {
- mShowMoreTabsButton.setBackgroundResource(R.drawable.tab_more_bg_selector);
- }
- if (mTabManager.mLastTab.tag.startsWith(TabHidedItem.TAB_PREFIX)) {
- String ordinal = mTabManager.mLastTab.tag
- .substring(TabHidedItem.TAB_PREFIX.length());
- int or = Integer.valueOf(ordinal);
- TabHidedItem curTab = TabHidedItem.values()[or];
- if (colorScheme != null && colorScheme.getUseCustom()) {
- switch (curTab) {
- case VIDEO:
- mVideo.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
- mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
- break;
- case CONTACT_US:
- mContactUs.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
- mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
- break;
- case SOCIAL:
- mSocial.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
- mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
- break;
- case SHARE:
- mShare.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
- mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
- break;
- case SECURITY:
- mSecurity.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
- mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
- break;
- }
- } else {
- switch (curTab) {
- case VIDEO:
- mVideo.setBackgroundResource(R.color.tab_additional_color_pre);
- mContactUs
- .setBackgroundResource(R.drawable.additional_tabs_selector);
- mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
- mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
- mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
- break;
- case CONTACT_US:
- mContactUs
- .setBackgroundResource(R.color.tab_additional_color_pre);
- mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
- mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
- mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
- mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
- break;
- case SOCIAL:
- mSocial.setBackgroundResource(R.color.tab_additional_color_pre);
- mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
- mContactUs
- .setBackgroundResource(R.drawable.additional_tabs_selector);
- mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
- mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
- break;
- case SHARE:
- mShare.setBackgroundResource(R.color.tab_additional_color_pre);
- mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
- mContactUs
- .setBackgroundResource(R.drawable.additional_tabs_selector);
- mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
- mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
- break;
- case SECURITY:
- mSecurity.setBackgroundResource(R.color.tab_additional_color_pre);
- mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
- mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
- mContactUs
- .setBackgroundResource(R.drawable.additional_tabs_selector);
- mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
- break;
- }
- }
- } else {
- if (colorScheme != null && colorScheme.getUseCustom()) {
- mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
- } else {
- mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
- mContactUs
- .setBackgroundResource(R.drawable.additional_tabs_selector);
- mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
- mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
- mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
- }
- }
- } else {
- if (!mTabManager.mLastTab.tag.startsWith(TabHidedItem.TAB_PREFIX)) {
- if (colorScheme != null && colorScheme.getUseCustom()){
- mShowMoreTabsButton.setBackgroundColor(Color.parseColor(getTabBgColor()));
- } else {
- mShowMoreTabsButton.setBackgroundResource(R.drawable.tab_more_bg_selector);
- }
- mShowMoreTabsIcon.clearColorFilter();
- }
- if (colorScheme != null && colorScheme.getUseCustom()) {
- mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
- mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
- } else {
- mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
- mContactUs .setBackgroundResource(R.drawable.additional_tabs_selector);
- mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
- mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
- mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
- }
- mHidedTabs.setVisibility(View.INVISIBLE);
- }
- }
- private void saveUIReferences() {
- mScreenTitle = (TextView) findViewById(R.id.action_bar_title);
- mHidedTabs = (RelativeLayout) findViewById(R.id.additional_tabs_container);
- }
- private final class AppssonEmailClickListener implements OnClickListener {
- @Override
- public void onClick(View arg0) {
- CommonUtils.sendEmail(MainTabsActivity.this, getString(R.string.appsson_email),
- getString(R.string.app_creation_request), getString(R.string.hello));
- }
- }
- private class ScreenActionListener implements OnActionListener {
- @Override
- public void onOpenPageAction(int pageName) {
- }
- }
- protected boolean checkPlayServices() {
- GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
- int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
- if (resultCode != ConnectionResult.SUCCESS) {
- Log.d("push_test", "UNsuccess connection");
- if (apiAvailability.isUserResolvableError(resultCode)) {
- apiAvailability.getErrorDialog(this, resultCode, 9000)
- .show();
- } else {
- Log.i("MainSliderActivity", "This device is not supported.");
- }
- return false;
- }
- return true;
- }
- private void showNotificationGroups(String token) {
- RestApiManager apiManager = new RestApiManager(ConstantsOfCompany.COMPANY_ALIAS);
- apiManager.getNotificationSettingsAsync(token, new Callback<List<NotificationGroups>>() {
- @Override
- public void success(List<NotificationGroups> notificationGroupses, Response response) {
- if (notificationGroupses != null && !notificationGroupses.isEmpty()) {
- notifIcon.setVisibility(View.VISIBLE);
- notifIcon.setOnClickListener(new NotificationClickListener());
- } else {
- notifIcon.setVisibility(View.GONE);
- }
- }
- @Override
- public void failure(RetrofitError error) {
- Log.d("push_test", "push_test");
- }
- });
- }
- protected class TokenSubscriber implements RegistrationIntentService.TokenObserver {
- @Override
- public void update(String token) {
- showNotificationGroups(token);
- }
- }
- private class NotificationClickListener implements OnClickListener {
- @Override
- public void onClick(View v) {
- FragmentTransaction ft = getSupportFragmentManager()
- .beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).addToBackStack(MainTabsActivity.this.getClass().getName());
- ft.commit();
- }
- }
- private final class BackBtnListener implements OnClickListener {
- @Override
- public void onClick(View v) {
- FragmentTransaction ft = getSupportFragmentManager()
- .beginTransaction().replace(R.id.fragment_container, new HomeFragment());
- ft.commit();
- backButton.setVisibility(View.GONE);
- }
- }
- private class BackToSettings implements OnClickListener {
- @Override
- public void onClick(View v) {
- FragmentTransaction ft = getSupportFragmentManager()
- .beginTransaction().replace(R.id.fragment_container, new SettingsFragment());
- ft.commit();
- }
- }
- private class BackToNews implements View.OnClickListener {
- @Override
- public void onClick(View v) {
- backButton.setVisibility(View.GONE);
- FragmentManager manager = getSupportFragmentManager();
- BaseFragment frag = (BaseFragment) manager.findFragmentById(R.id.fragment_container);
- if (frag != null) {
- frag.onBack();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement