Android: change code generation order
I have a Lombok, DataBinding and Realm in my project.
I created model like this:
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class NewsItem extends RealmObject {
public static final String ID = "id";
@SerializedName("id")
private long id;
@SerializedName("title")
private String title;
@SerializedName("description")
private String description;
@SerializedName("pubdate")
private String date;
@SerializedName("link")
private String link;
@SerializedName("favorite")
private boolean favorite;
}
But in build time I get an error "Error:Class must declare a public constructor with no arguments if it contains custom constructors."
And if I set attribute in xml android:text="@{model.getTitle()}", I get an error about there is no getTitle() in model.
I think it's becouse code genereted by lombok later then other, and DataBinding and Realm don't see getTitle() and constructor.
Question: Can I change order of code generation, to set Lombok generation on first place? Or maybe I don't understand how it works.
See also questions close to this topic
-
Rewrite code from logcat output to TextView output
I would like to rewrite the following code to output in a TextView instead of the logcat. How do I do that?
public static void printUsageStats(List<UsageStats> usageStatsList,Context context){ for (UsageStats u : usageStatsList) { PackageManager pm = context.getPackageManager(); PackageInfo foregroundAppPackageInfo = null; try { foregroundAppPackageInfo = pm.getPackageInfo(u.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } if (u.getTotalTimeInForeground() > 0) { Log.d(TAG, "Pkg: " + foregroundAppPackageInfo.applicationInfo.loadLabel(pm).toString() + "\t" + String.valueOf(((u.getTotalTimeInForeground() / 60000) / 60) / 24) + "d " + String.valueOf(((u.getTotalTimeInForeground() / 60000) / 60) % 24) + "hr " + String.valueOf((u.getTotalTimeInForeground() / 60000) % 60) + "m " + String.valueOf((u.getTotalTimeInForeground() / 1000) % 60) + "s"); } } }
Thanks
-
How to Upload Image by multipart in amazon s3 with only Presigned URL in android
I have only
1. Presigned Url
I have uploaded image to this Url but now i, want to upload image using Multipart through this URL in Amazon S3, Is there any way to upload image by multipart by using only presigned URL.
NOTE: I don't have credentials and bucket name and other extra information, so is there any way for implement Multipart upload. ?
-
How to create a collage preview of images like FaceBook?
I am trying to implement image collage preview like Facebook while posting images,
so far i have created 5 layouts according to multiple image count and then i am inflating the layouts according to selected image list and setting image in forloop, i also need to show document icon if any selected.
Here is the code which i have implemented.
private void displayCollage() { rlLayout.setVisibility(View.VISIBLE); rlLayout.removeAllViews(); imagelayout5Binding.tvCount.setVisibility(View.GONE); if (attachList.size() > 0) { int count = attachList.size(); if (count > 5) { count = 6; } switch (count) { case 1: DisplayCollageImage(imagelayout1Binding.ivImage, 0); rlLayout.addView(imagelayout1Binding.getRoot()); break; case 2: for (int i = 0; i <= attachList.size(); i++) { switch (i) { case 0: DisplayCollageImage(imagelayout2Binding.ivImage1, i); break; case 1: DisplayCollageImage(imagelayout2Binding.ivImage2, i); break; } } rlLayout.addView(imagelayout2Binding.getRoot()); break; case 3: for (int i = 0; i <= attachList.size(); i++) { switch (i) { case 0: DisplayCollageImage(imagelayout3Binding.ivImage1, i); break; case 1: DisplayCollageImage(imagelayout3Binding.ivImage2, i); break; case 2: DisplayCollageImage(imagelayout3Binding.ivImage3, i); break; } } rlLayout.addView(imagelayout3Binding.getRoot()); break; case 4: for (int i = 0; i <= attachList.size(); i++) { switch (i) { case 0: DisplayCollageImage(imagelayout4Binding.ivImage1, i); break; case 1: DisplayCollageImage(imagelayout4Binding.ivImage2, i); break; case 2: DisplayCollageImage(imagelayout4Binding.ivImage3, i); break; case 3: DisplayCollageImage(imagelayout4Binding.ivImage4, i); break; } } rlLayout.addView(imagelayout4Binding.getRoot()); break; case 5: for (int i = 0; i <= attachList.size(); i++) { switch (i) { case 0: DisplayCollageImage(imagelayout5Binding.ivImage1, i); break; case 1: DisplayCollageImage(imagelayout5Binding.ivImage2, i); break; case 2: DisplayCollageImage(imagelayout5Binding.ivImage3, i); break; case 3: DisplayCollageImage(imagelayout5Binding.ivImage4, i); break; case 4: DisplayCollageImage(imagelayout5Binding.ivImage5, i); break; } } rlLayout.addView(imagelayout5Binding.getRoot()); break; case 6: for (int i = 0; i <= attachList.size(); i++) { if (i >= attachList.size()) { i = 5; } switch (i) { case 0: DisplayCollageImage(imagelayout5Binding.ivImage1, i); break; case 1: DisplayCollageImage(imagelayout5Binding.ivImage2, i); break; case 2: DisplayCollageImage(imagelayout5Binding.ivImage3, i); break; case 3: DisplayCollageImage(imagelayout5Binding.ivImage4, i); break; case 4: DisplayCollageImage(imagelayout5Binding.ivImage5, i); break; case 5: DisplayCollageImage(imagelayout5Binding.tvCount); break; } if (i == 5) { break; } } rlLayout.addView(imagelayout5Binding.getRoot()); break; } } else { rlLayout.removeAllViews(); } }
but doing this is taking too much processing time, please help me how can i reduce this processing time.
-
Angular 2 svg image showing up as blank image
I am trying to display an svg image where the path to the image is being passed down from the parent component. Like so:
Parent HTML:
<div class="home__top-right"> <dashboard-button btnImg="../../../../assets/dashboard/Hex_Cube_White.svg"></dashboard-button> <dashboard-button btnImg="../../../../assets/dashboard/Hex_Cube_White.svg"></dashboard-button> </div>
Component:
@Component({ selector: 'dashboard-button', templateUrl: './dashboard-button.component.html', styleUrls: ['./dashboard-button.component.scss'] }) export class DashboardButtonComponent { @Input() btnImg: string; }
HTML:
<div class="dash-button__body"> <img class="dash-button__body-img" [src]="btnImg"> <p class="dash-button__body-title">{{btnImg}}</p> </div>
All I can see if the empty img icon and the svg is being downloaded as type text/html instead of svg+xml like all my other svg I'm using. The path is correct because if I place the path directly into the source I can see the image. What am I doing incorrectly?
-
How to set background color of cells of DataGrid according to data field
I have a data structure like this:
List<Data> data = new List<Data>(); data.Add(new Data() { Value1 = ("123", Colors.Red), Value2 = ("345", Colors.Green) }); data.Add(new Data() { Value1 = ("123", Colors.Yellow), Value2 = ("456", Colors.Red) }); data.Add(new Data() { Value1 = ("543", Colors.Green), Value2 = ("456", Colors.Green) });
So, I have 2 columns "Value1" and "Value2". And every value is a tuple of the value itself and associated color. I want to show the value on the cell and make the background of the cell according to the color given in the tuple.
I can change the data structure if the solution requires. For example, instead of a tuple, I can create an object with
value
andbackground color
fields.How can I implement this using WPF DataGrid?
Note: The colors don't have a rule, so I cannot derive them from the value. For example, "123" might be associated with red in one of the cells, and might be associated to green on another cell.
-
Caliburn Micro add Edit button to DataGrid in every row
I am using Caliburn.Micro in my project. I am trying to achieve CRUD operation using Caliburn.Micro . I have done the all part but I am facing problem in Edit data. I wants to add button in my DataGrid in every row so that when ever user click the edit button that row value could be edited and updated in database.
Here is my code
ShellView.xaml
<Button x:Name="ButtonUpdate" Width="100" Height="30" Content="Update"/> <DataGrid x:Name="Empdata2" AutoGenerateColumns="False" ItemsSource="{Binding Path= Empdata}" SelectedItem="{Binding selecteditem}" Height="162" CanUserAddRows="False"> <DataGrid.Columns> <DataGridTextColumn Header="ID" Binding="{Binding Path=id}"/> <DataGridTextColumn Header=" First Name" Binding="{Binding Path= fname}"/> <DataGridTextColumn Header="Last Name" Binding="{Binding Path=lname}"/> <DataGridTemplateColumn Header="delete"> <DataGridTemplateColumn.CellTemplate > <DataTemplate > <Button Content="Delete" cal:Bind.Model="{Binding DataContext, RelativeSource={RelativeSource AncestorType=DataGrid}}" x:Name="DeleteButton" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn Header="Edit"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Content="Edit" x:Name="EditButton"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid>
ShellViewModel.cs
public class ShellViewModel : Caliburn.Micro.PropertyChangedBase, IShell { private ObservableCollection<Person> _empdata = new ObservableCollection<Person>(); public ObservableCollection<Person> Empdata { get { return _empdata; } set { _empdata = value; NotifyOfPropertyChange(() => Empdata); } } Person model = new Person(); Auth obj = new Auth(); public void ButtonUpdate() { try { DataSet d = new DataSet(); d = obj.updateuser(); Empdata.Clear(); for (int i = 0; i < d.Tables[0].Rows.Count; i++) Empdata.Add(new Person { id=Convert.ToInt32(d.Tables[0].Rows[i][0]), fname = d.Tables[0].Rows[i][1].ToString(), lname = d.Tables[0].Rows[i][2].ToString(), }); } catch(Exception ex) { MessageBox.Show(ex.Message); } } private Person _selecteditem; public Person selecteditem { get { return _selecteditem; } set { _selecteditem = value; NotifyOfPropertyChange(() => selecteditem); } } string sel; public void DeleteButton() { Auth obj = new Auth(); sel = selecteditem.fname.ToString(); bool find = obj.deluser(sel); if (find == true) { ButtonUpdate(); } } public void EditButton(){ Auth obj = new Auth(); sel = selecteditem.fname.ToString(); ler = selecteditem.lname.ToString(); bool edit = obj.edituser(sel,ler); if (edit == true) { } }
Person.cs
public class Person:PropertyChangedBase
{
public string FirstName { get; set; } public string LastName { get; set; } private string Firstname; public string fname { get { return Firstname; } set { Firstname = value; NotifyOfPropertyChange(() => fname); } } private string Lastname; public string lname { get { return Lastname; } set { Lastname = value; NotifyOfPropertyChange(() => lname); } }
Auth.cs
public class Auth { SqlConnection conn = new SqlConnection(@"Data Source = a; Initial Catalog = ab; Persist Security Info=True;User ID = s; Password=123"); public DataSet updateuser() { try { conn.Open(); SqlCommand comm = new SqlCommand("Select * from [add]", conn); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(comm); da.Fill(ds); conn.Close(); return ds; } catch (Exception ex) { throw ex; } } public bool deluser(string name) { try { conn.Open(); SqlCommand comm = new SqlCommand("Delete from [add] where firstname=" + name + "", conn); comm.ExecuteNonQuery(); conn.Close(); return true; } catch(Exception ex) { throw ex; } } public bool edituser(string frname,string lrname) { try { conn.Open(); SqlCommand comm = new SqlCommand("Update [add] set firstname='" + frname + "' where lastname='" + lrname + "'", conn); comm.ExecuteNonQuery(); conn.Close(); return true; } catch (Exception ex) { throw ex; } }
-
How to use Array or Dictionary in RealmSwift?
I'm tried RealmSwift.
And I save my model. but RealmSwift does not support Array, Dic... What can I do?
import Foundation import RealmSwift class DumbData: Object { @objc dynamic var myModel: [[String: String]]! } class ViewController: UIViewController { ... let data = DumbData() data.myModel = [["asdf": "1234"]] let realm = try! Reaml() try realm.write { realm.add(data) // error. Realm Does not support Array, Dic... } ... }
-
ROS data upload issue
My realm version on android is 5.0.0 and ROS version is 2.1.1. I have an issue on get and put data on ros. Facing the following issue in logcat
Connection closed due to error D/REALM_SYNC: Connection[1]: Allowing reconnection in 647 milliseconds D/REALM_SYNC: Connection[1]: Resolving '00.00.00.000:9080' D/REALM_SYNC: Connection[1]: Connecting to endpoint '00.00.00.000:9080' (1/1) I/REALM_SYNC: Connection[1]: Connected to endpoint '00.00.00.000:9080' (from '00.00.000.000:52823') D/REALM_SYNC: Connection[1]: WebSocket::initiate_client_handshake()
-
check if any realm instances is running or not before deleting the database
How to check all realm instances are closed or not?
I want to check if any realm instances is running or not before deleting the database.. I want to know how many instances are open.
I've this
getGlobalInstanceCount(myRealm.getConfiguration()); public static int getGlobalInstanceCount(RealmConfiguration configuration){ //How do I convert the configuration to int? so that I return the number of open stores return **; }
I do not know how to convert RealmConfiguration to Int. to return the number
-
ITERATIVE MATHEMATICS NETWORK
Iterative Mathematics Network (I.Math.Net) also called I.logic
(+) = give,
(-) = request,
(->) = process,green(+) = [+g] = given,
green(-) = [-g] = none-sense,
Red(+) = [+r] = sense,
Red(-) = [-r] = pencel(pend/cancel).
2[-r] = [+r] = cancel.
2[+r] = [+g] = given.global -0- (sensible -0-) equation
[-] -> [+] = [-]
(ns)-> (s) = (p)
(none-sense) -> (sense) = (pencel)
The above means none-sense process sense which equals to pencel, pencel is a waiting action abbreviated from PEND and CANCEL... Now with this said answer the following questions below.NOTE: ANSWER WITH ANY OF THE SEQUATS OR SCHEMERACTIVES ABOVE.
What sense will it make out of none-sense ?
If pend, what it's waiting for ?
When pencel is on, what's none-sense? -
detecting logically duplicate classes under different class hierarchies in java
I have some Entity classes with following structure.
class A { ... other fields. static class B { String field1; int field2; C fieldC; static class C { String field3; } } } class X { ... other fields static class B { String field1; int field2; C fieldC; static class C { String field3; } } }
Note: I have no control over this source code and cannot change its structure.
Now, I am generating a client for these entities and I want to detect thatclass B
is actually the exact same class, under 2 different hierarchies. I have thejava.lang.reflect.Type
instance of both theseB
classes. So, with that, how is it feasible to detect that these are indeed logical duplicates. If I can detect that, then at the client side, I actually only need to generate 1 class hierarchy for this.
Particularly challenging for me is thesubclass C
. Any libraries that can do this? -
Sympy codegen: summed indexed functions
I'm struggling with what seems to be a simple problem in the python sympy module. Thus I suspect that I have misunderstood something - I hope you can help me.
My problem revolves around: sums of vectors (or at least indexed parameters), derivatives of these with respect to a specific matrix element and how to make this accessible through the autowrap functionality.
Example:
from sympy import Eq, IndexedBase, symbols, Idx, Sum, diff from sympy.utilities.autowrap import autowrap nc = symbols("nc", integer=True) fout = symbols("fout") n = IndexedBase("n") F = IndexedBase("F") i = Idx("i", nc) j = Idx("j", nc) F1 = symbols("F1") N = Sum(n[i],i) F1 = Sum(F[i,j]*n[i]/N,i,j) Funcout = Eq(fout,diff(F1,n[i])) Testfunction = autowrap(Funcout)
Here I get the following error:
NotImplementedError: FIXME: No specialized handling of type <class 'sympy.concrete.summations.Sum'>
How do I use autowrap to generate the vector function with: Output: [vector] where the i'th element corresponds to diff(F1,n[i]) Input: F and n of arbitrary sizes (but n[m] and F[m,m]).
But surely there must be a way to do summations over an arbitrary array size with sympy that plays well with the codegen module?
Context: I work with simulations based on large equation systems where some of the boundary conditions are defined by a series of first and second order derivatives from particular functions. Thus I want to write the main function in sympy, then generate the derivatives and finally get a fast implementation by using the codegen capabilities. This would probably save me half a years worth of work.
-
IntelliJ Lombok - src/integration-test classes don't see generated lombok code
I am using IntelliJ IDEA 2016.3 + lombok plugin with the following structure:
Edit: this is the Module Content Root configuration:
Everything works as expected in
src/main/java
andsrc/test/java
, but classes insrc/integration-test
andsrc/end-to-end-test
don't see the generated lombok code (so no autocomplete).I can still run the tests without any issue though.
Does anyone have any idea what I should do to benefit from auto-complete from these other test source folders?
Thanks!
-
Lombok creates multiple setters
I am new to lombok. I just annotated the pojo with @Data annotation, and it has generated multiple methods. do you have an idea what on what can be the reason?
Here is the code,
package com.stack.model; import lombok.Data; @Data public class Animal { private Integer id; private String name; }
And, I am getting multiple errors. The default constructor is never generated, and ambiguous methods.
-
Custom serialized and deserialized field names with lombok
Is there a way to specify different serialized/deserialized JSON field names without having to write out both getter and setter methods explicitly, perhaps using lombok getters and setters?
As similar to this example, the following code permits incoming JSON to be deserialized to a different POJO field name. It also causes the POJO field name to be serialized as is:
public class PrivacySettings { private String chiefDataOfficerName; @JsonProperty("CDO_Name__c") private void setChiefDataOfficerName(String chiefDataOfficerName) { this.chiefDataOfficerName = chiefDataOfficerName; } @JsonProperty("chiefDataOfficerName") private String getChiefDataOfficerName() { return chiefDataOfficerName; } }
This seems verbose, but I haven't been able to get this to work with @Getter and @Setter. I did see that Jackson supports @JsonAlias which would probably help in this particular example, but I also have need to serialize with a different name.
Seems like this should be very simple, something like:
@Getter @Setter public class PrivacySettings { @JsonSetter("CDO_Name__c") @JsonGetter("chiefDataOfficerName") private String chiefDataOfficerName; }
But of course this is not valid.