Bug 26135 - TaskStackBuilder API Improvements
Summary: TaskStackBuilder API Improvements
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 5.1
Hardware: PC Windows
: Normal enhancement
Target Milestone: master
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-01-17 03:27 UTC by Matthew Leibowitz
Modified: 2017-03-21 20:27 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Matthew Leibowitz 2015-01-17 03:27:11 UTC
There are some small improvements to the API of the TaskStackBuilder type that can be made:

 - TaskStackBuilder.AddParentStack can be overloaded to accepts a System.Type
 - TaskStackBuilder.GetPendingIntent can be overloaded to accept a PendingIntentFlags

Currently I have to use:

  var intent = new Intent (this, typeof(MainActivity));
  var backStack = TaskStackBuilder.Create (this)
    .AddParentStack (Java.Lang.Class.FromType (typeof(NotificationActivity)))
    .AddNextIntent (intent);
  var pendingIntent = backStack.GetPendingIntent (0, (int)PendingIntentFlags.UpdateCurrent);

It would be better to use:

  var intent = new Intent (this, typeof(MainActivity));
  var backStack = TaskStackBuilder.Create (this)
    .AddParentStack (typeof(NotificationActivity))
    .AddNextIntent (intent);
  var pendingIntent = backStack.GetPendingIntent (0, PendingIntentFlags.UpdateCurrent);
Comment 1 Matthew Leibowitz 2015-01-17 06:41:37 UTC
I notice that this is in the 2.3 API but not in the 4.1
Comment 2 Jonathan Pryor 2015-03-02 12:32:55 UTC
@Dean: Perhaps we should update `generator` to emit a `System.Type` overload for all constructors and methods which accept `Java.Lang.Class`?
Comment 3 dean.ellis 2016-11-08 17:23:32 UTC
@jonp 

would the new "overload" require the Register attribute (on constructors)? I assume not since we don't need to expose this one to the java side of the house. Its been a while since I played with generator...

I also assume we would want to end up with "additional" code like

  public TaskStackBuilder (Type type)  : this (Java.Lang.Class.FromType (type));

  public TaskStackBuilder AddParentStack (Type type) {
     return AddParentStack (Java.Lang.Class.FromType (type));
  }
 
providing we don't have a System.Type constructor/method already.

Note You need to log in before you can comment on or make changes to this bug.