This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->

Overview

PlaceHolderView
An advance view for lists and stacks

Download 2.x Mindorks Mindorks Community License

Some Implementations


Documentation

You can find the PlaceHolderView documentation here which has extended usage instructions and other useful information.


About PlaceHolderView

Some of the views in PlaceHolderView library is build on top of RecyclerView and rest are written in its own.

All the annotations are processed during build time to generate the binding classes

There are two versions available for use.

  1. Old version (branch 1.x): Uses Java reflection
  2. New version (branch 2.x): Uses Annotation Processing.

This library provides 5 different type of views

  1. PlaceHolderView
    It is build on top of RecyclerView and abstracts most of the boiler plate. It provides APIs through annotations.

  2. InfinitePlaceHolderView
    It is build on PlaceHolderView and adds the functionality of handling load more views when the user has scrolled to the bottom of the list.

  3. ExpandablePlaceHolderView
    It is build on PlaceHolderView and creates ExpandableListView with parent-child relation.

  4. SwipePlaceHolderView
    It is not build on RecyclerView. Its a ground up implementation. We can create a variety of card stack views using this class. It provides APIs that could easily build Tinder like cards.

  5. SwipeDirectionalView
    It is build on top of SwipePlaceHolderView. It provides callbacks for swipe directions and touch events.

How to use newer version (2.x branch) with annotation processing

Gradle dependency:

Java

dependencies {
    ...
    compile 'com.mindorks.android:placeholderview:1.0.3'
    annotationProcessor 'com.mindorks.android:placeholderview-compiler:1.0.3'

    // RecyclerView dependency is added to override the
    // default 25.4.1 RecyclerView dependency used by placeholderview.
    // If you are using the support libraries other than 25.x in the project
    compile 'com.android.support:recyclerview-v7:<current-version>' // example: 27.1.0
}

Kotlin

dependencies {
    ...
    // RecyclerView dependency is added to override the
    // default 25.4.1 RecyclerView dependency stated by placeholderview
    // since we are using the 27.+ support libraries in the project
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'com.mindorks.android:placeholderview:1.0.3'
    kapt 'com.mindorks.android:placeholderview-compiler:1.0.3'
}

For use with Kotlin refer to Kotlin docs.

Migration:

It is super easy to migrate to 2.x branch library version.

To migrate from 1.x to 2.x see Migration doc here.


How to Use older version (1.x branch)

If you want to use older version of PlaceHoldeView that used reflection, then you can use below dependecies.

Gradle dependency:

dependencies {
    compile 'com.mindorks:placeholderview:0.7.3'
}

Dependency: It depends on the RecyclerView

Add below lines in your app's build.gradle if recyclerview above v7:25 is being used

    // NOTE: change the version of recyclerview same as the your project's support library version
    com.android.support:recyclerview-v7:25.+

Proguard Note:

If you are using proguard, then add this rule in proguard-project.txt

  -keepattributes *Annotation*
  -keepclassmembers class ** {
    @com.mindorks.placeholderview.annotations.** <methods>;
  }

If this library helps you in anyway, show your love ❤️ by putting a on this project ✌️

TO-DOs

  • Update/Refresh the View already shown in the stack.
  • Callback when a card comes on top of the stack.
  • Provide Undo for the entire swipe history.
  • Provide Sort for the PlaceHolderView.

License

   Copyright (C) 2016 Janishar Ali Anwar

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License

Comments
  • Undo is not working

    Undo is not working

    Hi! I have the following setup:

    mCardsContainer.builder`
                    .setDisplayViewCount(1)
                    .setSwipeDecor(SwipeDecor()
                            .setPaddingTop(10)
                            .setRelativeScale(0.01f))
    
            mCardsContainer.disableTouchSwipe()
    

    For SwipePlaceHolderView. When I'm doing the mCardsContainer.undoLastSwipe() nothing happens at all. Is this because of disableTouchSwipe?

    opened by JEuler 29
  • update events call upons

    update events call upons

    just a quick question if the holder support supports late update events in the view holder. for example, I got this hierarchy... PlaceHolderView . . PlaceHolderView . . . PlaceHolderView . . The Child Holder

    Can I possibly update this child with late event with http request?

    opened by jjhesk 21
  •  Unable to find constructor for com.mindorks.demo.swipe.TinderCard

    Unable to find constructor for com.mindorks.demo.swipe.TinderCard

    Caused by: java.lang.RuntimeException: Unable to find constructor for com.mindorks.demo.swipe.TinderCard at com.mindorks.placeholderview.Binding.getBinderInstance(Binding.java:47) at com.mindorks.placeholderview.Binding.bindSwipeViewResolver(Binding.java:67) at com.mindorks.placeholderview.SwipePlaceHolderView.getViewBinder(SwipePlaceHolderView.java:206) at com.mindorks.placeholderview.SwipePlaceHolderView.addView(SwipePlaceHolderView.java:211) at com.mindorks.demo.ActivityTinder.onPostCreate(ActivityTinder.java:71) at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1199) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6119)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)  at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107) 

    opened by specloli 18
  •     kotlin.UninitializedPropertyAccessException: lateinit property tvTitle has not been initialized

    kotlin.UninitializedPropertyAccessException: lateinit property tvTitle has not been initialized

    • PlaceHolderView: 1.0.3
    • Kotlin: 1.3.61

    `

    @Layout(R.layout.view_room_contract_item) class RoomContractItemView( val context: Context, val contract: RoomContractsQuery.RoomContract, val listener: ContractItemListener ) {

    @View(R.id.tvContractItemTitle)
    lateinit var tvTitle: TextView
    
    @View(R.id.tvContractItemRoom)
    lateinit var tvRoom: TextView
    
    @View(R.id.tvContractItemAddress)
    lateinit var tvAddress: TextView
    
    @View(R.id.tvContractItemTime)
    lateinit var tvTime: TextView
    
    interface ContractItemListener {
        fun onContractClick(id: Int)
    }
    
    @Click(R.id.contract_item_container)
    fun onClick() {
        listener.onContractClick(contract.id().toInt())
    }
    
    @Resolve
    fun resolve() {
        tvTitle.text = context.getString(R.string.contract_title, contract.id().toInt())
        tvRoom.text = RoomUtils.getFullRoomName(
            context, contract.room()?.name(),
            contract.room()?.motel()?.name()
        )
        tvAddress.text = contract.room()?.motel()?.address() ?: EMPTY_STRING
        tvTime.text = context.getString(
            R.string.date_range,
            DateTimeUtils.formatDate(contract.startDate()),
            DateTimeUtils.formatDate(contract.endDate())
        )
    }
    

    } Please help.

    `

    opened by thanhpd-teko 11
  •  java.lang.RuntimeException: Unable to find Class for com.mybataz.contest.h$SwipeViewBinder

    java.lang.RuntimeException: Unable to find Class for com.mybataz.contest.h$SwipeViewBinder

    04-21 12:06:20.460 1418-1418/? E/AndroidRuntime: FATAL EXCEPTION: main Process: bataz.com.bataz, PID: 1418 java.lang.RuntimeException: Unable to start activity ComponentInfo{bataz.com.bataz/com.mybataz.contest.RateNowActivity}: java.lang.RuntimeException: Unable to find Class for com.mybataz.contest.h$SwipeViewBinder PLEASE ADD >> annotationProcessor 'com.mindorks.android:placeholderview-compiler:' << in build.gradle at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2785) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6342) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770) Caused by: java.lang.RuntimeException: Unable to find Class for com.mybataz.contest.h$SwipeViewBinder PLEASE ADD >> annotationProcessor 'com.mindorks.android:placeholderview-compiler:' << in build.gradle at com.mindorks.placeholderview.c.a(Unknown Source) at com.mindorks.placeholderview.c.a(Unknown Source) at com.mindorks.placeholderview.SwipePlaceHolderView.a(Unknown Source) at com.mindorks.placeholderview.SwipePlaceHolderView.b(Unknown Source) at com.mybataz.contest.RateNowActivity.onPostCreate(Unknown Source) at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1200) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2706) ... 9 more Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mybataz.contest.h$SwipeViewBinder" on path: DexPathList[[zip file "/data/app/bataz.com.bataz-1/base.apk"],nativeLibraryDirectories=[/data/app/bataz.com.bataz-1/lib/arm, /data/app/bataz.com.bataz-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 16 more

    opened by Yellu 8
  • NullPointerException on bindSwipeCancelState() method.

    NullPointerException on bindSwipeCancelState() method.

    Hello @janishar , I have been facing crash on swipe cards while i cancel swipe of cards. It is a random crash but happning too many times.

    It happens while I have loaded cards on fragment and change the tab. When i came back and try to swiping a card. But when i cancel swiping card, app got crashed.

    Please look on this bug. Thanks.

    ## Stack Trace :

    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference at com.mindorks.placeholderview.SwipeViewBinder.bindSwipeCancelState(SwipeViewBinder.java:196) at com.mindorks.placeholderview.SwipePlaceHolderView.onResetView(SwipePlaceHolderView.java:593) at com.mindorks.placeholderview.SwipeViewBinder$2.onAnimationEnd(SwipeViewBinder.java:256) at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1116) at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171) at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722) at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:549) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

    opened by pragneshghoda 8
  • lateinit property has not been initialized

    lateinit property has not been initialized

    Sometimes i had "has not been initialized "

    data class Learn(var key:String="")
    @Layout(R.layout.item_word_stack)
    class LearnCard(private val context: Context,
                    private val learn: Learn,
                    private val speak: (text:String) -> Unit
                    ) {
    
        @View(R.id.btnSound)
        lateinit var btnSound : ImageView
    
        @View(R.id.txtEN)
        lateinit var txtEN: TextView
    
        @View(R.id.txtTR)
        lateinit var txtTR: TextView
    
    
        @SwipeView
        lateinit var swipeView: android.view.View
    
        @JvmField
        @Position
        var position: Int = 0
    
    
        @Resolve
        fun onResolved() {
            FirebaseFirestore.getInstance().collection(").document(l).get().addOnSuccessListener {
               val data = it.toObject(Word::class.java)
                txtEN.text = data?.EN
                txtTR.text = data?.TR
                swipeView.alpha = 1f
            }
    
        }
        @Click(R.id.btnSound)
        fun onClick(){
            speak(txtEN.text.toString())
        }
        @SwipeOutDirectional
        fun onSwipeOutDirectional(direction: SwipeDirection) {
            Log.d("DEBUG", "SwipeOutDirectional " + direction.name)
            if (direction.direction == SwipeDirection.TOP.direction) {
            }
        }
    
        @SwipeCancelState
        fun onSwipeCancelState() {
            Log.d("DEBUG", "onSwipeCancelState")
            swipeView.alpha = 1f
        }
    
        @SwipeInDirectional
        fun onSwipeInDirectional(direction: SwipeDirection) {
            Log.d("DEBUG", "SwipeInDirectional " + direction.name)
        }
    
        @SwipingDirection
        fun onSwipingDirection(direction: SwipeDirection) {
            Log.d("DEBUG", "SwipingDirection " + direction.name)
        }
        @SwipeIn
        fun  onSwipeIn(){
            Log.d("DEBUG","swipe in")
            DBHelper(context).updateData(learn.key)
        }
        @SwipeOut
        fun  onSwipeOut(){
            Log.d("DEBUG","swipe out")
            DBHelper(context).deleteKey(learn.key)
        }
    
    }
    
    opened by ekrmh 7
  • @Click behavior bug for SwipePlaceHolderView

    @Click behavior bug for SwipePlaceHolderView

    Hey,

    First of all, thanks for the awesome work on PlaceHolderView! It's by far the best and most professional Android library of its kind. :clap:

    I've noticed an odd behavior while using SwipePlaceHolderView. This is the context of the bug:

    1. I have a stack of 3 cards: A, B and C added in this order.
    2. Each card has a few buttons on it. I'm setting click handlers for the buttons with @Click.
    3. When I click a button on the first card of the deck (A), the last card of the deck (C) is triggered instead. C is not visible at all to the user as it's below in the deck.

    I've created a repository demonstrating this: PlaceHolderView bug. If you run it and click the buttons, you'll notice in the debug log that the wrong button is being triggered.

    Let me know if I'm doing something wrong - maybe this is not the proper way to do what I'm trying to achieve...

    In addition, if this is really a bug and you don't have time to tackle it in the library, perhaps I could help with a PR if you give me some pointers as to where the issue might be.

    Thanks again!

    opened by rsaksida 7
  • Continuation to #3

    Continuation to #3

    the fixes seem to send @Click to the TinderCard class. However, the click listeners in the MainActivity.java (for eg: R.id.acceptBtn, R.id.rejectBtn) do not work any more!

    I have not exactly tested with the above classes but have code that parallel's that. So, I'm guessing the issue exists here too. My code does not receive the click events for buttons sitting in the parent frame.

    opened by biskit 7
  • ImageView don't adjust to CardView's border

    ImageView don't adjust to CardView's border

    API 19 and lower: the ImageView don't adjust to CardView's border. On the example of tutorial "Tinder Swipe" (just changed app:cardCornerRadius="30dp"): API 19: https://www.dropbox.com/s/wzbjsl4ql0qr77x/Screenshot_1495827653.png?dl=0 API 24: https://www.dropbox.com/s/eidrkokvyq5me5s/Screenshot_1495827593.png?dl=0

    opened by tupikoff 6
  • Gravity issue

    Gravity issue

    Hi! Thank you for the cool library first of all. I have a problem using it. So, I have the following code in my Relative layout. So, it is just the all screen, you know.

    <com.mindorks.placeholderview.SwipePlaceHolderView android:id="@+id/cards_container" android:layout_width="match_parent" android:layout_height="match_parent" />

    I have the following layout for the cardview <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/pod_card" android:layout_width="@dimen/card_width" android:layout_height="@dimen/card_height" card_view:cardCornerRadius="4dp" card_view:cardElevation="4dp" card_view:cardUseCompatPadding="true">

    With that layout I have the cards placed in the center of screen. That is fine, i think. But I want to place content at the bottom, with some padding. So, I write this in my Activity:

    .setSwipeDecor(new SwipeDecor() .setViewGravity(Gravity.BOTTOM) .setRelativeScale(0.01f));

    Am I correct, that this should place the content at the bottom of view? I see that it is showing the cards content at the center.

    opened by JEuler 6
  • Empty method with @Click annotation make app crash: NullPointerException

    Empty method with @Click annotation make app crash: NullPointerException

    Hi, When you declare a method that content is empty in the ChildView, when you click on the parent item, Appp crash.

    com.mindorks.placeholderview.ViewBinder in bindClick at line 152
    com.mindorks.placeholderview.ViewBinder in bindView at line 45
    com.mindorks.placeholderview.ExpandableViewBinder in bindView at line 114
    com.mindorks.placeholderview.ViewAdapter in onBindViewHolder at line 50
    com.mindorks.placeholderview.ViewAdapter in onBindViewHolder at line 17
    androidx.recyclerview.widget.RecyclerView$Adapter in onBindViewHolder at line 6781
    androidx.recyclerview.widget.RecyclerView$Adapter in bindViewHolder at line 6823
    androidx.recyclerview.widget.RecyclerView$Recycler in tryBindViewHolderByDeadline at line 5752
    androidx.recyclerview.widget.RecyclerView$Recycler in tryGetViewHolderForPositionByDeadline at line 6019
    androidx.recyclerview.widget.RecyclerView$Recycler in getViewForPosition at line 5858
    androidx.recyclerview.widget.RecyclerView$Recycler in getViewForPosition at line 5854
    androidx.recyclerview.widget.LinearLayoutManager$LayoutState in next at line 2230
    androidx.recyclerview.widget.LinearLayoutManager in layoutChunk at line 1557
    androidx.recyclerview.widget.LinearLayoutManager in fill at line 1517
    androidx.recyclerview.widget.LinearLayoutManager in onLayoutChildren at line 612
    androidx.recyclerview.widget.RecyclerView in dispatchLayoutStep2 at line 3924
    androidx.recyclerview.widget.RecyclerView in onMeasure at line 3336
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.LinearLayout in measureChildBeforeLayout at line 1552
    android.widget.LinearLayout in measureVertical at line 842
    android.widget.LinearLayout in onMeasure at line 721
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.LinearLayout in measureChildBeforeLayout at line 1552
    android.widget.LinearLayout in measureVertical at line 842
    android.widget.LinearLayout in onMeasure at line 721
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.FrameLayout in onMeasure at line 194
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    androidx.coordinatorlayout.widget.CoordinatorLayout in onMeasureChild at line 733
    com.google.android.material.appbar.HeaderScrollingViewBehavior in onMeasureChild at line 95
    com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior in onMeasureChild at line 1556
    androidx.coordinatorlayout.widget.CoordinatorLayout in onMeasure at line 803
    android.view.View in measure at line 27131
    androidx.drawerlayout.widget.DrawerLayout in onMeasure at line 1119
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.FrameLayout in onMeasure at line 194
    androidx.appcompat.widget.ContentFrameLayout in onMeasure at line 143
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.LinearLayout in measureChildBeforeLayout at line 1552
    android.widget.LinearLayout in measureVertical at line 842
    android.widget.LinearLayout in onMeasure at line 721
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.FrameLayout in onMeasure at line 194
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.LinearLayout in measureChildBeforeLayout at line 1552
    android.widget.LinearLayout in measureVertical at line 842
    android.widget.LinearLayout in onMeasure at line 721
    android.view.View in measure at line 27131
    android.view.ViewGroup in measureChildWithMargins at line 7951
    android.widget.FrameLayout in onMeasure at line 194
    com.android.internal.policy.DecorView in onMeasure at line 1175
    android.view.View in measure at line 27131
    android.view.ViewRootImpl in performMeasure at line 4187
    android.view.ViewRootImpl in measureHierarchy at line 2936
    android.view.ViewRootImpl in performTraversals at line 3204
    android.view.ViewRootImpl in doTraversal at line 2618
    android.view.ViewRootImpl$TraversalRunnable in run at line 9971
    android.view.Choreographer$CallbackRecord in run at line 1010
    android.view.Choreographer in doCallbacks at line 809
    android.view.Choreographer in doFrame at line 744
    android.view.Choreographer$FrameDisplayEventReceiver in run at line 995
    android.os.Handler in handleCallback at line 938
    android.os.Handler in dispatchMessage at line 99
    android.os.Looper in loop at line 246
    android.app.ActivityThread in main at line 8653
    java.lang.reflect.Method in invoke
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 602
    com.android.internal.os.ZygoteInit in main at line 1130
    

    this bug took me one debugging day before find the problem.

    this is my method that causes this issue:

    @Click(R.id.btn)
    public void displayDetails()
    {
    //OnActionListener.dislayDetails();
    }
    
    i got this error because the ony intruction in my method is commented. So my function is empty ans app crash
    }
    
    opened by TechNov 0
  • Resource IDs as annotations non-final

    Resource IDs as annotations non-final

    Got the following error: Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them as annotation attributes

    Was wondering if this will be an issue in the future - and what should we do to fix the problem.

    opened by ZeeOne 0
  • Cannot load profile pictures for the Tinder like swap pictures.

    Cannot load profile pictures for the Tinder like swap pictures.

    Hello I downloaded and started the App. However, when I have the Tinder like swap view with the name and the University I do not see profile pictures. I only see the blue background. Do I have to declare anywhere that I need profile pictures from the given URLs for example? Or is it a bug?

    opened by StudFL 0
  • How to display a fragment inside the view?

    How to display a fragment inside the view?

    The layout for my view is very simple:

    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/dialog_food_card_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:layout="@layout/fragment_food_card" />
    

    I want to use the FrameLayout to display a fragment, so I tried this but it seems that the FragmentManager could not find the dialog_food_card_frame:

    @NonReusable
    @Animate(Animate.CARD_TOP_IN_DESC)
    @Layout(R.layout.dialog_food_card)
    public class FoodCard {
        private FoodCardFragment foodCardFragment = new FoodCardFragment();
        private Food food;
        private Fragment fragment;
        public FoodCard(Fragment fragment, Food food){
            this.fragment = fragment;
            this.food = food;
        }
    
        @Resolve
        public void onResolved() {
            fragment.getChildFragmentManager().beginTransaction().add(R.id.dialog_food_card_frame, foodCardFragment).commit();
            foodCardFragment.LoadFood(food);
        }
    }
    

    How do I display the fragment?

    opened by SeakyLuo 0
Releases(1.0.3)
  • 1.0.3(Apr 3, 2018)

    Features

    1. This release fixes the constructor not found exception when minify is enabled.
    2. The proguard rules are added to keep the classes annotated with @Layout along with the generated classes required by the library

    Note:

    A new annotation @Keep is added for the purpose of keeping the class and its methods when minify is enabled. This was required by the library so to reference the generated classes for the item views. This annotations as a by product can be utilised by the client code to prevent any class from being obfuscated.

    Source code(tar.gz)
    Source code(zip)
  • 0.7.3(Feb 16, 2018)

    @Recycle Addition To PlaceHolderView

    It will provide the callback to the ViewItem when the ViewHolder containing that ViewItem is recycled. It can then be used to clean up views and data.

    Example:

    @Layout(R.layout.row_user)
    public class UserDetailView {
    
        @View(R.id.et_user_name) 
        private EditText etUserName;
    
        private User user;
        private TextWatcher textWatcher;
    
        public UserDetailView(User user){
             this.user = user;
             textWatcher = new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
    
                }
    
                @Override
                public void onTextChanged(CharSequence charSequence, int pos, int i1, int i2) {
                    if (charSequence.toString().length() > 0) {
                        user.setName(charSequence.toString())
                    }
                }
    
                @Override
                public void afterTextChanged(Editable editable) {
    
                }
            };
       }
    
        @Resolve
        private void onResolved() {
            etUserName.setText(user.getName());
            etUserName.addTextChangedListener(textWatcher);
        }
    
        @Recycle
        private void onRecycle() {
            etUserName.removeTextChangedListener(textWatcher);
        }
    }
    

    RecyclableEditText Widget

    The EditText in Android don't allow to remove TextChangedListener if TextWatcher instance is not known. Thus when ViewHolder is recycled then it leads to addition of multiple listeners and causes unpredictable behavior.

    RecyclableEditText provides two methods setTextChangedListener and removeTextChangedListener.

        etUserName.setTextChangedListener(new RecyclableEditText.OnTextChangeListener() {
                @Override
                public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
                    // Do something
                }
            });
    
    Source code(tar.gz)
    Source code(zip)
  • 0.7.2(Dec 1, 2017)

    PlaceHolderView Sort

    Now we can apply sort to the views added to the PlaceHolderView. This will refresh the views with new sort order.

    Example: If the View Items added to the PlaceHolderView is of class ItemView, then we have to supply a Comparator that defines the comparison between the itemView objects. Here the itemView's title string is being compared for the sorting.

    NOTE: Check item1 and item2 are of type ItemView for this example. This is required because any type of View Item class can be added into the PlaceHolderView

    placeHolderView.sort(new Comparator<Object>() {
        @Override
        public int compare(Object item1, Object item2) {
            if (item1 instanceof ItemView && item2 instanceof ItemView) {
                ItemView view1 = (ItemView) item1;
                ItemView view2 = (ItemView) item2;
                return view1.getTitle().compareTo(view2.getTitle());
            }
            return 0;
        }
    });
    
    

    SwipeHead Callback

    SwipePlaceHolderView will now provide SwipeHead annotation for callback when a card comes on top of the stack.

    @SwipeHead
    private void onSwipeHeadCard() {
        // do something when the card comes on the top
    }
    

    Example: In the below example link, the cards below the top card are blurred and when a card come on the top then it's blur removed. Link: TinderCard

    ExpandabePlaceHolderView Reverse Add Fix

    The child views were getting added in reverse order and hence it is fixed now.

    Source code(tar.gz)
    Source code(zip)
  • 0.7.1(Sep 10, 2017)

    The Swipe Animation while changing the direction of swipe caused jumps. This is fixed in this release.

    setSwipeMaxChangeAngle method has been added to the SwipeDecor that defines the maximum angle change allowed for subsequent card movement while swiping.

    Example:

    For allowing only up to 1 degree rotation increment (default is 2 degrees) keep it smaller for smoother animation.

    swipeDecor().setSwipeMaxChangeAngle(1f)
    

    Suggestion:

    For smooth transition of card rotation keep setHeightSwipeDistFactor and setWidthSwipeDistFactor smaller and setSwipeMaxChangeAngle less than 2 degrees(default).

    mSwipeView.getBuilder()
                   .setHeightSwipeDistFactor(8)
                   .setWidthSwipeDistFactor(4)
    
    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Aug 9, 2017)

    SwipeDirectionalView

    0.7.0 version provides SwipeDirectionalView class, which is build on top of SwipePlaceHolderView. This View provides more refines directional callbacks for the swipes. All the properties of SwipePlaceHolderView is available to SwipeDirectionalView.

    Usage:

        <com.mindorks.placeholderview.SwipeDirectionalView
            android:id="@+id/swipeView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    
    private SwipeDirectionalView mSwipeView;
    ...
    
    mSwipeView.getBuilder()
                    .setSwipeVerticalThreshold(Utils.dpToPx(50))
                    .setSwipeHorizontalThreshold(Utils.dpToPx(50))
                    ...
    

    setSwipeVerticalThreshold: It defines the vertical area from the initial touch location. setSwipeHorizontalThreshold: It defines the horizontal area from the initial touch location.

    If the swipe take place within these areas then it will be considered for TOP, BOTTOM, LEFT or RIGHT direction swipe else the direction will be RIGHT_TOP, RIGHT_BOTTOM, LEFT_TOP or LEFT_BOTTOM

    For receiving the directional callbacks for SwipeDirectionalView, new Annotations has been added:

    1. @SwipeOutDirectional: It is called when the card is either left swiped or top swiped.
        @SwipeOutDirectional
        private void onSwipeOutDirectional(SwipeDirection direction) {
            Log.d("DEBUG", "SwipeOutDirectional " + direction.name());
        }
    
    1. @SwipeInDirectional: It is called when the card is either right swiped or bottom swiped.
        @SwipeInDirectional
        private void onSwipeInDirectional(SwipeDirection direction) {
            Log.d("DEBUG", "SwipeInDirectional " + direction.name());
        }
    
    1. @SwipingDirection: It is called when the card is swiping in some direction.
        @SwipingDirection
        private void onSwipingDirection(SwipeDirection direction) {
            Log.d("DEBUG", "SwipingDirection " + direction.name());
        }
    

    Refer to this demo example to understand it's usage: Link

    SwipeTouch Callback

    This callback is added to SwipePlaceHolderView. It provides the starting and current touch point's coordinates on the card while it is getting swiped.

        @SwipeTouch
        private void onSwipeTouch(float xStart, float yStart, float xCurrent, float yCurrent) {
            Log.d("DEBUG", "onSwipeTouch "
                    + " xStart : " + xStart
                    + " yStart : " + yStart
                    + " xCurrent : " + xCurrent
                    + " yCurrent : " + yCurrent
                    + " distance : "
                    + Math.sqrt(Math.pow(xCurrent - xStart, 2) + (Math.pow(yCurrent - yStart, 2)))
            );
        }
    

    Programmatic undo for SwipePlaceHolderView with Animation.

    The mSwipeView.undoLastSwipe(); will now put back the swiped card back into the stack by making a reverse animation.

    Programmatic Expand/Collapse for ExpandablePlaceHolderView

    
    // These will expand the desired parent
    public <T> void expand(T resolver) throws Resources.NotFoundException
    public void expand(int position) throws Resources.NotFoundException
    
    // These will collapse the desired parent
    public <T> void collapse(T resolver) throws Resources.NotFoundException
    public void collapse(int position) throws Resources.NotFoundException
    
    // This will collapse all the expanded parents
    public void collapseAll()
    
    //Example
        @OnClick(R.id.collapse)
        void onCollapse() {
            try {
                mExpandableView.collapse(parentItem);
               //mExpandableView.collapse(0);
            } catch (Resources.NotFoundException e) {
                e.printStackTrace();
            }
        }
    
    Source code(tar.gz)
    Source code(zip)
  • 0.6.2(Mar 29, 2017)

    getAllResolvers() has been added to the SwipePlaceHolderView. This method will give the list of all the currently added and reserved views in the SwipePlaceHolderView.

    Example:

    for(Object view : mSwipeView.getAllResolvers()){
         // do with the added view objects
    }
    
    Source code(tar.gz)
    Source code(zip)
  • 0.6.1(Jan 17, 2017)

    SwipePlaceHolderView will now accept ItemRemovedListener. It will listen to the itemView remove events. onItemRemoved method will be called with the count of the current items in the view list after the view removal.

        mSwipePlaceHolderView.addItemRemoveListener(new ItemRemovedListener() {
    
            @Override
            public void onItemRemoved(int count) {
                //do something when the count changes to some specific value.
                //For Example: Call server to fetch more data when count is zero
            }
        });
    
    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Dec 14, 2016)

    RecyclerView is updated to 25.+

    com.android.support:recyclerview-v7:25.+
    

    SwipePlaceHolderView can now remove all its child views to reset its empty state using:

    mSwipePlaceHolderView.removeAllViews();
    
    Source code(tar.gz)
    Source code(zip)
  • 0.5.2(Oct 21, 2016)

    1. This release clubs all the non UI options into SwipeOption class. It will fix the Options of SwipePlaceHolderView to reset to default when new SwipeDecor class is passed to the Builder class.
    2. mSwipePlaceHolderView.deActivatePutBack() is renamed to mSwipePlaceHolderView.deactivatePutBack()
    Source code(tar.gz)
    Source code(zip)
  • 0.5.1(Oct 20, 2016)

    This version adds two method to enable/disable swiping on touch. The programmatic swipe will still be enabled.

    mSwipePlaceHolderView.disableTouchSwipe();
    mSwipePlaceHolderView.enableTouchSwipe();
    
    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Oct 19, 2016)

    This Version adds several new functionality to the SwipePlaceHolderView:

    I. Dynamic view margin: This will allow to specify margin for placing cards at appropriate position programmatically. example: mSwipePlaceHolderView is the SwipePlaceHolderView layout

    mSwipePlaceHolderView.setSwipeDecor(new SwipeDecor()
                            .setMarginTop(300)
                            .setMarginLeft(100)
                            .setViewGravity(Gravity.TOP)
    

    Note:

    1. This will place the card at 300 pixel from top and 100 pixel from left.
    2. If setViewGravity(Gravity.TOP) is not provided then the margin will take place from the center on the screen.

    II. Undo last swipe: This will allow to put the last swiped view back on the top. Example:

    //It initializes the Undo functionality
    mSwipePlaceHolderView.getBuilder() .setIsUndoEnabled(true)
    
    //To undo call this method
    mSwipePlaceHolderView.undoLastSwipe();
    

    III. Putback swiped view: This functionality enable the card to be swiped and then animate back on the top. So, user is not able to swipe other cards other than top.

    Example:

    //Activates the Putback functionality
    mSwipePlaceHolderView.activatePutBack();
    
    //Deactivates the Putback functionality
    mSwipePlaceHolderView.deActivatePutBack();
    

    IV. Lock view: This allows the card to be locked. The user will not be able to swipe the locked cards.

    Example:

    //It locks the card view
    mSwipePlaceHolderView.lockViews();
    
    //It Unlocks the locked card view
    mSwipePlaceHolderView.unlockViews();
    
    Source code(tar.gz)
    Source code(zip)
  • 0.2.8(Oct 12, 2016)

  • 0.2.7(Oct 10, 2016)

    This update adds below methods to the PlaceHolderView

    1. <T>int getViewResolverPosition(T resolver): This will give the position of the class object which is added as the item view, even before the item view is binded to the window.
    2. <T>void refreshView(T resolver): This will refresh the item view after new data is added based on the class object reference added as item view.
    3. public void refreshView(int position): This will refresh the item view after new data is added based on the position of item view.
    Source code(tar.gz)
    Source code(zip)
  • 0.2.6(Oct 9, 2016)

    This update calculates the swipe with-respect-to initial touch point. Earlier versions used to calculate swipe w.r.t. on the coordinate center being the actual screen center.

    This enables swiping even from the edges of the cards correctly as opposed to earlier version.

    Source code(tar.gz)
    Source code(zip)
  • 0.2.5(Oct 8, 2016)

  • 0.2.4(Oct 7, 2016)

    SwipeView annotation is added. It will help to get a reference to the swipeable view. SwipeDecor has additions to specify view height, width and gravity.

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Oct 6, 2016)

    InfinitePlaceHolderView: This class has been added to show load more style of view loading when the last item has been seen. SwipePlaceHolderView image freezing when rapid swipe is done is also fixed

    Source code(tar.gz)
    Source code(zip)
  • 0.1.6(Oct 5, 2016)

    This version is build upon Support RecyclerView v7:24.+ It's an update from previous RecyclerView v7:23.+ The project using this version should compile using compileSdkVersion 24

    Source code(tar.gz)
    Source code(zip)
  • 0.1.5(Sep 29, 2016)

  • 0.1.4(Sep 29, 2016)

  • 0.1.3(Sep 24, 2016)

Owner
Janishar Ali
Co-Founder at MindOrks, AfterAcademy, CuriousJr | Disrupting EdTech | mindorks.com | afteracademy.com | curiousjr.com
Janishar Ali
A TagView library for Android. Customize your own & Drag effect.

AndroidTagView An Android TagView library. You can customize awesome TagView by using this library. Screenshots Usage Step 1 Add below dependency in y

lujun 1.7k Dec 29, 2022
[] Define and render UI specs on top of your Android UI

dspec A simple way to define and render UI specs on top of your Android UI. Usage Enclose the target UI with a DesignSpecFrameLayout, usually the root

Lucas Rocha 561 Dec 16, 2022
A tiny window overlay to log app internal on top of your android app

DebugOverlay A logcat alike overlay to display log messages in your app as independent overlay. Typically in android you would log some app internals

Hannes Dorfmann 150 Nov 29, 2022
TopSheet - a "top" version of BottomSheet

TopSheet - a "top" version of BottomSheet TopSheetBehaviour View sheet = findViewById(R.id.top_sheet); TopSheetBehavior.from(sheet).setState(TopSheetB

Andrea Maglie 82 Jun 24, 2022
Owasp-top-five - An intro into writing code for greater Android Security

Don’t get stung by OWASP An intro into writing code for greater Android Security

Ed George 5 Feb 13, 2022
Android Library to build a UI Card

Card Library Travis master: Travis dev: Card Library provides an easy way to display a UI Card using the Official Google CardView in your Android app.

Gabriele Mariotti 4.7k Dec 29, 2022
Have a look at Job Allocation app build with SQLite database and Kotlin support

Job Allocation Overview Do you remember or forget sometimes to whom you allocated a task ?? Have a look at Job Allocation app build with SQLite databa

null 0 Dec 13, 2021
This project created just for help developer who want to and ability of read VISA, UNION PAY, HUMO, ATTO and some other cards data read.

If you enjoy my content, please consider supporting what I do. Thank you. By me a Coffee To get a Git project into your build: Step 1. Add the JitPack

Fozilbek Imomov 1 Oct 15, 2022
This is a sample Android Studio project that shows the necessary code to create a note list widget, And it's an implementation of a lesson on the Pluralsight platform, but with some code improvements

NoteKeeper-Custom-Widgets This is a sample Android Studio project that shows the necessary code to create a note list widget, And it's an implementati

Ibrahim Mushtaha 3 Oct 29, 2022
Add some depth to your Android scrolling.

Parallax Pager Add some depth to your Android scrolling using the parallax effect! Installation Step 1. Add the JitPack repository to your build file

Prolific Interactive 782 Dec 29, 2022
An Android application which visualizes some of the famous Algorithms for finding path from Source to Destination in a 2D grid.

Pathfinding-Visualizer An Android application which visualizes some of the famous Algorithms for finding path from Source to destination in a 2D grid.

Pranjal Mishra 37 Aug 8, 2022
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR. Android Sliding Up Panel This library provides a simp

Umano: News Read To You 9.4k Dec 31, 2022
[] Android library that provides a file explorer to let users select files on external storage.

aFileChooser - Android File Chooser aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1

Paul Burke 1.8k Jan 5, 2023
Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (https://github.com/romannurik/android-wizardpager)

Wizard Pager Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (ht

Julián Suárez 520 Nov 11, 2022
A library that provides an implementation of the banner widget from the Material design.

MaterialBanner A banner displays a prominent message and related optional actions. MaterialBanner is a library that provides an implementation of the

Sergey Ivanov 252 Nov 18, 2022
Wizard Pager is a library that provides an example implementation of a Wizard UI on Android

Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager.

Julián Suárez 520 Nov 11, 2022
Android library for multiple snapping of RecyclerView

MultiSnapRecyclerView Gradle dependencies { implementation 'com.github.takusemba:multisnaprecyclerview:x.x.x' } Features This is an Android Libra

TakuSemba 2.5k Jan 4, 2023
A small, easy to use android library for implementing flipping between views as seen in the popular Flipboard application

FlipView About This library is made to be very easy to use and at the same time be feature complete. With only a few lines of code you can have a flip

Emil Sjölander 924 Nov 10, 2022