Giter VIP home page Giter VIP logo

mvvmexample1's People

Contributors

mitchtabian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mvvmexample1's Issues

Creating Model instance in View

Hello Mitch, thanks a ton for sharing this project.
With respect to line 68 in MainActivity, by calling NicePlace constructer in MainActivity, are we not violating the MVVM architecture guideline? If yes then what is the better way to do it? I am new to MVVM and trying to understand the architecture so that I can implement it in my current project.
Thanks.

setValue fails on first run on actual network call

The repository setValue call works fine with the hard coded data.
It however fails to update the view on first run when loading data from network using Volley.
It populates the views on refresh but not on first run
I dont understand why or where I'm supposed to make change.
Its like the viewModel and the views load first then the data comes in a few seconds later - I can see the data on Toast- but that data is not loaded in the UI.
Using postValue doesnt update the views at all

Sample repository setValue function

public MutableLiveData> getHouseDetails(Context mContext){
        this.mContext=mContext;

        getDatabaseHouseDetails();

        MutableLiveData> myData= new MutableLiveData<>();
        myData.setValue(dataSet);
        return myData;
    }

Sample repository network call getDatabaseHouseDetails(); in volley

@Override
public void onSuccessResponse(String response) {
	Log.e("Response", response);
	if(response!=null) {
		try {
			JSONObject json = new JSONObject(response);
			//Successfully fetched

			String sarray = json.getString("house_details");
			Toast.makeText(mContext, sarray, Toast.LENGTH_SHORT).show();
			JSONArray jsonArray = new JSONArray(sarray);

			//Clear list to refresh list in every selection
			for (int i = 0; i < jsonArray.length(); i++) {
				JSONObject json_list = jsonArray.getJSONObject(i);
				DecodeHouseDetails houses_array = new DecodeHouseDetails(
						json_list.getInt("active_identifier"),
						json_list.getInt("house_id"),
						json_list.getInt("house_status"),
						json_list.getString("house_number"),
						json_list.getString("house_cover"),
						json_list.getString("house_name"),
						json_list.getString("longitude"),
						json_list.getString("latitude")
				);
				dataSet.add(houses_array);
			}

		} catch (JSONException e) {
			e.printStackTrace();
			//Dismiss loader
			isUpdating = false;
		}
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.