Help in BarChartView class

Hello everyone

For anybody that is familiar with the Java classes in ui/statistics section. I am currently facing an issue with the class “BarChartView” that is located on ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years. In order to create an instance of this class, I have to use the constructor which takes as a parameter a Context object. Unfortunately, I cannot find a way to have a Context object without this being null, and therefore I cannot create an object of this class and use any methods. Does someone knows how to resolve this issue?

Did you get anywhere with this? I’m not great with android development, and am unfortunately unfamiliar with all parts of the AntennaPod source code including this specific class. However, I hate seeing questions remaining unanswered. So here’s my attempt:

What I do believe you’re talking about is the BarChartView class, and how to create the Context object required as an argument by its constructors. Correctly understood?

On line 3 we can an import of android.content.Context, which according to its documentation has a constructor which takes no argument. Is that the one you’re attempting to call?

It might be easier to give a good answer if you include the code you attempt to run, a description of what you expect it to do and what actually happens. Is this it?

  import android.content.Context;
  import de.danoeh.antennapod.ui.statistics.years.BarChartView;

  Context c = Context();
  BarChartView b = BarChartView(c);

I don’t have an android development environment readily available, but my glance at the source and documentation gives me the impression that typical callers should probably find an existing Context rather than creating one. The similarly sounding<object>.getTargetContext() and getContext() seem to occur frequently in AntennaPod:s source code. The fact that my language-server does not know about getContext() suggests that it is provided by android. What happens if you attempt to call that one?

  import de.danoeh.antennapod.ui.statistics.years.BarChartView;

  Context c = getContext();
  BarChartView b = BarChartView(c);

Again, no android environment here. So my code snippets are intended to clarify the question. I would not trust them to even compile.