manabreak

0

votes
0

answer
16

views

Resources$NotFoundException thrown after updating Gradle Plugin to 3.4.0

I have a project with multiple modules, and after updating to Gradle Plugin 3.4.0 and Gradle 5.1.1, everything else seems to work OK, but the module for Espresso tests crashes immediately when trying to run the tests: android.content.res.Resources$NotFoundException: Drawable com.example.foo:dimen/ac...
manabreak
1

votes
3

answer
94

views

Using the same indices between two arrays to get relevant information?

I have a data reader that tokenizes input strings by given delimiters. The tokens go to an ArrayList, and the delimiters go to another. For example: this + is - an * input This sentence would be tokenized so that 'this', 'is', 'an' and 'input' would go to the token array while '+', '-' and '*' go to...
manabreak
1

votes
2

answer
266

views

How to create a list view with number, text and checkbox columns?

I need to have a list somewhat similar to CheckedListBox. The format would be No. Name Use? 1 First item [ ] 2 Second item [X] 3 Third item [X] The name should not be editable. The number should be editable and the order should update au...
manabreak
1

votes
2

answer
807

views

Spotlight angular attenuation causes sharp edges when angle > 90

If the cone angle is over 90 degrees, my spot light's angular attenuation is not working correctly. From 0.1 to 90, the attenuation is smooth from the center of the cone to the edges, but from 90 to 179.9, it gets sharper and sharper edges. Here's my attenuation code: uniform vec3 lightPosition; //...
manabreak
1

votes
1

answer
1.1k

views

C++, ECS and Saving / Loading

I have a program that employs an entity-component-system framework. Essentially this means that I have a collection of entities that have various components attached to them. Entities are actually just integer ID numbers, and components are attached to them by mapping the component to the specified...
manabreak
1

votes
1

answer
444

views

Jekyll shows excerpt only on one post

I'm trying to show the excerpts of the posts on the front page, but it seems to only work for one post. The excerpt is inserted like this: {% for post in paginator.posts %} {{ post.title }} {{ post.excerpt | strip_html }} {% endfor %} The posts look like this, first one called '2015-08-17-first-post...
manabreak
1

votes
1

answer
942

views

RxJava: How to repeat an observable chain when original condition is not met anymore?

I'd like to re-subscribe to an observable using repeat(), but the condition that triggers the original observable is not met anymore when the first subscription is finished. How would I re-subscribe the observer in this case? The code looks something like this: RxInput.onInput(grid) .flatMap(Grid::h...
manabreak
1

votes
1

answer
1.1k

views

Improving shadow map performance of point lights?

I'm making point lights with shadow maps, and currently I have it done with six depth map textures, each rendered individually and applied to the light map. This works quite well, but the performance cost is high. Now, to improve the performance by reducing FBO changes and shader swapping between de...
manabreak
1

votes
1

answer
47

views

How to retrieve an object of a specific subclass?

I have a class 'Entity', that has a list of 'Component' objects. Now, 'Component' is just a root class for a bunch of different subclasses, and each subclass can be represented only once per entity. Now, I would like to retrieve a certain type of 'Component', how do I do that? It's a bit difficult t...
manabreak
1

votes
2

answer
694

views

How to use the user ID as a foreign key?

I have two tables, 'users' and 'posts', looking like this: users: - id - username - password ... posts: - id - user_id (foreign key referencing users.id) - text Basically, a user has multiple posts (blog-type posts). Now, I'm trying to create a new post as a logged in user, but I can't get it to wor...
manabreak
1

votes
2

answer
697

views

Linking a static library causes errors in the linked library

I have a small library project that uses OpenGL (glfw and glew). Now, the project compiles fine, but when I create a new project and statically link the library project, VS starts to throw errors in the library project. Why is that? More specifically, I get this error: error C1083: Cannot open inclu...
manabreak
1

votes
4

answer
5.2k

views

How to order a list of points by distance to a given point?

I have a list of items that have X and Y coordinates. Now, there's a method that takes X and Y parameters and should return a the list of coordinates ordered from the closest to the farthest based on the given parameters. Basically, it looks something like this: class Point: x = 0.0 y = 0.0 # List o...
manabreak
1

votes
2

answer
89

views

Set boolean value to FALSE for each row in query with 'HAVING'?

(Sorry about the phrasing of the title.) I have the following SQL query that retrieves all the rows I want: SELECT app_activity.name FROM app_chatmessage JOIN app_activity ON app_chatmessage.activity_id = app_activity.id GROUP BY app_activity.name HAVING COUNT(app_chatmessage.owner_id) = 1; Now, th...
manabreak
1

votes
3

answer
312

views

How to erase an element from std::vector when using templates?

I have a rather simple templated class in which I store items in a vector. However, I get the following error when I try to erase an element: C2678: binary '==': no operator found which takes a left-hand operand of type 'TestComponent' (or there is no acceptable conversion) Here's the code I'm using...
manabreak
1

votes
2

answer
469

views

Java Regex: Allow only certain characters, but don't allow certain characters to begin the string?

I'm fiddling around with Java regex, and I'm trying to come up with a pattern that allows a certain set of characters anywhere else BUT it can't start with certain characters in the allowed set. For example, let's say the allowed characters are from A to Z, but the string can't start with X or Z. Ho...
manabreak
2

votes
3

answer
1.9k

views

How to remove all 'nil' values from an array?

I have an array of objects (or just numbers), and I have another array which contains all the objects that should not be removed from the first array in any circumstances. It looks something like this: -- Array of objects (just numbers for now) Objects = {} -- Array of objects that should always sta...
manabreak
18

votes
3

answer
2.4k

views

VS emulator for Android stops responding to keyboard

I've been using the new VS emulator for Android for a few days now, and while it works brilliantly otherwise, it randomly stops receiving keyboard events. It does change the keyboard language when I press CTRL + Space, but it won't receive any characters when I try to type text. So far, the only sol...
manabreak
19

votes
3

answer
2.1k

views

How to avoid piling up callbacks or “callback hell”?

My program makes heavy use of (possibly) asynchronous calls where the return value is not immediately available, thus there are a lot of methods like this: // A simple callback interface public interface GetFooCallback { void onResult(Foo foo); }; // A method that magically retrieves a foo public vo...
manabreak
6

votes
3

answer
3.6k

views

Compressing the response payload in Django REST?

I was wondering: would it be possible to compress the response payload in Django REST? At the moment, the response payloads are plain JSON data. However, there's quite a lot of data to bounce back and forth so I was wondering if compressing the data would help with the bandwidth issues.
manabreak
8

votes
1

answer
12k

views

Error C2280: attempting to reference a deleted function (unique_ptr)

I went through some old code that used raw pointers and changed them to unique_ptrs instead. Now, when I try to compile the code, I get this error message: Error 1 error C2280: 'std::unique_ptr>::unique_ptr(const std::unique_ptr &)' : attempting to reference a deleted function d:\visual studio 2...
manabreak
20

votes
2

answer
10.5k

views

“AndroidRuntime: Shutting down VM” with nothing else

For some reason, LogCat doesn't report any stack traces anymore on crashes. Instead, I only get the following info: D/AndroidRuntime: Shutting down VM W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40dd3960) This is really weird because I've been working on the very same pro...
manabreak
2

votes
1

answer
297

views

How to update a single column on a single row?

I'm trying to write a simple update view for my Django REST application, but I cannot figure out how to do it. I've gotten a range of errors from 403 to 500. Basically, I have a table 'Foo' and I want to set the 'active' field from 'True' to 'False'. Here's the view I have currently: class DisableFo...
manabreak
1

votes
1

answer
62

views

Is there a way to enforce a reference lvalue?

I was wondering if there's a way to enforce the usage of a reference lvalue? Suppose a following scenario: class Foo { public: Foo() { std::cout
manabreak
21

votes
2

answer
8k

views

How to make a “light” build of GCC with language supports etc. pruned?

Basically I would like to make a light build of GCC with only C/C++ support. Can this be done easily or does it require manual tinkering with source?
manabreak
1

votes
1

answer
1.2k

views

Page not found (404) with django-allauth

I'm trying to incorporate django-allauth on my project. So far so good with the installation, but when I try to access the 'accounts' page, I get a 'page not found 404' error. Here's the output: Using the URLconf defined in Mysite.urls, Django tried these URL patterns, in this order: ^$ [name='home'...
manabreak
3

votes
4

answer
2.9k

views

How to get the nearest location entries from a database?

I store coordinates as latitude longitude pairs in my database. Now, I need to retrieve all the entries that are within a given radius from a given lat-long coordinate. For example, if given coordinates 48.796777, 2.371140 and distance of 20 kilometers, it would retrieve all the records within 20 ki...
manabreak
4

votes
3

answer
283

views

Instantiation of class by classname

I have multiple classes that share a common base class, like this: class Base {}; class DerivedA : public Base {}; class DerivedB : public Base {}; class DerivedC : public Base {}; Now, I need to know which of these derived classes to instantiate during runtime (based on input). For example, if inpu...
manabreak
12

votes
2

answer
2k

views

Can I load a picture with Picasso to the action bar?

I've been using Picasso extensively to retrieve images over the internet to my app. Now, I've run into a situation where I need to retrieve a small image to the action bar (like a logo next to the title text). Is it possible to do this with Picasso? If so, how would I do that?
manabreak
4

votes
2

answer
2.1k

views

WRITE_EXTERNAL_STORAGE still required with KitKat?

As mentioned in the documentation, the WRITE_EXTERNAL_STORAGE permission should not be a requirement starting from API level 19. Hence, I've written this to the manifest: However, when running my app which uses Google Maps V2 and thus needs access to the external storage, I get a SecurityException:...
manabreak
2

votes
1

answer
414

views

How to find out which item the recycler view is snapped to?

I have a recycler view that uses LinearSnapHelper to snap the items as the user scrolls it. Now, I'd like to listen to the snaps, preferably getting the index of the item that was snapped. However, I can't really figure out if there's a way to do that. Initially I thought that the LinearSnapHelper's...
manabreak
7

votes
1

answer
1.1k

views

“C2593: operator = is ambiguous” when populating std::map

I have a std::map I'm trying to initialize with an initialization list. I do this in two places, in two different ways. The first one works, while the other one causes the error mentioned in the title. Here's the one that works: void foo() { static std::map fooMap = { { 'First', 'ABC' }, { 'Second',...
manabreak
2

votes
2

answer
1.3k

views

Get all string resources from XML resource file?

I have a resource file called suggestions.xml which is translated to a couple of languages. These XML files contain just values. Now, I'd like to retrieve all the strings in the current locale's suggestions.xml file. How do I do that? I know I can retrieve single strings by their ID's, but I'd like...
manabreak
3

votes
1

answer
666

views

RxJava: How to refresh a token when multiple requests are sent at the same time?

I have an app that authenticates using OAuth2 and fetches data from a RESTful service using Retrofit. Now, I have the token retrieval and refreshing up and running. The token is refreshed like so (schedulers omitted): // Each Retrofit call observable is 'wrapper' using this method protected Observa...
manabreak
5

votes
1

answer
2.5k

views

How to handle COLLADA indices?

I wrote a simple reader for the COLLADA file format, and it seems to work OK. Now, I have a Blender-exported cube mesh which is edge-splitted and triangulated, so it should have 12 triangles (2 per face), 24 vertices (4 per face) and 36 indices (6 per face). This mesh also has normal data and UV map...
manabreak
1

votes
3

answer
584

views

How to specify which .cpp files to compile based on the current build configuration?

I have multiple build configurations in my project, and I'd like to swap some .CPP files based on the currently selected configuration. How can I do that in Visual Studio 2013?
manabreak
3

votes
1

answer
145

views

Android Studio doesn't build Java project on “Run”; requires manual build

I have a multi-module Java project, which I opened in Android Studio. Now, the project works otherwise fine, but when I click 'Run', it won't build the project. Instead, it runs the old executable. I always have to first manually build the project so that it will run the most recent version. What co...
manabreak
2

votes
1

answer
1.3k

views

Is it possible to flatten the JSON hierarchy with Gson?

I use Gson to convert JSON data to Java objects. However, the JSON structure has an extra field which could be flattened. Is this possible to do with Gson? To elaborate (since this is rather difficult to explain), the JSON looks something like this: { 'foo': 'bar', 'data': { 'first': 0, 'second': 1,...
manabreak
2

votes
1

answer
1.9k

views

How to show nested (or 'tree') data in recycler view?

I have a data structure where each node can contain n child nodes of the same type. I'd like to show these as a list where each child is intended as per its 'depth'. I have already a working recycler view that shows the top-level nodes. How would I go on about showing the child nodes? The node class...
manabreak
3

votes
0

answer
111

views

Foreground service stops while running a long task

I have a foreground service that should execute a long-running (~20 minutes) task in a single go (a file transfer using Bluetooth). However, the service gets stopped after a while. As a simple test app that reproduces the issue, I did the following, first the activity: public class MainActivity exte...
manabreak
2

votes
2

answer
45

views

How to prevent a local file being synced with the remote repo?

I have a file that has authentication-related constants (e.g. client ID, client secret etc.), something like this: public class AuthConstants { public static final String CLIENT_SECRET = 'Client secret here'; ... } Now, I have committed and pushed this file with placeholder strings, so the client se...
manabreak

View additional