Guest User

Untitled

a guest
Apr 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
  2. .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.iconcrossroadscwhite))
  3. .setSmallIcon(R.drawable.iconcrossroadscwhite)
  4. .setContentTitle(messageTitle)
  5. .setContentText(messageBody)
  6. .setAutoCancel(true)
  7. .setSound(defaultSoundUri);
  8.  
  9.  
  10. Intent notificationIntent = null;
  11.  
  12. if(tag.equals("acceptBidNotification"))
  13. {
  14. notificationIntent = new Intent(MyFirebaseMessagingService.this, SplashScreen.class);
  15. notificationIntent.putExtra("menuFragment", "myJobsFragment");
  16. notificationIntent.putExtra("tabView", "Active");
  17. }
  18. else if(tag.equals("newBidNotification"))
  19. {
  20. notificationIntent = new Intent(MyFirebaseMessagingService.this, SplashScreen.class);
  21. notificationIntent.putExtra("menuFragment", "myAdvertsFragment");
  22. notificationIntent.putExtra("tabView", "Pending");
  23. }
  24. else if(tag.equals("jobCompletedNotification"))
  25. {
  26. notificationIntent = new Intent(MyFirebaseMessagingService.this, SplashScreen.class);
  27. notificationIntent.putExtra("menuFragment", "myAdvertsFragment");
  28. notificationIntent.putExtra("tabView", "Completed");
  29. }
  30.  
  31. PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  32.  
  33. notificationBuilder.setContentIntent(pendingIntent);
  34. NotificationManager notificationManager =
  35. (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  36.  
  37.  
  38.  
  39. notificationManager.notify(count, notificationBuilder.build());
  40. count++;
  41.  
  42. public class SplashScreen extends AppCompatActivity {
  43.  
  44.  
  45. private GifImageView gifImageView;
  46. private String menuFragment, tabView;
  47. private Bundle newBundle;
  48.  
  49.  
  50. @Override
  51. protected void onCreate(Bundle savedInstanceState) {
  52. super.onCreate(savedInstanceState);
  53. setContentView(R.layout.activity_splash_screen);
  54.  
  55. Bundle bundle = getIntent().getExtras();
  56. if(bundle != null)
  57. {
  58. menuFragment = bundle.getString("menuFragment");
  59. tabView = bundle.getString("tabView");
  60. }
  61.  
  62. gifImageView = (GifImageView)findViewById(R.id.gifImageView);
  63.  
  64.  
  65. try{
  66. InputStream inputStream = getAssets().open("crossroadssplash.gif");
  67. byte[] bytes = IOUtils.toByteArray(inputStream);
  68. gifImageView.setBytes(bytes);
  69. gifImageView.startAnimation();
  70. }
  71. catch (IOException ex)
  72. {
  73.  
  74. }
  75.  
  76. new Handler().postDelayed(new Runnable() {
  77. public void run() {
  78. if(menuFragment != null && tabView != null)
  79. {
  80. if(menuFragment.equals("myJobsFragment"))
  81. {
  82. newBundle = new Bundle();
  83. newBundle.putString("tabView", tabView);
  84. MyJobsFragment myJobsFragment = new MyJobsFragment();
  85. myJobsFragment.setArguments(newBundle);
  86. getFragmentTransaction().replace(R.id.content, myJobsFragment).commit();
  87.  
  88. }
  89. else if(menuFragment.equals("myAdvertsFragment"))
  90. {
  91. newBundle = new Bundle();
  92. newBundle.putString("tabView", tabView);
  93. MyAdvertsFragment myAdvertsFragment = new MyAdvertsFragment();
  94. myAdvertsFragment.setArguments(newBundle);
  95. getFragmentTransaction().replace(R.id.content, myAdvertsFragment).commit();
  96. }
  97. }
  98. else {
  99. SplashScreen.this.startActivity(new Intent(SplashScreen.this, LoginActivity.class));
  100. SplashScreen.this.finish();
  101. }
  102. }
  103. }, 7000);
  104. }
  105. private FragmentTransaction getFragmentTransaction()
  106. {
  107. final android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
  108. FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  109.  
  110. return fragmentTransaction;
  111. }
  112.  
  113. }
Add Comment
Please, Sign In to add comment