Skip to content

Commit

Permalink
fix nowplaying intent on notification clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
naman14 committed Sep 29, 2015
1 parent 5d18955 commit 09bbebd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.naman14.timber.activities;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
Expand Down Expand Up @@ -331,11 +333,12 @@ public void run() {
Runnable navigateNowplaying = new Runnable() {
public void run() {
navigationView.getMenu().findItem(R.id.nav_nowplaying).setCheckable(false);
String fragmentID = getIntent().getExtras().getString(Constants.NOWPLAYING_FRAGMENT_ID);
boolean withAnimations = getIntent().getExtras().getBoolean(Constants.WITH_ANIMATIONS);
SharedPreferences prefs = getSharedPreferences(Constants.FRAGMENT_ID, Context.MODE_PRIVATE);
String fragmentID= prefs.getString(Constants.NOWPLAYING_FRAGMENT_ID, Constants.TIMBER3);

Fragment fragment = NavigationUtils.getFragmentForNowplayingID(fragmentID);
FragmentManager fragmentManager = getSupportFragmentManager();

fragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment).commit();
panelLayout.setPanelHeight(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v4.app.Fragment;
import android.util.Pair;

Expand Down Expand Up @@ -61,26 +60,20 @@ public static void navigateToArtist(Activity context,long artistID,ArrayList<Pai
}

public static void navigateToNowplaying(Activity context,boolean withAnimations){
SharedPreferences prefs = context.getSharedPreferences(Constants.FRAGMENT_ID, Context.MODE_PRIVATE);
String fragmentID= prefs.getString(Constants.NOWPLAYING_FRAGMENT_ID, Constants.TIMBER3);

final Intent intent=new Intent(context, MainActivity.class);
if (!PreferencesUtility.getInstance(context).getSystemAnimations()){
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
}
intent.setAction(Constants.NAVIGATE_NOWPLAYING);
intent.putExtra(Constants.NOWPLAYING_FRAGMENT_ID,fragmentID);
intent.putExtra(Constants.WITH_ANIMATIONS,withAnimations);
context.startActivity(intent);
}

public static Intent getNowPlayingIntent(Context context){
SharedPreferences prefs = context.getSharedPreferences(Constants.FRAGMENT_ID, Context.MODE_PRIVATE);
String fragmentID= prefs.getString(Constants.NOWPLAYING_FRAGMENT_ID, Constants.TIMBER3);

final Intent intent=new Intent(context, MainActivity.class);
intent.setAction(Constants.NAVIGATE_NOWPLAYING);
intent.putExtra(Constants.NOWPLAYING_FRAGMENT_ID,fragmentID);
return intent;
}

Expand Down

0 comments on commit 09bbebd

Please sign in to comment.