architecture | One kind of boilerplate for writing Android apps | Architecture library
kandi X-RAY | architecture Summary
kandi X-RAY | architecture Summary
One kind of boilerplate for writing Android apps using android official architecture component approach
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a cubic gradient drawable for the given base color and gravity .
- Checks if the service is currently in the service process .
- Read a text file .
- Draws children in a RecyclerView .
- Sets the translation .
- Creates a RippleDrawable for the given palette .
- Creates an int property .
- Converts milliseconds to milliseconds .
- Disables system soft keyboard on an EditText .
- Interpolate the linear interpolation function .
architecture Key Features
architecture Examples and Code Snippets
Community Discussions
Trending Discussions on architecture
QUESTION
I have a need to truncate a float to the nearest power of 10. For example, 1.1 would truncate to 1.0 and 4.7e3 would truncate to 1e3. I am currently doing it with the seemingly complicated powf(10,floorf(log10f(x)))
. I am wondering whether there is a better performing (as in faster execution speed) solution? My target CPU architecture is both x86-64 and arm64.
ANSWER
Answered 2022-Apr-15 at 16:36I would say don't sweat it. Unless the program is spending a large proportion of its time doing this truncation, it's not worth optimising what is probably super-fast anyway. But if you wanted to optimise for your common cases (1e-2 <= x <= 10), then you might try using 32-bit integer arithmetic to compare with the binary representations of 1e-2, 1e-1, 1, and 10 (for instance, 1e-1 is 0x3dcccccd) ; if it's outside that range, you can fall back on the floating point version. Only experimentation will determine if this actually runs faster.
QUESTION
I've got a project that is working fine in windows os but when I switched my laptop and opened an existing project in MacBook Pro M1. I'm unable to run an existing android project in MacBook pro M1. first I was getting
Execution failed for task ':app:kaptDevDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException (no error message)
this error was due to the Room database I applied a fix that was adding below library before Room database and also changed my JDK location from file structure from JRE to JDK.
...kapt "org.xerial:sqlite-jdbc:3.34.0"
ANSWER
Answered 2022-Apr-04 at 18:41To solve this on a Apple Silicon M1 I found three options
AUse NDK 24
QUESTION
Updated to the Xcode 13 beta, now I can't build the project due to an error in several pods
Older Xcode launches an app on iOS 15 too long
I use M1, maybe this is due to architecture
...ANSWER
Answered 2021-Aug-25 at 21:20That remark isn't an actual error, just a warning. The real error can be found in the nested Compile Swift source files
under the top level section with the same name. Expand the logs for this command and you should see the actual error.
QUESTION
Dart SDK officially supports ARM64 and as of now, 2.14.2 is the latest (stable) Dart SDK that has support for ARM64. Though it was the same version that was bundled in my Flutter setup, it seemed to run on Intel architecture (Activity monitor shows dart processes running on Intel).
I manually tried replacing the dart SDK on my flutter installation bu replacing flutter-directory/bin/cache/dart-sdk/
with the contents of a zip file of the Dart SDK made for ARM64, downloaded from dart.dev archive. But trying to run an app on an Android emulator (which runs on ARM64 and was working on my old Flutter setup), throws this error:
ANSWER
Answered 2021-Sep-29 at 17:46It seems it can't be used with Flutter yet, as seen in:
Apple Silicon support in the Dart SDK
[...] Note that the Dart SDK bundled in the Flutter SDK doesn’t have these improvements yet.
https://medium.com/dartlang/announcing-dart-2-14-b48b9bb2fb67
[Announcing Dart 2.14][ScreenShot]: https://i.stack.imgur.com/N8Qcc.png
And:
Get the Dart SDK
[...] As of Flutter 1.21, the Flutter SDK includes the full Dart SDK. So if you have Flutter installed, you might not need to explicitly download the Dart SDK. Consider downloading the Dart SDK if any of the following are true:
- You don’t use Flutter.
- You use a pre-1.21 version of Flutter.
- You want to reduce disk space requirements or download time, and your use case doesn’t require Flutter. For example, you might have a continuous integration (CI) setup that requires Dart but not Flutter.
[Get the Dart SDK][ScreenShot]: https://i.stack.imgur.com/rawJV.png
QUESTION
I'm new to Android development and I'm currently building my first real app. I'm trying to implement a MVVM architecture and because of that I'm having a viewModel for each fragment and each viewModel has a viewModelFactory. At least, this is how I understood it has to be.
I use the boilerplate code everyone seems to use for the factory:
...ANSWER
Answered 2022-Feb-25 at 16:53It seems like you are either directly or indirectly (through some other library) depending on Lifecycle 2.5.0-alpha01
.
As per this issue:
You need to temporarily add following to your
build.gradle
:
QUESTION
I'm trying to wrap my head around the x86 instruction encoding format. All the sources that I read still make the subject confusing. I'm starting to understand it a little bit but one thing that I'm having trouble with understanding is how the CPU instruction decoder differentiates an opcode prefix from an opcode.
I'm aware that the whole format of the instruction basically depends on the opcode (with extra bit fields defined in the opcode of course). Sometimes the instruction doesn't have a prefix and the opcode is the first byte. How would the decoder know?
I'm assuming that the instruction decoder would be able to tell the difference because opcode bytes and prefix bytes would not share the same binary values. So the decoder can tell if the unique binary number in the byte is an instruction or a prefix. For example (In this example we will stick to single byte opcodes) a REX or LOCK prefix would not share the same byte value as any opcode in the architecture's instruction set.
...ANSWER
Answered 2022-Feb-23 at 02:47Traditional (single-byte) prefixes are different from opcode bytes like you said, so a state machine can just remember which prefixes it's seen until it gets to an opcode byte.
The 0f
escape byte for 2-byte opcodes is not really a prefix. It has to be contiguous with the 2nd opcode byte. Thus, following a 0f
, any byte is an opcode, even if it's something like f2
that would otherwise be a prefix. (This also applies following 0f 3a
or 0f 38
2-byte escapes for SSSE3 and later, or VEX/EVEX prefixes that encode one of those escape sequences).
If you look at an opcode map, there are no entries that are ambiguous between single-byte prefix and opcode. (e.g. http://ref.x86asm.net/coder64.html, and notice how the 2-byte 0F .. opcodes are listed separately).
The decoders do have to know the current mode for this (and other things); for example x86-64 removed the 1-byte inc/dec reg
opcodes for use as REX prefixes. (x86 32 bit opcodes that differ in x86-x64 or entirely removed). We can even use this difference to write polyglot machine code that runs differently when decoded in 32-bit vs. 64-bit mode, or even distinguish all 3 mode sizes.
x86 machine code is a byte stream that's not self-synchronizing (e.g. a ModRM or an immediate can be any byte). The CPU always knows where to start decoding from, either a jump target or the byte after the end of a previous instruction. That's the start of the instruction (including prefixes).
Bytes in memory are just bytes, only becoming instructions when they're decoded by the CPU. (Although in normal programs, simply disassembling from the top of the .text
section does give you the program's instructions. Self-modifying and obfuscated code are not normal.)
Multi-byte VEX and EVEX prefixes aren't that simple in 32-bit mode. For example VEX prefixes overlap with invalid encodings of LES and LDS in modes other than 64-bit. (The c4
and c5
opcodes for LES and LDS are always invalid in 64-bit mode, except as VEX prefixes.) https://wiki.osdev.org/X86-64_Instruction_Encoding#VEX.2FXOP_opcodes
In legacy / compat modes, there weren't any free bytes left that weren't already opcodes or prefixes when AVX (VEX prefixes) and AVX-512 (EVEX prefix), so the only room for extensions was as encodings for opcodes that are only valid with a limited set of ModRM bytes. (e.g. LES / LDS require a memory source, not register - this is why some bits are inverted in VEX prefixes, so the top 2 bits of the byte after c4
or c5
will always be 1
in 32-bit mode instead of 0
.
That's the "mode" field in ModRM, and 11
means register).
(Fun fact: VEX prefixes are not recognized in 16-bit real mode, apparently because some software used the same invalid encodings of LES / LDS as intentional traps, to be sorted out in the #UD exception handler. VEX prefixes are recognized in 16-bit protected mode, though.)
AMD64 freed up several bytes by removing instructions like AAM, as well as LES/LDS (and the one-byte inc
/dec reg
encodings for use as REX prefixes), but CPU vendors have continued to care about 32-bit mode and not added any extensions that are only available in 64-bit mode which could simply take advantage of those free opcode bytes. This means finding ways to cram new instruction encodings into increasingly small gaps in 32-bit machine code. (Often via mandatory prefixes, e.g. rep bsr
= lzcnt
on CPUs with that feature, which gives different results.)
So the decoders in modern CPUs that support AVX / BMI1/2 have to look at multiple bytes to decide whether this is a prefix for a valid AVX or other VEX-encoded instruction, or in 32-bit mode if it should decode as LES or LDS. (And I guess look at the rest of the instruction to decide if it should #UD).
But modern CPUs are looking at 16 or 32 bytes at a time anyway to find instruction boundaries in parallel. (And then later feed those groups of instruction bytes to actual decoders, again in parallel.) https://www.realworldtech.com/sandy-bridge/4/
Same goes for the prefix scheme used by AMD XOP, which is a lot like VEX.
Agner Fog's blog article Stop the instruction set war from 2009 (soon after AVX was announced, before the first hardware supporting it) has a table of remaining unused coding space for future extensions, and some notes about it being "assigned" to AMD, Intel, or Via.
Related / examples- How to tell the length of an x86 instruction? (including my answer) has some more details about x86 machine code.
- https://codegolf.stackexchange.com/questions/133486/find-an-illegal-string/133622#133622 (on codegolf.SE - the shortest sequence of bytes that will definitely #UD fault if it's not jumped over. It has to be long enough that it can't be consumed by the CPU as the immediate for a
mov r64, imm64
for example.) - Why does x/i on gdb give different results then disassemble? - an example of starting decode in the wrong place and decoding the middle of another instruction as something else.
(This is not really related to prefixes, but in general seeing how the rules apply to weird cases can help understand exactly things work.)
A software disassembler does need to know a start point. This can be problematic if obfuscated code mixes code and data, and actual execution jumps to places you wouldn't get if you just assume that you can decode in order without following jumps.
Fortunately compiler-generated code doesn't do that so naive static disassembly (e.g. by objdump -d
or ndisasm
, as opposed to IDA) finds the same instruction boundaries that actually running the program will.
This is not a problem for running obfuscated machine code; the CPU just does what it's told, and never cares about bytes before the place you tell it to jump to. Disassembling without running / single-stepping the program is the hard thing, especially with the possibility of self-modifying code and jumps to what a naive disassembler would think was the middle of an earlier instruction.
Obfuscated machine code can even have an instruction decode one way, then jump back into what was the middle of that instruction, for a later byte to be the opcode (or prefix + opcode). Modern CPUs with uop caches or that mark instruction boundaries in I-cache run slow (but correctly) if you do this, so it's more of a fun code-golf trick (extreme code-size optimization at the expense of speed) or obfuscation technique.
For an example of this, see my codegolf.SE x86 machine code answer to Golf a Custom Fibonacci Sequence. I'll excerpt the disassembly that lines up with what the CPU sees after looping back to cfib.loop
, but note that the first iteration decodes differently. So I'm using just 1 byte outside the loop instead of 2 to effectively jump into the middle for the start of the first iteration. See the linked answer for a full description and the other disassembly.
QUESTION
Am starting off in blockchain development using the book Mastering Blockchain - A deep dive into distributed ledgers, consensus protocols, smart contracts, DApps, cryptocurrencies, Ethereum,
Am using WSL with geth version 1.10.9.
...ANSWER
Answered 2021-Oct-11 at 23:20It appears 1.10.9-stable version has a problem and is returning a -rpc error. GETH 1.10.8-stable version works fine when running the geth command with --rpc
QUESTION
I am getting an error when trying to save a model with data augmentation layers with Tensorflow version 2.7.0.
Here is the code of data augmentation:
...ANSWER
Answered 2022-Feb-04 at 17:25This seems to be a bug in Tensorflow 2.7 when using model.save
combined with the parameter save_format="tf"
, which is set by default. The layers RandomFlip
, RandomRotation
, RandomZoom
, and RandomContrast
are causing the problems, since they are not serializable. Interestingly, the Rescaling
layer can be saved without any problems. A workaround would be to simply save your model with the older Keras H5 format model.save("test", save_format='h5')
:
QUESTION
This question is about architecture more than coding.
Here's the case. In React sometimes we want to hide components. For example, when user opens new page in SPA, when some toast is closed, etc. We can hide them with adding display: none
. Or we can remove them from the virtual DOM.
ANSWER
Answered 2021-Sep-01 at 07:22Well if you want to use lifecycles there are workarounds for that as well. if you are using functional components then you can manage the rerenders using the dependency props.
Its true dom size can slow you down if you use it excessively https://web.dev/dom-size/ But is better if those components are constantly being updated rather then rendering a new component on demand.
If its a list of items and its gigantic i suggest you to take a look at https://react-window.vercel.app/#/examples/list/fixed-size or https://bvaughn.github.io/react-virtualized/#/components/List
QUESTION
I'm trying to get a django project up and running, which depends on GDAL library. I'm working on a M1 based mac.
Following the instructions on official Django docs, I've installed the necessary packages via brew
...ANSWER
Answered 2021-Nov-23 at 07:35Try using the new arm version of python!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install architecture
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page