kandi background
Explore Kits

android-mvp-architecture | repository contains a detailed sample app | Reactive Programming library

 by   MindorksOpenSource Java Version: Current License: Apache-2.0

 by   MindorksOpenSource Java Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | android-mvp-architecture Summary

android-mvp-architecture is a Java library typically used in Programming Style, Reactive Programming applications.,roid-mvp-architecture has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. However android-mvp-architecture has 2 bugs. You can download it from GitHub.
This repository contains a detailed sample app that implements MVP architecture using Dagger2, GreenDao, RxJava, FastAndroidNetworking, PlaceHolderView and AndroidDebugDatabase.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • android-mvp-architecture has a medium active ecosystem.
  • It has 4333 star(s) with 1248 fork(s). There are 199 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 33 open issues and 41 have been closed. On average issues are closed in 58 days. There are 7 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of android-mvp-architecture is current.
This Library - Support
Best in #Reactive Programming
Average in #Reactive Programming
This Library - Support
Best in #Reactive Programming
Average in #Reactive Programming

quality kandi Quality

  • android-mvp-architecture has 2 bugs (1 blocker, 0 critical, 0 major, 1 minor) and 76 code smells.
This Library - Quality
Best in #Reactive Programming
Average in #Reactive Programming
This Library - Quality
Best in #Reactive Programming
Average in #Reactive Programming

securitySecurity

  • android-mvp-architecture has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • android-mvp-architecture code analysis shows 0 unresolved vulnerabilities.
  • There are 1 security hotspots that need review.
This Library - Security
Best in #Reactive Programming
Average in #Reactive Programming
This Library - Security
Best in #Reactive Programming
Average in #Reactive Programming

license License

  • android-mvp-architecture is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
This Library - License
Best in #Reactive Programming
Average in #Reactive Programming
This Library - License
Best in #Reactive Programming
Average in #Reactive Programming

buildReuse

  • android-mvp-architecture 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, examples and code snippets are available.
  • android-mvp-architecture saves you 3228 person hours of effort in developing the same functionality from scratch.
  • It has 6938 lines of code, 675 functions and 161 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
This Library - Reuse
Best in #Reactive Programming
Average in #Reactive Programming
This Library - Reuse
Best in #Reactive Programming
Average in #Reactive Programming
Top functions reviewed by kandi - BETA

kandi has reviewed android-mvp-architecture and discovered the below as its top functions. This is intended to give you an instant insight into android-mvp-architecture implemented functionality, and help decide if they suit your requirements.

  • On server login .
  • Override this to handle API errors .
  • region Drawable
  • Handler for logout action .
  • Called when the blog is prepared .
  • Setup the card container view .
  • Called when the user has submitted a rating .
  • Handle the resolved button .
  • Saves questions .
  • Creates the dialog .

android-mvp-architecture Key Features

This repository contains a detailed sample app that implements MVP architecture using Dagger2, GreenDao, RxJava2, FastAndroidNetworking and PlaceholderView

License

copy iconCopydownload iconDownload
   Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED

   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.

Community Discussions

Trending Discussions on android-mvp-architecture
  • RxJava thread not waiting for result
Trending Discussions on android-mvp-architecture

QUESTION

RxJava thread not waiting for result

Asked 2018-Jul-04 at 23:26

I have this method that I am trying to pull data from an API, and then update the text view. Everything works except getRecipeName doesn't finish after the "end Method" log. .getRecipeName() uses RetroFit to pull from an API.

I am currently learning MVP, Dagger, RxJava, and Butterknife all at once using Mindork's Github page on MVP Architecture

I commented out the .subscribeOn and .observeOn to see the result difference and nothing changed.

@Override
public void onRandomButtonClicked() {

    getMvpView().showLoading();
    Log.e(TAG, "Random Method Open");
    getCompositeDisposable().add(getDataManager()
            .getRecipeName()
            //.subscribeOn(getSchedulerProvider().io())
            //.observeOn(getSchedulerProvider().ui())
            .subscribe(new Consumer<String>() {
                @Override
                public void accept(String s) throws Exception {
                    Log.e(TAG, "accept");
                    getMvpView().updateTextView(title);
                }
            }));

    Log.e(TAG, "end method");

}

Here is my getRecipeName() method

@Override
public Observable<String> getRecipeName() {

    /*Create handle for the RetrofitInstance interface*/
    GetDataService service = RetrofitClientInstance.getRetrofitInstance().create(GetDataService.class);
    Call<RecipeList> call = service.getRecipe();
    call.enqueue(new Callback<RecipeList>() {
        @Override
        public void onResponse(@NonNull Call<RecipeList> call, @NonNull retrofit2.Response<RecipeList> response) {


            Log.e("onResponse","Recipe is Successful = " + response.isSuccessful());
            //if response is false then skip to avoid null object reference
            if (response.isSuccessful()) {

                RecipeList drinkRecipe = response.body();

                List<Recipe> recipes = drinkRecipe.getDrinks();
                jokeText = String.valueOf(recipes.size());
                Recipe myRecipe = recipes.get(0);
                jokeText = myRecipe.getStrDrink();

                Log.e("On Response", "Result2: " + jokeText);
            }
            //jokeText = "null";

        }

        @Override
        public void onFailure(Call<RecipeList> call, Throwable t) {
            Log.e("On Response","Failure");
        }
    });

    //return jokeText;
    return Observable.fromCallable(new Callable<String>() {
        @Override
        public String call() throws Exception {
            return jokeText;
        }
    });
}

Solution

So as the comments stated RxJava Adapter was the correct way to go. I will just post my working code on myself using the adapter. I found it very difficult to find a working example.

//single api call using retrofit and rxjava
@SuppressLint("CheckResult")
private void getRandomButtonClick(){

    retrofit = RetrofitClientInstance.getRetrofitInstance();

    retrofit.create(GetDataService.class).getRecipe()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(this::handleResults, this::handleError );
}

private void handleResults(RecipeList recipeList) {
    int i = recipeList.getDrinks().size();
    Log.e(TAG, "size is: "+ i);
    Recipe recipe = recipeList.getDrinks().get(0);
    getMvpView().updateTextView(recipe.getStrDrink());
}

 private void handleError(Throwable t){
    Log.e("Observer", "");

}

My Retrofit Client Instance

 public static Retrofit getRetrofitInstance() {
    if (retrofit == null) {
        retrofit = new retrofit2.Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
    }
    return retrofit;
}

My Interface

public interface GetDataService {

//@Headers({})
@GET("random.php")
Observable<RecipeList> getRecipe();

I found a great resource to reference for me to correctly implement this. Retrofit Android

ANSWER

Answered 2018-Jul-04 at 06:55

The reason is because your observable is returning jokeText every time it is subscribed upon. It returns immediately after invocation and will not wait for your network operation.

One possible solution is to use the RxJavaCallAdapter. Link here: https://github.com/square/retrofit/tree/master/retrofit-adapters/rxjava2

It will automatically convert your API returns to observables. No need to manually invoke retrofit requests. Just process the response and convert it to your desired object from there.

Another approach would be to wrap your entire sequence in an Observable.create or Observable.fromAsync.

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

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

Vulnerabilities

No vulnerabilities reported

Install android-mvp-architecture

Find the template/MVPActivity folder under root directory of android-mvp-architecture app. Paste the MVPActivity folder at below location. Restart the Android Studio.
Windows - C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities
Mac - /Applications/Android/Studio.app/Contents/plugins/android/lib/templates/activities

Support

All pull requests are welcome, make sure to follow the contribution guidelines when you submit pull request.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Consider Popular Reactive Programming Libraries
Compare Reactive Programming Libraries with Highest Support
Compare Reactive Programming Libraries with Highest Quality
Compare Reactive Programming Libraries with Highest Security
Compare Reactive Programming Libraries with Permissive License
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.