Notification improvements #1175
3 changed files with 19 additions and 11 deletions
|
@ -2781,15 +2781,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private Fragment getCurrentFragment() {
|
private Fragment getCurrentFragment() {
|
||||||
int backCount = getSupportFragmentManager().getBackStackEntryCount();
|
return getSupportFragmentManager().findFragmentById(R.id.content_main);
|
||||||
if (backCount > 0) {
|
|
||||||
try {
|
|
||||||
return getSupportFragmentManager().getFragments().get(backCount - 1);
|
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideActionBar() {
|
public void hideActionBar() {
|
||||||
|
@ -3495,6 +3487,18 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentFragment != null && ((BaseFragment) currentFragment).getParams() != null
|
||||||
|
&& ((BaseFragment) currentFragment).getParams().containsKey("source")
|
||||||
|
&& ((BaseFragment) currentFragment).getParams().get("source").equals("notification")) {
|
||||||
|
|
||||||
|
Map<String, Object> currentParams = new HashMap<>(1);
|
||||||
|
|
||||||
|
if (((BaseFragment) currentFragment).getParams().containsKey("url"))
|
||||||
|
currentParams.put("url", ((BaseFragment) currentFragment).getParams().get("url"));
|
||||||
|
|
||||||
|
((BaseFragment) currentFragment).setParams(currentParams);
|
||||||
|
}
|
||||||
|
|
||||||
//fragment.setRetainInstance(true);
|
//fragment.setRetainInstance(true);
|
||||||
FragmentManager manager = getSupportFragmentManager();
|
FragmentManager manager = getSupportFragmentManager();
|
||||||
FragmentTransaction transaction = manager.beginTransaction().replace(R.id.content_main, fragment);
|
FragmentTransaction transaction = manager.beginTransaction().replace(R.id.content_main, fragment);
|
||||||
|
|
|
@ -16,8 +16,10 @@ import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import io.lbry.browser.MainActivity;
|
import io.lbry.browser.MainActivity;
|
||||||
import io.lbry.browser.data.DatabaseHelper;
|
import io.lbry.browser.data.DatabaseHelper;
|
||||||
|
@ -47,7 +49,9 @@ public class NotificationListTask extends AsyncTask<Void, Void, List<LbryNotific
|
||||||
List<LbryNotification> notifications = new ArrayList<>();
|
List<LbryNotification> notifications = new ArrayList<>();
|
||||||
SQLiteDatabase db = null;
|
SQLiteDatabase db = null;
|
||||||
try {
|
try {
|
||||||
JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("notification", "list", context));
|
Map<String, String> parameters = new HashMap<>(1);
|
||||||
|
parameters.put("is_app_readable", "true");
|
||||||
|
JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("notification", "list", parameters, context));
|
||||||
if (array != null) {
|
if (array != null) {
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
JSONObject item = array.getJSONObject(i);
|
JSONObject item = array.getJSONObject(i);
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class BaseFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params != null && params.containsKey("source") && "notification".equalsIgnoreCase(params.get("source").toString())) {
|
if (params != null && params.containsKey("source") && params.get("source") != null && "notification".equalsIgnoreCase(params.get("source").toString())) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context instanceof MainActivity) {
|
if (context instanceof MainActivity) {
|
||||||
((MainActivity) context).navigateBackToNotifications();
|
((MainActivity) context).navigateBackToNotifications();
|
||||||
|
|
Loading…
Reference in a new issue