vipulasri / ticketview Goto Github PK
View Code? Open in Web Editor NEWAn Android library to implement TicketView in android with normal, rounded and scallop corners
License: Apache License 2.0
An Android library to implement TicketView in android with normal, rounded and scallop corners
License: Apache License 2.0
When I try to unit Test with robolectric, I got errors, I think it is about mocking...
I can not call as TicketView class and mock.
Error:
error: attribute ticketBorderColor (aka com.component.test:ticketBorderColor) not found.
How can we mock the view?
How to set color for shadow TicketView
I have this Render Problem in the xml, i cant see the example of ticketview in the preview mode
java.lang.NoClassDefFoundError: Could not initialize class android.renderscript.RenderScript
at com.vipulasri.ticketview.TicketView.generateShadow(TicketView.java:272)
at com.vipulasri.ticketview.TicketView.doLayout(TicketView.java:254)
at com.vipulasri.ticketview.TicketView.onDraw_Original(TicketView.java:110)
at com.vipulasri.ticketview.TicketView.onDraw(TicketView.java)
at android.view.View.draw(View.java:19156)
at android.view.View.draw(View.java:19026)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4256)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4256)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4042)
at android.view.View.draw(View.java:19024)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4256)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4256)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4042)
at android.view.View.draw(View.java:19159)
at android.view.View.draw(View.java:19026)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4256)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4256)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4042)
at android.view.View.draw(View.java:19024)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4256)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:63)
at android.view.ViewGroup.drawChild(ViewGroup.java:4256)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4042)
at android.view.View.draw(View.java:19159)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:403)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:541)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:424)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:108)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136)
at com.android.tools.idea.rendering.RenderTask.lambda$renderInner$5(RenderTask.java:760)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Hi, I'm trying to use your library in my application but I'm having some issues about:
Let me know and thanks for your work!
first of all, congratulations for your repository. I'm trying to use with the recycler view and create a list view of ticket view. But it is not displayed. Do you have a similar example?
I try to re-write the class but it is very hard to make it become a View Group can help update ? Thank YOU
I'm using it in a RecyclerView and it crashes the app with this error?
android.renderscript.RSIllegalArgumentException: Radius out of range (0 < r <= 25).
at android.renderscript.ScriptIntrinsicBlur.setRadius(ScriptIntrinsicBlur.java:82)
at com.vipulasri.ticketview.BlurBuilder.blur(BlurBuilder.java:20)
at com.vipulasri.ticketview.TicketView.generateShadow(TicketView.java:281)
at com.vipulasri.ticketview.TicketView.doLayout(TicketView.java:262)
at com.vipulasri.ticketview.TicketView.onDraw(TicketView.java:111)
Here's the TicketView I'm using
it shows perfectly fine in the preview btw.
<com.vipulasri.ticketview.TicketView
android:id="@+id/ticketView"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="5dp"
app:ticketBackgroundColor="@color/white"
app:ticketCornerRadius="10dp"
app:ticketCornerType="rounded"
app:ticketDividerColor="#D9D9D9"
app:ticketDividerDashGap="6dp"
app:ticketDividerDashLength="8dp"
app:ticketDividerPadding="5dp"
app:ticketDividerType="dash"
app:ticketDividerWidth="1dp"
app:ticketElevation="3dp"
app:ticketOrientation="horizontal"
app:ticketScallopPositionPercent="77"
app:ticketScallopRadius="10dp"
app:ticketShadowColor="@color/black"
app:ticketShowBorder="false"
app:ticketShowDivider="true" />
Paint provide setShadowLayer https://developer.android.com/reference/android/graphics/Paint.html#setShadowLayer(float, float, float, int) for customized shadow. Use this method can remove the api version restriction and less code.
Ticket view just disappears when you try to wrap it inside ScrollView
Does this library can support multiple divisions like for example i need 3 sections for my ticket? Thanks!
Ticket View Not Display in nested scrollview
how to implement nested scroll view ?
I have a view which contains multiple textviews which will be "part of the ticket", but when I increase one of the textviews number of lines from 1 to 2, it works on the preview, but in real-time execution the resize doesn't work.
`
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/fakeToolbar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:backgroundTint="?attr/transparent"
android:elevation="1dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.08"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ticketPreviewLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/darkBackgroundColor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/fakeToolbar">
<com.vipulasri.ticketview.TicketView
android:id="@+id/ticketView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="16dp"
android:elevation="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:ticketCornerRadius="4dp"
app:ticketCornerType="rounded"
app:ticketOrientation="vertical"
app:ticketScallopRadius="12dp"/>
<TextView
android:id="@+id/ticketValidity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:elevation="4dp"
android:text="gültig in 110 • 1 Stunde"
android:textColor="?attr/secondaryTextColor"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/ticketType"
app:layout_constraintEnd_toStartOf="@+id/ticketPrice"
app:layout_constraintStart_toStartOf="@id/ticketView"
app:layout_constraintTop_toTopOf="@id/ticketPrice"
app:layout_constraintVertical_bias="0" />
<TextView
android:id="@+id/ticketPrice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:elevation="4dp"
android:text="2,70 €"
app:layout_constraintBottom_toTopOf="@id/ticketPriceLevel"
android:textColor="?attr/defaultTextColor"
android:textStyle="bold"
android:textSize="16sp"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="@id/ticketView"
app:layout_constraintTop_toTopOf="@id/ticketView" />
<TextView
android:id="@+id/ticketPriceLevel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:elevation="4dp"
android:layout_marginBottom="8dp"
android:text="Preisstufe 1"
android:textColor="?attr/secondaryTextColor"
android:textSize="16sp"
app:layout_constraintVertical_bias="0"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/ticketType"
app:layout_constraintEnd_toEndOf="@id/ticketView"
app:layout_constraintTop_toBottomOf="@id/ticketPrice" />
<TextView
android:id="@+id/ticketType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:elevation="4dp"
android:text="Einzelfahrkarte"
android:maxLines="2"
android:textColor="?attr/themeTextColor"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@id/ticketView"
app:layout_constraintBottom_toBottomOf="@id/ticketView"
app:layout_constraintStart_toStartOf="@id/ticketView"
app:layout_constraintTop_toTopOf="@id/ticketView" />
<TextView
android:id="@+id/ticketBought"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:elevation="4dp"
android:text="Gekauft:"
android:textColor="?attr/secondaryTextColor"
android:textStyle="bold"
android:textSize="16sp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="@id/ticketView"
app:layout_constraintVertical_bias="1"
app:layout_constraintTop_toBottomOf="@id/ticketType"
app:layout_constraintBottom_toTopOf="@id/ticketBoughtDate" />
<TextView
android:id="@+id/ticketBoughtDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginBottom="20dp"
android:elevation="4dp"
android:text="Heute 12:20"
app:layout_constraintTop_toBottomOf="@id/ticketBought"
android:textColor="?attr/defaultTextColor"
android:textSize="16sp"
app:layout_constraintVertical_bias="0"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/ticketView"
app:layout_constraintEnd_toEndOf="@id/ticketView" />
<TextView
android:id="@+id/ticketRemainingValidity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:elevation="4dp"
android:text="Noch 25 min gültig"
android:textColor="?attr/defaultTextColor"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/ticketBoughtDate"
app:layout_constraintEnd_toStartOf="@+id/ticketBoughtDate"
app:layout_constraintStart_toStartOf="@id/ticketView" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/surfaceColor"
android:padding="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ticketPreviewLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>`
Can this be done?
Your GitHub release mentions that 1.1.2 is on androidx but the actual artifact in maven references the old support lib (See pom.xml here: https://search.maven.org/artifact/com.vipulasri/ticketview/1.1.2/aar)
Also noticed artifact was last updated in Feb 2021 while GH release was pushed Sep 2020, maybe the artifact was inadvertently overwritten?
HI, I am unable to view on ticket view. if i used transparent background it gives gray color background in devices. please help me with including layout over ticketview
Hi, first thanks for creating such an awesome library.
Is it possible to change the attribute names so it won't collide with other libraries? (like adding ticketview_ or ticket as a prefix(like the ticketElevation
?)
I want to use this library but currently it attributes collides with other libraries i am using. (in my case the orientation resource name has conflicts)
AGPBI: {"kind":"error","text":"Attribute "orientation" already defined with incompatible format.","sources":[{"file":"/Users/xxxx/.gradle/caches/transforms-1/files-1.1/{other-library-name}/f85a8ad0b0222b4a35fd6da2e9a9be73/res/values/values.xml","position":{"startLine":86,"startColumn":4,"startOffset":5685,"endColumn":51,"endOffset":5732}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Original attribute defined here.","sources":[{"file":"/Users/xxx/.gradle/caches/transforms-1/files-1.1/{other-library-name}/f85a8ad0b0222b4a35fd6da2e9a9be73/res/values/values.xml","position":{"startLine":86,"startColumn":4,"startOffset":5685,"endColumn":51,"endOffset":5732}}],"original":"","tool":"AAPT"}
Stating from here
https://developer.android.com/studio/projects/android-library
Resource merge conflicts
The build tools merge resources from a library module with those of a dependent app module. If a given resource ID is defined in both modules, the resource from the app is used.
If conflicts occur between multiple AAR libraries, then the resource from the library listed first in the dependencies list (toward the top of the dependencies block) is used.
To avoid resource conflicts for common resource IDs, consider using a prefix or other consistent naming scheme that is unique to the module (or is unique across all project modules).
Hi Vipul Asri, thanks for this nice view
but i have a question about how to use this view?
is there any gradle work or something to get this view as a library?
thanks again dude :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.