Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.07 KB | None | 0 0
  1. public class MainTabsActivity extends ScreenBaseActivity implements ActionBarHolder, NotificationsClickable {
  2. private RelativeLayout mHidedTabs;
  3. private RelativeLayout mShowMoreTabsButton;
  4. private RelativeLayout actionBar;
  5. private RelativeLayout additionalTabsContainer;
  6. private RelativeLayout backButton;
  7.  
  8. private TabWidget tabWidget;
  9.  
  10. private ImageView mShowMoreTabsIcon;
  11. private ImageView notifIcon;
  12. private ImageView openMenu;
  13. private ImageView arrowMenu;
  14.  
  15. private TextView mShowMoreTabText;
  16. private TextView mSecurity;
  17. private TextView mVideo;
  18. private TextView mContactUs;
  19. private TextView mSocial;
  20. private TextView mShare;
  21. private TextView mScreenTitle;
  22.  
  23. private TabHost mTabHost;
  24. private TabManager mTabManager;
  25. private SettingsAll settingsAll;
  26. private StorageManager manager;
  27. private TokenSubscriber subscriber;
  28. private ColorScheme colorScheme;
  29. private IconPack icon;
  30.  
  31. private String token;
  32. private static Settings settings;
  33.  
  34. public MainTabsActivity() {
  35. this.manager = new StorageManager();
  36. this.subscriber = new TokenSubscriber();
  37. this.settingsAll = NetworkDataSingleton.getInstance().getMenuSettings();
  38. this.colorScheme = settingsAll.getColorScheme();
  39. this.icon = settingsAll.getIconPack();
  40. this.settings = NetworkDataSingleton.getInstance().getSettings();
  41. setActionListener(new ScreenActionListener());
  42. }
  43.  
  44. @Override
  45. protected void onCreate(Bundle savedInstanceState) {
  46. super.onCreate(savedInstanceState);
  47. setContentView(R.layout.activity_main_tabs_container);
  48. setToken();
  49. initOnCreate();
  50. registerGCM();
  51. }
  52.  
  53. private void setToken() {
  54. if (manager.getToken(this) != null) {
  55. token = manager.getToken(this);
  56. } else {
  57. NetworkDataSingleton.getInstance().subscribeToken(subscriber);
  58. }
  59. }
  60.  
  61. private void initOnCreate() {
  62. initActionBarButton();
  63. saveUIReferences();
  64. init();
  65. initTabs();
  66. }
  67.  
  68. private void initActionBarButton() {
  69. actionBar = (RelativeLayout) findViewById(R.id.action_bar);
  70. notifIcon = (ImageView) findViewById(R.id.notif_settings);
  71. backButton = (RelativeLayout) findViewById(R.id.back_button);
  72. openMenu = (ImageView) findViewById(R.id.open_menu);
  73. arrowMenu = (ImageView) findViewById(R.id.arrow_menu);
  74. backButton.setVisibility(View.GONE);
  75.  
  76. setActionBarColors();
  77. showNotificationGroups(token);
  78. }
  79.  
  80. private void setActionBarColors() {
  81. String actionBarColor = getActionBarColor();
  82. if (actionBarColor != null){
  83. actionBar.setBackgroundColor(Color.parseColor(actionBarColor));
  84. }
  85. setMenuIconColor(arrowMenu, getMenuTextColor(), 0, false, false);
  86. setMenuIconColor(openMenu, getMenuTextColor(), 0, false, false);
  87.  
  88. setMenuIconColor(notifIcon, getMenuTextColor(), getHomeSettingsIcon(), false, false);
  89. }
  90.  
  91. private void setMenuIconColor(ImageView iv, String color, int icon, boolean isEmpty, boolean isColored){
  92. if (icon != 0 && !isEmpty){
  93. iv.setImageResource(icon);
  94. }
  95. if (color != null && !isColored){
  96. iv.setColorFilter(Color.parseColor(color));
  97. }
  98. }
  99.  
  100. private void init() {
  101. ImageView ivBg = (ImageView) findViewById(R.id.bg);
  102. AppssonApplication.getsImageLoader().displayImage(NetworkDataSingleton.getInstance().getTheme().getBackgroundImageUrl(), ivBg, AppssonApplication.getmImageOptions(true));
  103. }
  104.  
  105. private void setupTab(String tag, String name, int imgResource,
  106. Class fragmentClass) {
  107. View tabview = createTabView(name, imgResource);
  108. mTabManager.addTab(mTabHost.newTabSpec(tag).setIndicator(tabview),
  109. fragmentClass, null);
  110. }
  111.  
  112. private void setupHidedTab(String tag, Class fragmentClass) {
  113. mTabManager.addHidedTab(tag, fragmentClass, null);
  114. }
  115.  
  116. private View createTabView(String text, int imgResource) {
  117. View view = LayoutInflater.from(this).inflate(R.layout.tab_view, null);
  118. ImageView iv = (ImageView) view.findViewById(R.id.tabsIcon);
  119. iv.setImageResource(imgResource);
  120. TextView tv = (TextView) view.findViewById(R.id.tabsText);
  121.  
  122. String tabTextColor = getMenuTextColor();
  123. String tabPressedBg = getLinksBtnColor();
  124. int tabTextSize = getMenuTextFontSize();
  125.  
  126. if (!settingsAll.getIconPack().getIconType().equalsIgnoreCase(ScreenBaseActivity.ICON_TYPE_COLORED)){
  127. iv.setColorFilter(Color.parseColor(tabTextColor));
  128. }
  129. view.setBackground(makeSelector(tabPressedBg));
  130. initMenuItemTextView(tv, getMenuTypeface(), text, tabTextSize, tabTextColor, null);
  131. return view;
  132. }
  133.  
  134. public static StateListDrawable makeSelector(String color) {
  135. StateListDrawable res = new StateListDrawable();
  136. res.setExitFadeDuration(400);
  137. res.addState(new int[]{android.R.attr.state_selected}, new ColorDrawable(Color.parseColor(color)));
  138. res.addState(new int[]{}, new ColorDrawable(Color.TRANSPARENT));
  139. return res;
  140. }
  141.  
  142. @Override
  143. public void initActionBar(String title) {
  144. if (mScreenTitle != null) {
  145. int textSize = getMenuTextFontSize();
  146. String textColor = getMenuTextColor();
  147. initMenuItemTextView(mScreenTitle, getMenuTypeface(), title, textSize, textColor, null);
  148. }
  149. }
  150.  
  151. private void initMenuItemTextView(TextView tv, Typeface typeface, String title, int txtSize, String txtColor, String bg) {
  152. if (title != null) {
  153. tv.setText(title);
  154. }
  155. if (typeface != null) {
  156. tv.setTypeface(typeface);
  157. }
  158. if (txtSize != 0){
  159. tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, txtSize);
  160. }
  161. if (txtColor != null){
  162. tv.setTextColor(Color.parseColor(txtColor));
  163. }
  164. if (bg != null){
  165. tv.setBackgroundColor(Color.parseColor(bg));
  166. }
  167. }
  168.  
  169. @Override
  170. public void showNotifIcon(boolean isVisible) {
  171. if (!isVisible) {
  172. notifIcon.setVisibility(View.GONE);
  173. } else {
  174. notifIcon.setVisibility(View.VISIBLE);
  175. }
  176. }
  177.  
  178. @Override
  179. public void backClick(Fragments fragmentName) {
  180. if (fragmentName.equals(Fragments.SETTINGS)) {
  181. backButton.setVisibility(View.VISIBLE);
  182. backButton.setOnClickListener(new BackBtnListener());
  183. }
  184. if (fragmentName.equals(Fragments.NOTIFICATION)) {
  185. backButton.setVisibility(View.VISIBLE);
  186. backButton.setOnClickListener(new BackToSettings());
  187. }
  188. if (fragmentName.equals(Fragments.TW_POST) || fragmentName.equals(Fragments.FB_POST)
  189. || fragmentName.equals(Fragments.FEED_POST) || fragmentName.equals(Fragments.MANUAL_POST)){
  190. backButton.setVisibility(View.VISIBLE);
  191. backButton.setOnClickListener(new BackToNews());
  192. }
  193. }
  194.  
  195. @Override
  196. public void onConfigurationChanged(Configuration newConfig) {
  197. super.onConfigurationChanged(newConfig);
  198. if (currentFragment != Fragments.VIDEO) {
  199. if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
  200. setContentView(R.layout.main_land);
  201. findViewById(R.id.email).setOnClickListener(
  202. new AppssonEmailClickListener());
  203. } else {
  204. initOnCreate();
  205. }
  206. }
  207. }
  208.  
  209. @Override
  210. protected void onPause() {
  211. super.onPause();
  212. }
  213.  
  214. @Override
  215. protected void onResume() {
  216. super.onResume();
  217. Singleton.get_instance(this).setmCurrentActivity(this.getClass());
  218. CommonUtils.hideKeyboard(this);
  219. }
  220.  
  221. @Override
  222. protected void onNewIntent(Intent intent) {
  223. getForStartIntent(intent);
  224. super.onNewIntent(intent);
  225. }
  226.  
  227. public static class TabManager implements TabHost.OnTabChangeListener {
  228. private final FragmentActivity mActivity;
  229. private RelativeLayout hidedTabsContainer;
  230. private RelativeLayout moreButton;
  231. private ImageView moreIcon;
  232. private final TabHost mTabHost;
  233. private final int mContainerId;
  234. private RelativeLayout hideBackBtn;
  235. private final HashMap<String, TabInfo> mTabs = new HashMap<String, TabInfo>();
  236. TabInfo mLastTab;
  237.  
  238. static final class TabInfo {
  239. private final String tag;
  240. private final Class<?> clss;
  241. private final Bundle args;
  242. private Fragment fragment;
  243.  
  244. TabInfo(String _tag, Class<?> _class, Bundle _args) {
  245. tag = _tag;
  246. clss = _class;
  247. args = _args;
  248. }
  249. }
  250.  
  251. static class DummyTabFactory implements TabHost.TabContentFactory {
  252. private final Context mContext;
  253.  
  254. public DummyTabFactory(Context context) {
  255. mContext = context;
  256. }
  257.  
  258. @Override
  259. public View createTabContent(String tag) {
  260. View v = new View(mContext);
  261. v.setMinimumWidth(0);
  262. v.setMinimumHeight(0);
  263. return v;
  264. }
  265. }
  266.  
  267. public TabManager(FragmentActivity activity, TabHost tabHost,
  268. int containerId, RelativeLayout hideBackBtn) {
  269. mActivity = activity;
  270. mTabHost = tabHost;
  271. mContainerId = containerId;
  272. mTabHost.setOnTabChangedListener(this);
  273. this.hideBackBtn = hideBackBtn;
  274. }
  275.  
  276. public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
  277. tabSpec.setContent(new DummyTabFactory(mActivity));
  278. String tag = tabSpec.getTag();
  279.  
  280. TabInfo info = new TabInfo(tag, clss, args);
  281. info.fragment = mActivity.getSupportFragmentManager()
  282. .findFragmentByTag(tag);
  283. if (info.fragment != null && !info.fragment.isDetached()) {
  284. FragmentTransaction ft = mActivity.getSupportFragmentManager()
  285. .beginTransaction();
  286. ft.detach(info.fragment);
  287. ft.commit();
  288. }
  289. mTabs.put(tag, info);
  290. mTabHost.addTab(tabSpec);
  291. }
  292.  
  293. public void addHidedTab(String tag, Class<?> clss, Bundle args) {
  294. TabInfo info = new TabInfo(tag, clss, args);
  295. info.fragment = mActivity.getSupportFragmentManager()
  296. .findFragmentByTag(tag);
  297. if (info.fragment != null && !info.fragment.isDetached()) {
  298. FragmentTransaction ft = mActivity.getSupportFragmentManager()
  299. .beginTransaction();
  300. ft.detach(info.fragment);
  301. ft.commit();
  302. }
  303. mTabs.put(tag, info);
  304. }
  305.  
  306. @Override
  307. public void onTabChanged(String tabId) {
  308. hideBackBtn.setVisibility(View.GONE);
  309.  
  310. if (tabId.equalsIgnoreCase(TabItem.TAB_PREFIX + TabItem.EMPTY_MORE.ordinal())) {
  311. return;
  312. }
  313.  
  314. if (hidedTabsContainer != null) {
  315. if (hidedTabsContainer.getVisibility() == View.VISIBLE) {
  316. hidedTabsContainer.setVisibility(View.INVISIBLE);
  317. }
  318. if (!tabId.startsWith(TabHidedItem.TAB_PREFIX)) {
  319. moreIcon.clearColorFilter();
  320. SettingsAll settingsAll = NetworkDataSingleton.getInstance().getMenuSettings();
  321. ColorScheme menuColor = settingsAll.getColorScheme();
  322. if (menuColor != null && menuColor.getUseCustom()){
  323. moreButton.setBackgroundColor(Color.parseColor(menuColor.getMenuBackground()));
  324. moreIcon.setColorFilter(Color.parseColor(menuColor.getMenuText()));
  325. } else {
  326. moreButton.setBackgroundResource(R.drawable.tab_more_bg_selector);
  327. moreIcon.setColorFilter(Color.parseColor(Constants.WHITE_COLOUR));
  328. }
  329. }
  330. }
  331.  
  332. TabInfo newTab = mTabs.get(tabId);
  333. if (mLastTab != newTab) {
  334. mActivity.getSupportFragmentManager().popBackStack(null,
  335. FragmentManager.POP_BACK_STACK_INCLUSIVE);
  336. FragmentTransaction ft = mActivity.getSupportFragmentManager()
  337. .beginTransaction();
  338. if (mLastTab != null) {
  339. if (mLastTab.fragment != null) {
  340. ft.detach(mLastTab.fragment);
  341. }
  342. }
  343.  
  344. if (newTab != null) {
  345. if (newTab.fragment == null) {
  346. newTab.fragment = Fragment.instantiate(mActivity,
  347. newTab.clss.getName(), newTab.args);
  348. ft.replace(mContainerId, newTab.fragment, newTab.tag);
  349. } else {
  350. ft.attach(newTab.fragment);
  351. }
  352. }
  353. mLastTab = newTab;
  354. ft.commit();
  355. mActivity.getSupportFragmentManager()
  356. .executePendingTransactions();
  357. }
  358.  
  359. if (tabId.startsWith(TabHidedItem.TAB_PREFIX)) {
  360. mTabHost.setCurrentTab(TabItem.EMPTY_MORE.ordinal());
  361. }
  362. }
  363.  
  364. public void setHiddenTabsContainer(RelativeLayout hiddenTabsContainer) {
  365. this.hidedTabsContainer = hiddenTabsContainer;
  366. }
  367.  
  368. public void setMoreButton(RelativeLayout moreButton) {
  369. this.moreButton = moreButton;
  370. }
  371.  
  372. public void setMoreIcon(ImageView moreIcon) {
  373. this.moreIcon = moreIcon;
  374. }
  375. }
  376.  
  377. private void initTabs() {
  378. initHidedTabs(mHidedTabs);
  379. mTabHost = (TabHost) findViewById(android.R.id.tabhost);
  380. mTabHost.setup();
  381. mTabManager = new TabManager(this, mTabHost, R.id.fragment_container, backButton);
  382. mTabManager.setHiddenTabsContainer(mHidedTabs);
  383. mTabManager.setMoreButton(mShowMoreTabsButton);
  384. mTabManager.setMoreIcon(mShowMoreTabsIcon);
  385.  
  386. for (TabItem tab : TabItem.values()) {
  387. setupTab(TabItem.TAB_PREFIX + tab.ordinal(), tab.getTabTitle(this),
  388. tab.getSelector(), tab.getActionClass());
  389. }
  390. for (TabHidedItem tab : TabHidedItem.values()) {
  391. setupHidedTab(
  392. TabHidedItem.TAB_PREFIX + String.valueOf(tab.ordinal()),
  393. tab.getActionClass());
  394. }
  395. initLocation();
  396. }
  397.  
  398. private String getTabBgColor(){
  399. String color = getBgColor();
  400. if (color.equalsIgnoreCase("#000000")){
  401. color = color.replace("#", "#FF");
  402. return color;
  403. } else {
  404. return color;
  405. }
  406. }
  407.  
  408. private void initHidedTabs(RelativeLayout container) {
  409. tabWidget = (TabWidget) findViewById(android.R.id.tabs);
  410. additionalTabsContainer = (RelativeLayout) findViewById(R.id.additional_tabs_container);
  411.  
  412. mShowMoreTabsButton = (RelativeLayout) findViewById(R.id.more_button);
  413. mShowMoreTabsIcon = (ImageView) findViewById(R.id.more_icon);
  414.  
  415. additionalTabsContainer.setOnClickListener(
  416. new OnClickListener() {
  417. @Override
  418. public void onClick(View v) {
  419. showAdditionalTabs();
  420. }
  421. });
  422.  
  423. mVideo = (TextView) container.findViewById(R.id.tab_video);
  424. mContactUs = (TextView) container.findViewById(R.id.tab_contact_us);
  425. mSocial = (TextView) container.findViewById(R.id.tab_social);
  426. mShare = (TextView) container.findViewById(R.id.tab_share);
  427. mSecurity = (TextView) container.findViewById(R.id.tab_security);
  428.  
  429. String tabTextColor = getMenuTextColor();
  430. String tabBgColor = getTabBgColor();
  431. int tabTextSize = getMenuTextFontSize();
  432.  
  433. if (colorScheme != null && colorScheme.getUseCustom()){
  434. tabWidget.setBackgroundColor(Color.parseColor(tabBgColor));
  435. initMenuItemTextView(mVideo, getMenuTypeface(), settings.getMenuVideosTitle(), tabTextSize, tabTextColor, tabBgColor);
  436. initMenuItemTextView(mContactUs, getMenuTypeface(), settings.getMenuContactsTitle(), tabTextSize, tabTextColor, tabBgColor);
  437. initMenuItemTextView(mSocial, getMenuTypeface(), settings.getMenuSocialsTitle(), tabTextSize, tabTextColor, tabBgColor);
  438. initMenuItemTextView(mShare, getMenuTypeface(), settings.getMenuShareTitle(), tabTextSize, tabTextColor, tabBgColor);
  439. initMenuItemTextView(mSecurity, getMenuTypeface(), settings.getMenuSecurityTitle(), tabTextSize, tabTextColor, tabBgColor);
  440. } else {
  441. tabWidget.setBackgroundResource(R.drawable.tab_more_bg_selector);
  442. }
  443.  
  444. mShowMoreTabsButton.setOnClickListener(new OnClickListener() {
  445. @Override
  446. public void onClick(View v) {
  447. showAdditionalTabs();
  448. }
  449. });
  450.  
  451. mVideo.setOnClickListener(new OnClickListener() {
  452. @Override
  453. public void onClick(View v) {
  454. mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
  455. + TabHidedItem.VIDEO.ordinal());
  456. }
  457. });
  458.  
  459. mContactUs.setOnClickListener(new OnClickListener() {
  460. @Override
  461. public void onClick(View v) {
  462. mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
  463. + TabHidedItem.CONTACT_US.ordinal());
  464. }
  465. });
  466.  
  467. mSocial.setOnClickListener(new OnClickListener() {
  468. @Override
  469. public void onClick(View v) {
  470. mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
  471. + TabHidedItem.SOCIAL.ordinal());
  472. }
  473. });
  474.  
  475. mShare.setOnClickListener(new OnClickListener() {
  476. @Override
  477. public void onClick(View v) {
  478. mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
  479. + TabHidedItem.SHARE.ordinal());
  480. }
  481. });
  482.  
  483. if (NetworkDataSingleton.getInstance().getSettings().getEnableSecurityMenu()) {
  484. mSecurity.setVisibility(View.VISIBLE);
  485. mSecurity.setOnClickListener(new OnClickListener() {
  486. @Override
  487. public void onClick(View v) {
  488. mTabManager.onTabChanged(TabHidedItem.TAB_PREFIX
  489. + TabHidedItem.SECURITY.ordinal());
  490. }
  491. });
  492. } else {
  493. mSecurity.setVisibility(View.GONE);
  494. }
  495. }
  496.  
  497. private void showAdditionalTabs() {
  498. if (mHidedTabs.getVisibility() != View.VISIBLE) {
  499. mHidedTabs.setVisibility(View.VISIBLE);
  500. if (colorScheme != null && colorScheme.getUseCustom()){
  501. mShowMoreTabsButton.setBackgroundColor(Color.parseColor(getTabBgColor()));
  502. } else {
  503. mShowMoreTabsButton.setBackgroundResource(R.drawable.tab_more_bg_selector);
  504. }
  505. if (mTabManager.mLastTab.tag.startsWith(TabHidedItem.TAB_PREFIX)) {
  506. String ordinal = mTabManager.mLastTab.tag
  507. .substring(TabHidedItem.TAB_PREFIX.length());
  508. int or = Integer.valueOf(ordinal);
  509. TabHidedItem curTab = TabHidedItem.values()[or];
  510. if (colorScheme != null && colorScheme.getUseCustom()) {
  511. switch (curTab) {
  512. case VIDEO:
  513. mVideo.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
  514. mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
  515. mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
  516. mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
  517. mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
  518. break;
  519. case CONTACT_US:
  520. mContactUs.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
  521. mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
  522. mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
  523. mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
  524. mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
  525. break;
  526. case SOCIAL:
  527. mSocial.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
  528. mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
  529. mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
  530. mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
  531. mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
  532. break;
  533. case SHARE:
  534. mShare.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
  535. mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
  536. mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
  537. mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
  538. mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
  539. break;
  540. case SECURITY:
  541. mSecurity.setBackgroundColor(Color.parseColor(getLinksBtnColor()));
  542. mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
  543. mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
  544. mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
  545. mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
  546. break;
  547. }
  548. } else {
  549. switch (curTab) {
  550. case VIDEO:
  551. mVideo.setBackgroundResource(R.color.tab_additional_color_pre);
  552. mContactUs
  553. .setBackgroundResource(R.drawable.additional_tabs_selector);
  554. mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
  555. mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
  556. mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
  557. break;
  558. case CONTACT_US:
  559. mContactUs
  560. .setBackgroundResource(R.color.tab_additional_color_pre);
  561. mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
  562. mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
  563. mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
  564. mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
  565. break;
  566. case SOCIAL:
  567. mSocial.setBackgroundResource(R.color.tab_additional_color_pre);
  568. mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
  569. mContactUs
  570. .setBackgroundResource(R.drawable.additional_tabs_selector);
  571. mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
  572. mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
  573. break;
  574. case SHARE:
  575. mShare.setBackgroundResource(R.color.tab_additional_color_pre);
  576. mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
  577. mContactUs
  578. .setBackgroundResource(R.drawable.additional_tabs_selector);
  579. mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
  580. mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
  581. break;
  582. case SECURITY:
  583. mSecurity.setBackgroundResource(R.color.tab_additional_color_pre);
  584. mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
  585. mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
  586. mContactUs
  587. .setBackgroundResource(R.drawable.additional_tabs_selector);
  588. mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
  589. break;
  590. }
  591. }
  592. } else {
  593. if (colorScheme != null && colorScheme.getUseCustom()) {
  594. mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
  595. mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
  596. mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
  597. mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
  598. mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
  599. } else {
  600. mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
  601. mContactUs
  602. .setBackgroundResource(R.drawable.additional_tabs_selector);
  603. mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
  604. mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
  605. mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
  606. }
  607. }
  608. } else {
  609. if (!mTabManager.mLastTab.tag.startsWith(TabHidedItem.TAB_PREFIX)) {
  610. if (colorScheme != null && colorScheme.getUseCustom()){
  611. mShowMoreTabsButton.setBackgroundColor(Color.parseColor(getTabBgColor()));
  612. } else {
  613. mShowMoreTabsButton.setBackgroundResource(R.drawable.tab_more_bg_selector);
  614. }
  615. mShowMoreTabsIcon.clearColorFilter();
  616. }
  617. if (colorScheme != null && colorScheme.getUseCustom()) {
  618. mVideo.setBackgroundColor(Color.parseColor(getTabBgColor()));
  619. mContactUs.setBackgroundColor(Color.parseColor(getTabBgColor()));
  620. mSocial.setBackgroundColor(Color.parseColor(getTabBgColor()));
  621. mShare.setBackgroundColor(Color.parseColor(getTabBgColor()));
  622. mSecurity.setBackgroundColor(Color.parseColor(getTabBgColor()));
  623. } else {
  624. mVideo.setBackgroundResource(R.drawable.additional_tabs_selector);
  625. mContactUs .setBackgroundResource(R.drawable.additional_tabs_selector);
  626. mSocial.setBackgroundResource(R.drawable.additional_tabs_selector);
  627. mShare.setBackgroundResource(R.drawable.additional_tabs_selector);
  628. mSecurity.setBackgroundResource(R.drawable.additional_tabs_selector);
  629. }
  630. mHidedTabs.setVisibility(View.INVISIBLE);
  631. }
  632. }
  633.  
  634. private void saveUIReferences() {
  635. mScreenTitle = (TextView) findViewById(R.id.action_bar_title);
  636. mHidedTabs = (RelativeLayout) findViewById(R.id.additional_tabs_container);
  637. }
  638.  
  639. private final class AppssonEmailClickListener implements OnClickListener {
  640.  
  641. @Override
  642. public void onClick(View arg0) {
  643. CommonUtils.sendEmail(MainTabsActivity.this, getString(R.string.appsson_email),
  644. getString(R.string.app_creation_request), getString(R.string.hello));
  645. }
  646. }
  647.  
  648. private class ScreenActionListener implements OnActionListener {
  649. @Override
  650. public void onOpenPageAction(int pageName) {
  651.  
  652. }
  653. }
  654.  
  655. protected boolean checkPlayServices() {
  656. GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
  657. int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
  658. if (resultCode != ConnectionResult.SUCCESS) {
  659. Log.d("push_test", "UNsuccess connection");
  660. if (apiAvailability.isUserResolvableError(resultCode)) {
  661. apiAvailability.getErrorDialog(this, resultCode, 9000)
  662. .show();
  663. } else {
  664. Log.i("MainSliderActivity", "This device is not supported.");
  665. }
  666. return false;
  667. }
  668. return true;
  669. }
  670.  
  671. private void showNotificationGroups(String token) {
  672. RestApiManager apiManager = new RestApiManager(ConstantsOfCompany.COMPANY_ALIAS);
  673. apiManager.getNotificationSettingsAsync(token, new Callback<List<NotificationGroups>>() {
  674. @Override
  675. public void success(List<NotificationGroups> notificationGroupses, Response response) {
  676. if (notificationGroupses != null && !notificationGroupses.isEmpty()) {
  677. notifIcon.setVisibility(View.VISIBLE);
  678. notifIcon.setOnClickListener(new NotificationClickListener());
  679. } else {
  680. notifIcon.setVisibility(View.GONE);
  681. }
  682. }
  683.  
  684. @Override
  685. public void failure(RetrofitError error) {
  686. Log.d("push_test", "push_test");
  687. }
  688. });
  689. }
  690.  
  691. protected class TokenSubscriber implements RegistrationIntentService.TokenObserver {
  692.  
  693. @Override
  694. public void update(String token) {
  695. showNotificationGroups(token);
  696. }
  697. }
  698.  
  699. private class NotificationClickListener implements OnClickListener {
  700. @Override
  701. public void onClick(View v) {
  702. FragmentTransaction ft = getSupportFragmentManager()
  703. .beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).addToBackStack(MainTabsActivity.this.getClass().getName());
  704. ft.commit();
  705. }
  706. }
  707.  
  708. private final class BackBtnListener implements OnClickListener {
  709.  
  710. @Override
  711. public void onClick(View v) {
  712. FragmentTransaction ft = getSupportFragmentManager()
  713. .beginTransaction().replace(R.id.fragment_container, new HomeFragment());
  714. ft.commit();
  715. backButton.setVisibility(View.GONE);
  716. }
  717. }
  718.  
  719. private class BackToSettings implements OnClickListener {
  720.  
  721. @Override
  722. public void onClick(View v) {
  723. FragmentTransaction ft = getSupportFragmentManager()
  724. .beginTransaction().replace(R.id.fragment_container, new SettingsFragment());
  725. ft.commit();
  726. }
  727. }
  728.  
  729. private class BackToNews implements View.OnClickListener {
  730.  
  731. @Override
  732. public void onClick(View v) {
  733. backButton.setVisibility(View.GONE);
  734. FragmentManager manager = getSupportFragmentManager();
  735. BaseFragment frag = (BaseFragment) manager.findFragmentById(R.id.fragment_container);
  736. if (frag != null) {
  737. frag.onBack();
  738. }
  739. }
  740. }
  741. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement