MVPDemo | MVP(Model View | Reactive Programming library

 by   Lloyd0577 Java Version: Current License: No License

kandi X-RAY | MVPDemo Summary

kandi X-RAY | MVPDemo Summary

MVPDemo is a Java library typically used in Programming Style, Reactive Programming applications. MVPDemo has no bugs, it has no vulnerabilities, it has build file available and it has low support. You can download it from GitHub.

MVP(Model View Presenter)其实就是一种项目的整体框架,能让你的代码变得更加简洁,说起框架大家可能还会想到MVC、MVVM。由于篇幅原因,这里我们先不讲MVVM,先来看一下MVC。其实Android本身就采用的是MVC(Model View Controllor)模式、其中Model指的是数据逻辑和实体模型;View指的是布局文件、Controllor指的是Activity。对于很多Android初学者可能会有这样的经历,写代码的时候,不管三七二十一都往Activity中写,当然我当初也是这么干的,根本就没有什么框架的概念,只要能实现某一个功能就很开心了,没有管这么多。当然项目比较小还好,一旦项目比较大,你会发现,Activity所承担的任务其实是很重的,它既要负责页面的展示和交互,还得负责数据的请求和业务逻辑之类的工作,相当于既要打理家庭,又要教育自己调皮的孩子,真是又当爹又当妈。。。那该怎么办呢?这时候Presenter这个继父来到了这个家庭。Presenter对Activity说,我来了,以后你就别这么辛苦了,你就好好打理好View这个家,我专门来负责教育Model这孩子,有什么情况我会向你反映的。这时Activity流下了幸福的眼泪,从此,Model、View(Activity)、Presenter一家三口过上了幸福的生活。。。好了磕个药继续,由于Presenter(我们自己建的类)的出现,可以使View(Activity)不用直接和Model打交道,View(Activity)只用负责页面的显示和交互,剩下的和Model交互的事情都交给Presenter做,比如一些网络请求、数据的获取等,当Presenter获取到数据后再交给View(Activity)进行展示,这样,Activity的任务就大大减小了。这便是MVP(Model 还是指的数据逻辑和实体模型,View指的是Activity,P就是Presenter)框架的工作方式。. 接下来我们看一下什么是Retrofit。在官网对Retrofit的描述是这样的 A type-safe HTTP client for Android and Java说人话就是“一个类型安全的用于Android和Java网络请求的客户端”,其实就是一个封装好的网络请求库。接下来就来看一下这个库该怎么用。首先我在网上找了一个API接口用于测试:然后我们来看一下这个方法的返回值,它返回Call实体,一会我们要用它进行具体的网络请求,我们需要为它指定泛型为Book也就是我们数据的实体类。接下来,你会发现这个方法的入参和我们平时方法的入参还不大一样。在每个入参前还多了一个注解。比如第一个入参@Query("q") String name ,Query表示把你传入的字段拼接起来,比如在测试url中我们可以看到q=金瓶梅的入参,那么Query后面的值必须是q,要和url中保持不变,然后我们定义了String类型的name,当调用这个方法是,用于传入字符串,比如可以传入“金瓶梅”。那么这个方法就会自动在q后面拼上这个字符串进行网络请求。以此类推,这个url需要几个入参你就在这个方法中定义几个入参,每个入参前都要加上Query注解。当然Retrofit除了Query这个注解外,还有其他几个比如:@QueryMap、@Path、@Body、@FormUrlEncoded/@Field、@Header/@Headers。我们来看一下他们的区别: ####@Query(GET请求): 用于在url后拼接上参数,例如:. 我们这篇文章主要介绍搭建整体网络请求框架,所以关于RxJava的基础知识,我这就不再详细介绍了,网上也有很多文章,对RxJava还不是很了解的同学,推荐你看一下扔物线的这篇文章给 Android 开发者的 RxJava 详解. 可以看到,在它的构造方法中,我们得到了RetrofitService 的实例化,然后定义了一个和RetrofitService 中同名的方法,里面其实就是调用RetrofitService 中的这个方法。这样,把RetrofitService 中定义的方法都封装到DataManager 中,以后无论在哪个要调用方法时直接在DataManager 中调用就可以了,而不是重复建立RetrofitService 的实例化,再调用其中的方法。. 逻辑并不复杂,我们先创建了一个BookPresenter 对象,然后调用它的onCreate方法进行初始化,接着调用attachView来绑定BookView。BookView的实现也很简单,在onSuccess方法中将Book 中内容显示在TextView上,在onError中弹出一个Toast提示。然后点击按钮的时候就调用BookPresenter中getSearchBooks方法,同时传入必要的入参。这样网络请求就开始了,如果请求成功就会回调BookView 中的onSuccess方法,失败就回调onError方法。当活动销毁时记得调用BookPresenter的onStop方法来释放订阅关系,防止内存泄漏。.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              MVPDemo has a low active ecosystem.
              It has 195 star(s) with 53 fork(s). There are 9 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 2 open issues and 1 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of MVPDemo is current.

            kandi-Quality Quality

              MVPDemo has 0 bugs and 0 code smells.

            kandi-Security Security

              MVPDemo has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              MVPDemo code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              MVPDemo does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              MVPDemo releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              MVPDemo saves you 252 person hours of effort in developing the same functionality from scratch.
              It has 613 lines of code, 106 functions and 18 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed MVPDemo and discovered the below as its top functions. This is intended to give you an instant insight into MVPDemo implemented functionality, and help decide if they suit your requirements.
            • Initializes the instance
            • Fetch books with specified tag
            • Invoked when the data manager is created
            • Search books by tag
            • Attaches a view to the book
            • On destroy
            • Unsubscribe from the composite
            • Initializes the app
            • Reset App
            • Get the Retrofit server
            Get all kandi verified functions for this library.

            MVPDemo Key Features

            No Key Features are available at this moment for MVPDemo.

            MVPDemo Examples and Code Snippets

            No Code Snippets are available at this moment for MVPDemo.

            Community Discussions

            Trending Discussions on MVPDemo

            QUESTION

            Espresso with Custom KeyboardView button press
            Asked 2018-Jul-26 at 00:01

            I am implementing a custom KeyboardView in my app and it's all working at the moment, however, when I attempt to press a key on the keyboard using Espresso ViewAction, I am getting an exception saying:

            ...

            ANSWER

            Answered 2018-Jul-26 at 00:01

            Answering my own question after determining a flexible solution:

            1. First attempt - get DisplayMetrics of the root View and subtract an arbitrary number to attempt to hit the Keyboard.Key
              • this didn't work because clickXY function uses the position of the view
              • this ended up being the reason for the exception since the view is smaller than the DisplayMetrics values and adding to the Views on screen position would give a very high number for the x and y.

            So I tried again,

            1. Second attempt - use check method on the ViewMatcher to check the KeyBoardView.
              • by doing so I was able to get access to the KeyboardView's position x
              • then I was able to get the KeyboardView's width and height
              • by performing some math, I was able to figure out target index for x & y

            the math:

            • take the widthPercent for the Keyboard.Key (in my case 33.3%)
            • take the rowCount of the keyboard.xml (in my case 3)
            • use (viewWidth * widthPercent) / 4 to get relativeButtonX
            • use (viewHeight / rowCount) / 2 to get relativeButtonY
            • then for targetY, I took viewHeight - relativeButtonY
            • finally, for targetX, I took (viewPosX + viewWidth) - relativeButtonX

            So enough explanation, here is the code:

            Source https://stackoverflow.com/questions/51528649

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install MVPDemo

            You can download it from GitHub.
            You can use MVPDemo like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the MVPDemo component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/Lloyd0577/MVPDemo.git

          • CLI

            gh repo clone Lloyd0577/MVPDemo

          • sshUrl

            git@github.com:Lloyd0577/MVPDemo.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Reactive Programming Libraries

            axios

            by axios

            RxJava

            by ReactiveX

            async

            by caolan

            rxjs

            by ReactiveX

            fetch

            by github

            Try Top Libraries by Lloyd0577

            CustomClockForAndroid

            by Lloyd0577Java

            FiveGuessMovieGame

            by Lloyd0577Java

            DjangoByExampleProjects

            by Lloyd0577Python

            BleDemo

            by Lloyd0577Java

            MultifunctionBed

            by Lloyd0577Java