Migrated from Glide 3 to 4 and having a AbstractMethodError when launching the app - android-glide

I have an application using Glide 3.8.0 and I've just migrated it to 4.8.0. After migrating all the code to use the new Glide's API, I've found that my app launches this error when trying to load an image from the network:
java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"
at com.bumptech.glide.Glide.initializeGlide(Glide.java:268)
at com.bumptech.glide.Glide.initializeGlide(Glide.java:221)
at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:182)
at com.bumptech.glide.Glide.get(Glide.java:166)
at com.bumptech.glide.Glide.getRetriever(Glide.java:680)
at com.bumptech.glide.Glide.with(Glide.java:732)
at com.fewlaps.android.quitnow.usecase.main.MainActivity.updateAvatar(MainActivity.java:356)
etc...
I've done the setup explained in the official documentation. As it requests, I wrote a class that extends AppGlideModule, it's annotated by #GlideModule, and it's empty. Empty? The official documentation says:
You’re not required to implement any of the methods in AppGlideModule for the API to be generated. You can leave the class blank as long as it extends AppGlideModule and is annotated with #GlideModule.
According to the Error's message, my issue is related with registerComponents() for sure, but I also tried to implement it with a blank implementation, and the issue remains.

As explained in AppGlideModule's JavaDoc (and as far as I know, only there...), if you are done with the migration from 3.x.x to 4.x.x, you have to implement isManifestParsingEnabled() returning false.
So, you'll end with a CustomAppGlideModule like this one:
#GlideModule
public class QNGlideModule extends AppGlideModule {
#Override
public boolean isManifestParsingEnabled() {
return false;
}
}

Related

ASP.NET Core MVC application dependency injection issue when using BaseController

Recently i tried to create a MVC application using ASP.NET Core 2.0 and i had some values defined in appsettings.json,
"MySettings": {
"WebApiBaseUrl": "http://localhost:6846/api/"
}
In order to read these values i have added
services.Configure<MySettingsModel>(Configuration.GetSection("MySettings"));
above line in ConfigureServices method in Startup.cs
and in my home controller i have added
private readonly IOptions<MySettingsModel> appSettings;
public HomeController(IOptions<MySettingsModel> app)
{
appSettings = app;
}
MySettingsModel class is just a model with property same as key define in appsettings.json.
by this method i'm able to read the value of this key.
Now my issue is that i want to use this key in many controllers so i don't want to repeat this code in every controller so what i did was i created a BaseConntroller, added its constructor and i got my values there. But when i inherit other controllers with my BaseController , it throws me an error and tells me to generate it's constructor, so basically it tells me to add constructor in every controller which is what i wanted to avoid.
How can i achieve this?
You can see the image for the error
And these are the potential fixes that it shows me.
This is just basic C# inheritance. Derived classes must re-implement constructors on base classes (at least the ones you want or need). The only exception is the empty constructor, which is implicit. In other words, you simply need:
public class HomeController : BaseController
{
public HomeController(IOptions<MySettingsModel> app)
: base(app)
{
}
And, of course, you need to change the accessibility of the base class field to protected instead of private. Otherwise, derived classes will not be able to access it.
Of course, this doesn't really save you that much. However, there's no free lunch here. Like I said, this is a limitation of C#, itself, so you have no choice. Although, it's worth mentioning, that while this can sometimes be annoying, it's actually a kind of useful feature of C#. You can look at any class and see exactly what constructors it has available, without having to trace down all its ancestors.
Actually, there is a good solution here:
https://stackoverflow.com/a/48886242/2060975
I am mostly using this method.
[Authorize]
[ApiController]
public abstract class ApiControllerBase : ControllerBase
{
private IOptions<AppSettings> _appSettings;
protected IOptions<AppSettings> appSettings => _appSettings ?? (_appSettings = (IOptions<AppSettings>)this.HttpContext.RequestServices.GetService(typeof(IOptions<AppSettings>)));
...
}
I hope it helps someone:)

Why does default AsyncController's index not work in Grails?

I came back to Grails after [oh so many] years, and was happy to find the Async Controllers.
I wanted to experiment, so I have created a very simple domain class:
class ClientDevice implements AsyncEntity<ClientDevice> {
int width
int height
static constraints = {
}
}
And generated the default async controller and views.
Upon running the app using grails run-app, I've browsed to http://localhost:8080/clientDevice/index, and I'm getting HTTP Error 500.
I've looked at the logs - nothing.
The http://localhost:8080/clientDevice/create page works fine, but saving new clientDevice does not work.
I'm using the default development devDb H2 memory database.
This is happening on Grails 3.3.3 with Java 1.8_161
Any tips? I was really looking forward to trying the async stuff.

Ensuring only a single instance of the RxBleClient

Maybe I'm not understanding the situation correctly, but we're told it's important to have only one instance of the RxBleClient.
Couldn't this be easily accomplished by making it a static member of the Application class?
class MyApp extends Application {
static RxBleClient rxBleClient;
...
}
Also, I'm having a hard time understanding this code (from your Application class):
public static RxBleClient getRxBleClient(Context context) {
RxBleApp application = (RxBleApp) context.getApplicationContext();
return application.rxBleClient;
}
Could you help me understand what it's doing, and why? Why couldn't it simply
return rxBleClient;
It can be accomplished with taking the static member of the class. Tough it is more elegant to pass it through the instance of RxBleApp which make it more testable (if there were any tests for the sample part).
The RxBleClient is referenced in the RxBleApp which is the android Application. The application context can be retrieved from the Context.

Swagger Java class is not parsing properly

I am using swagger to create API documentation for one of my Spring Rest API project, but the swagger.json file created is having an issue.
One of my Super class is not getting converted properly.
Library used to implement the swagger is springfox. Please find the implementation details below.
Configuration
EnableWebMvc
EnableSwagger2
ComponentScan
public class MvcConfig extends WebMvcConfigurerAdapter {
}
This is the class causing the problem
public class ListResultModel MODEL extends BaseModel {
}
Json Created
"schema":{"$ref":"#/definitions/RedirectAttributes"}}],"responses":{"200":{"description":"OK","schema":{"type":"string"}},"201":{"description":"Created"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden"},"404":{"description":"Not Found"}}}},"/admin/migration/vat":{"get":{"tags":["migration-controller"],"summary":"vatMigration","operationId":"vatMigrationUsingGET","consumes":["application/json"],"produces":["/"],"parameters":[{"name":"retailerId","in":"query","description":"retailerId","required":true,"type":"string"}
{"$ref":"#/definitions/**ListResultModel«Item»"**}},"401":{"description":""},"403":{"description":"Forbidden"},"404":{"description":"Not Found"}}}},"/api/items/withoutPictures/{departmentId}/{vendorId}/{status}":{"200":{"description":"OK","schema":{"$ref":"#/definitions/**ListResultModel«Item»"}**},"401":{"description":""},"403":{"description":"Forbidden"},"404":{"description":"Not }
{"$ref":"#/definitions/ListResultModel«Lead»"}},"201":{"description":"Created"},"401":{"description":""},"403":{"description":"Forbidden"},"404":{"description":"Not Found"}}}}
I am trying to resolve this for a long time and there is no clue how to do it. Can anybody help me please!
Thanks in advance.
Vivek
This Got Fixed by the below Thread.
https://github.com/springfox/springfox/issues/1283
Regards
Vivek

Is EventAggregator.PublishOnUIThread(aMessage) the same as EventAggregator.Publish(aMessage,Execute.OnUIThread)?

Micro 2.x users,
I'm having trouble mocking (using moq) and verifying a call to EventAggregator.PublishOnUIThread since it is a extension method!
Poking around in the source code made me come up with another method call that IS mockable :-)
But it would be nice to know if EventAggregator.Publish(aMessage,Execute.OnUIThread)
is the equivalent of EventAggregator.PublishOnUIThread(aMessage)?
Yes, they are equivalent.
This is how the EventAggregator.PublishOnUIThread extension method is currently implemented:
public static void PublishOnUIThread(this IEventAggregator eventAggregator, object message)
{
eventAggregator.Publish(message, Execute.OnUIThread);
}
For details, see the EventAggregatorExtensions.cs source code.

Resources