Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
- .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.iconcrossroadscwhite))
- .setSmallIcon(R.drawable.iconcrossroadscwhite)
- .setContentTitle(messageTitle)
- .setContentText(messageBody)
- .setAutoCancel(true)
- .setSound(defaultSoundUri);
- Intent notificationIntent = null;
- if(tag.equals("acceptBidNotification"))
- {
- notificationIntent = new Intent(MyFirebaseMessagingService.this, SplashScreen.class);
- notificationIntent.putExtra("menuFragment", "myJobsFragment");
- notificationIntent.putExtra("tabView", "Active");
- }
- else if(tag.equals("newBidNotification"))
- {
- notificationIntent = new Intent(MyFirebaseMessagingService.this, SplashScreen.class);
- notificationIntent.putExtra("menuFragment", "myAdvertsFragment");
- notificationIntent.putExtra("tabView", "Pending");
- }
- else if(tag.equals("jobCompletedNotification"))
- {
- notificationIntent = new Intent(MyFirebaseMessagingService.this, SplashScreen.class);
- notificationIntent.putExtra("menuFragment", "myAdvertsFragment");
- notificationIntent.putExtra("tabView", "Completed");
- }
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- notificationBuilder.setContentIntent(pendingIntent);
- NotificationManager notificationManager =
- (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(count, notificationBuilder.build());
- count++;
- public class SplashScreen extends AppCompatActivity {
- private GifImageView gifImageView;
- private String menuFragment, tabView;
- private Bundle newBundle;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_splash_screen);
- Bundle bundle = getIntent().getExtras();
- if(bundle != null)
- {
- menuFragment = bundle.getString("menuFragment");
- tabView = bundle.getString("tabView");
- }
- gifImageView = (GifImageView)findViewById(R.id.gifImageView);
- try{
- InputStream inputStream = getAssets().open("crossroadssplash.gif");
- byte[] bytes = IOUtils.toByteArray(inputStream);
- gifImageView.setBytes(bytes);
- gifImageView.startAnimation();
- }
- catch (IOException ex)
- {
- }
- new Handler().postDelayed(new Runnable() {
- public void run() {
- if(menuFragment != null && tabView != null)
- {
- if(menuFragment.equals("myJobsFragment"))
- {
- newBundle = new Bundle();
- newBundle.putString("tabView", tabView);
- MyJobsFragment myJobsFragment = new MyJobsFragment();
- myJobsFragment.setArguments(newBundle);
- getFragmentTransaction().replace(R.id.content, myJobsFragment).commit();
- }
- else if(menuFragment.equals("myAdvertsFragment"))
- {
- newBundle = new Bundle();
- newBundle.putString("tabView", tabView);
- MyAdvertsFragment myAdvertsFragment = new MyAdvertsFragment();
- myAdvertsFragment.setArguments(newBundle);
- getFragmentTransaction().replace(R.id.content, myAdvertsFragment).commit();
- }
- }
- else {
- SplashScreen.this.startActivity(new Intent(SplashScreen.this, LoginActivity.class));
- SplashScreen.this.finish();
- }
- }
- }, 7000);
- }
- private FragmentTransaction getFragmentTransaction()
- {
- final android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
- return fragmentTransaction;
- }
- }
Add Comment
Please, Sign In to add comment