Gradle can't find protobuf generated class (Android DataStore) - android-studio

I introduced the dependency by referring to the documentation
implementation "androidx.datastore:datastore:1.0.0"
then defined the schema app/src/main/proto/.proto
syntax = "proto3";
option java_package = "com.freedom.android.config.work";
option java_multiple_files = true;
message WorkItemVO {
bool enabled = 1;
string title = 2;
string repeat_interval = 3;
string repeat_interval_timeUnit = 4;
string last_update_time = 5;
string last_update_result = 6;
}
after app build, But build/generated/source/proto/ did not generate WorkItemVO class files.
Can you tell me what I'm missing?

Related

Creating Root Signature failed after changing version 1.1

I mimimized my code to the problem part.
I used to create root signature version 1.0 with no problem. Then I tried to upgrade my code to compatible with root signature version 1.1 if the hardware support.
D3D12_ROOT_DESCRIPTOR1 CBV1rootDescriptor;
CBV1rootDescriptor.ShaderRegister = 0;
CBV1rootDescriptor.RegisterSpace = 0;
CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE;
D3D12_ROOT_DESCRIPTOR1 CBV2rootDescriptor;
CBV2rootDescriptor.ShaderRegister = 1;
CBV2rootDescriptor.RegisterSpace = 0;
CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE;
D3D12_ROOT_PARAMETER1 rootParam[2];
rootParam[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
rootParam[0].Descriptor = CBV1rootDescriptor;
rootParam[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
rootParam[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
rootParam[1].Descriptor = CBV2rootDescriptor;
rootParam[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
D3D12_FEATURE_DATA_ROOT_SIGNATURE featureData = {};
featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_1;
if (FAILED(device->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &featureData, sizeof(featureData))))
{
featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0;
}
D3D12_ROOT_SIGNATURE_DESC1 rootSigDesc = {};
rootSigDesc.NumParameters = _countof(rootParam);
rootSigDesc.pParameters = rootParam;
rootSigDesc.NumStaticSamplers = 0;
rootSigDesc.pStaticSamplers = nullptr;
rootSigDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
D3D12_VERSIONED_ROOT_SIGNATURE_DESC VersionedrootSigDesc = {};
VersionedrootSigDesc.Version = featureData.HighestVersion;
VersionedrootSigDesc.Desc_1_1 = rootSigDesc;
ID3DBlob* serializedRootSig = nullptr;
ID3DBlob* errorBlob = nullptr;
ThrowIfFailed(D3DX12SerializeVersionedRootSignature(&VersionedrootSigDesc, featureData.HighestVersion, &serializedRootSig, &errorBlob));
The code will throw if I run like above, I checked featureData.HighestVersion is 1.1. If I forced featureData.HighestVersion to 1.0, the code will pass. And if I remove the second rootParam[1], only use 1 rootParam, even featureData.HighestVersion is 1.1, the code will pass. Does version 1.1 has some restrictions on CBV on root descriptor? (Windows 10 21H2 OS Build 19044.1706, Visual Studio 2022 community 17.2.2)
D3D12_ROOT_DESCRIPTOR1 CBV2rootDescriptor;
CBV2rootDescriptor.ShaderRegister = 1;
CBV2rootDescriptor.RegisterSpace = 0;
CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE;
Since I copied and pasted for CBV2, I didn't change CBV1rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE; to CBV2rootDescriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE; and I didn't initialize CBV2rootDescriptor, so CBV2rootDescriptor.Flags could be random number which cause the creation failed. I found this when I initialize CBV2rootDescriptor to {}, then the failure gone, which made to to look at each assignment again and found CBV1rootDescriptor.Flags didn't change to CBV2rootDescriptor.Flags.

Convert a haxe.Int64 to a Float?

How can I convert a haxe.Int64 to a Float?
I've got something like
var x = haxe.Int64.parseString("1000000000000");
and I'd like to convert that to a Float. I've looked in the Int64 api docs, have found fromFloat, ofInt, and toInt, but there's no toFloat method in there.
I cannot see that functionality in the Haxe standard library either, I checked Int64 and Int64Helper.
However the MIT-licensed thx.core library does include an implementation, see below: https://github.com/fponticelli/thx.core/blob/master/src/thx/Int64s.hx#L137
using haxe.Int64;
class Int64s {
static var zero = Int64.make(0, 0);
static var one = Int64.make(0, 1);
static var min = Int64.make(0x80000000, 0);
/**
Converts an `Int64` to `Float`;
Implementation by Elliott Stoneham.
*/
public static function toFloat(i : Int64) : Float {
var isNegative = false;
if(i < 0) {
if(i < min)
return -9223372036854775808.0; // most -ve value can't be made +ve
isNegative = true;
i = -i;
}
var multiplier = 1.0,
ret = 0.0;
for(_ in 0...64) {
if(i.and(one) != zero)
ret += multiplier;
multiplier *= 2.0;
i = i.shr(1);
}
return (isNegative ? -1 : 1) * ret;
}
}
Using the library method worked for me, tested on the JavaScript target like so:
import haxe.Int64;
import thx.Int64s;
class Main {
public static function main():Void {
var x:Int64 = haxe.Int64.parseString("1000000000000");
var f:Float = thx.Int64s.toFloat(x);
trace(f); // Prints 1000000000000 to console (on js target)
}
}
Alternatively, you can convert Int64 to Float yourself by combining high/low halves:
class Test {
static function main() {
var x = haxe.Int64.parseString("1000000000000");
var f = x.high * 4294967296. + (x.low >>> 0);
trace("" + x);
trace(f);
}
}
Here,
4294967296. is a float literal for unsigned 2^32;
>>> 0 is required because the lower half can be signed.
Or, for a naive conversion method, you can use:
var f = Std.parseFloat(haxe.Int64.toStr(x));
You may want to try to use FPHelper class. It contains a set of methods to convert Int types to Float / Double.
import haxe.io.FPHelper;
class Test {
static function main() {
var x = haxe.Int64.parseString("1000000000000");
var f = FPHelper.i64ToDouble(x.low, x.high);
trace(f);
}
}
See https://try.haxe.org/#CDa93

fetch data from website using c#

input link for ex is "http://www.unionstationdc.com".I need to programmatically go here "http://www.unionstationdc.com/contact" & fetch contents of this page. I have written this code below but of no use.
doc = hw.Load(link);
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[#href]"))
{
bool hreflink = link.GetAttributeValue("p", true);
if (hreflink == true)
{
attr = link.Attributes;
att = attr.AttributesWithName("p");
for (int i = 0; i < attr.Count; i++)
{
name = attr[i].Name;
value = attr[i].Value;
string trim = value.Trim('/');
string uppercase = trim.ToUpper();
if (uppercase.Contains("CONTACT"))
{
string path = attr[i].XPath;
MessageBox.Show(path);
}
}
}
}
Please help me to finish .... Thanks in advance

'Strings' does not exist in the current context

I converted the following function from vb.net to c# but I cannot figure this out.
Error 4 The name 'Strings' does not exist in the current context
public string GetBetween(string StringText)
{
string functionReturnValue = null;
string TMP = null;
string FromS = null;
string ToS = null;
FromS = "<Modulus>";
ToS = "</Modulus>";
TMP = Strings.Mid(StringText, Strings.InStr(StringText, FromS) + Strings.Len(FromS), Strings.Len(StringText));
TMP = Strings.Left(TMP, Strings.InStr(TMP, ToS) - 1);
functionReturnValue = TMP;
return functionReturnValue;
}
Strings is a VB.net class. You'd have to reference the Microsoft.VisualBasic.dll assembly and use the Microsoft.VisualBasic namespace if you'd want to be able to use it.
It would be better if you just avoided using VB.net methods whenever possible.
public string GetBetween(string str, string start = "<Modulus>", string end = "</Modulus>")
{
var startIndex = str.IndexOf(start);
var endIndex = str.LastIndexOf(end);
if (startIndex == -1 || endIndex == -1 || startIndex > endIndex)
return str;
return str.Substring(startIndex + start.Length,
str.Length - start.Length - end.Length);
}
Add using Microsoft.VisualBasic; in the header

Replace string does not work in python 3.2

I have a template file: 'template.txt' like below:
class Core_Model_DbTable_{table_name} extends YouNet_Db_Table
{
const TYPE_PRINTED = 1;
const TYPE_DIGITAL = 2;
protected $_name = '{table_name}';
protected $_rowClass = 'Core_Model_{table_name:short}';
}
And I use Python 3.2 to read that file and try to replace:
{table_name} => Coupons
{table_name:short} => Coupon
and here my code:
in_file = open("template.txt","r")
text = in_file.read()
in_file.close()
txt = text.replace("{table_name}","Coupons")
txt = text.replace("{table_name:short}","Coupon")
But the output only shows the result:
c:\Python32\python.exe builder.py
<?php
class Core_Model_DbTable_{table_name} extends YouNet_Db_Table
{
const TYPE_PRINTED = 1;
const TYPE_DIGITAL = 2;
protected $_name = '{table_name}';
protected $_rowClass = 'Core_Model_Coupon';
}
Could you please tell me anything is wrong here?
You seem to have misspelled the name of your variable: "txt" vs "text".

Resources