<repo_name>kgt15/FarmFriend-app<file_sep>/app/src/main/java/gino/farmfriend/banana.java
package gino.farmfriend;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.util.prefs.AbstractPreferences;

/**
 * Created by Gino on 19-02-2016.
 */
import android.content.Context;
import android.net.ConnectivityManager;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.net.NetworkInfo;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class banana extends AppCompatActivity {
    TextView uid1;
    TextView name11;
    TextView email11;
    TextView pre1;


    //JSON Node Names
    private static final String TAG_USER = "weather";
    private static final String TAG_USER1 = "main";
    private static final String TAG_ID = "temp_min";

    private static final String TAG_EMAIL = "description";
    private static final String TAG_ID1 = "temp_max";
    private static final String TAG_NAME1 = "humidity";
    int flag = 0;

    private static final String TAG_USER11 = "main";

    JSONArray user = null;
    JSONObject d = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.banana);

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor ed = sp.edit();
        ed.putString("track", "0");
        ed.apply();
        if (isonline()==true)
        new JSONParse().execute();

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_home, menu);
        return true;
    }

    private class JSONParse extends AsyncTask<String, String, JSONObject> {
        private ProgressDialog pDialog;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            uid1 = (TextView) findViewById(R.id.textView);
            name11 = (TextView) findViewById(R.id.textView2);
            email11 = (TextView) findViewById(R.id.textView3);
            pre1 = (TextView) findViewById(R.id.textView4);

            pDialog = new ProgressDialog(banana.this);
            pDialog.setMessage("Getting Data ...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();

        }

        @Override
        protected JSONObject doInBackground(String... args) {
            ServiceHandler jParser = new ServiceHandler();

            // Getting JSON from URL
            String url2 = "http://usehumzz.site88.net/banana.json";
            JSONObject json = jParser.getJSONFromUrl(url2);
            System.out.println(json);
            return json;
        }

        @Override
        protected void onPostExecute(JSONObject json) {
            pDialog.dismiss();
            try {System.out.println("secomd"+json);
                // Getting JSON Array
                user = json.getJSONArray(TAG_USER);
                System.out.println("user  "+user);
                JSONObject c = user.getJSONObject(0);

                d = json.getJSONObject(TAG_USER1);
                System.out.println("d  "+d);
                // Storing  JSON item in a Variable

                //String name = c.getString(TAG_NAME);
                String email1 = c.getString(TAG_EMAIL);

                String a1 = d.getString(TAG_ID1);
                String b1 = d.getString(TAG_NAME1);
                String id1 = d.getString(TAG_ID);
                System.out.println("stuff  "+email1+" "+a1+ " "+ b1 +" "+ id1+" ");
                uid1.setText(id1);
                // name1.setText(name);
                email11.setText(email1);
                pre1.setText(a1);
                name11.setText(b1);

            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }
    public boolean isonline()
    {


        ConnectivityManager cm=(ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info=cm.getActiveNetworkInfo();
        if (info!= null) {
            return true;
        }
        else {
            return false;
        }
    }
}
<file_sep>/app/src/main/java/gino/farmfriend/new_policies.java
package gino.farmfriend;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * Created by Gino on 18-02-2016.
 */

public class new_policies extends AppCompatActivity {
    ListView listView;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.new_policies);

            listView=(ListView)findViewById(R.id.listView);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
            getSupportActionBar().setTitle("New Policies");
            String[] values = new String[] { "Over 4 per cent annual growth rate aimed over next two decades",

                    "Greater private sector participation through contract farming",
                    "Price protection for farmers",

                    "National agricultural insurance scheme to be launched"
                    ,"Dismantling of restrictions on movement of agricultural commodities throughout the country",

                    "Rational utilisation of country's water resources for optimum use of irrigation potential",

                    "High priority to development of animal husbandry, poultry, dairy and aquaculture",
                    "Capital inflow and assured markets for crop production",

                    "Exemption from payment of capital gains tax on compulsory acquisition of agricultural land",

                    "Minimise fluctuations in commodity prices",
                    "Continuous monitoring of international prices",

                    "Plant varieties to be protected through a legislation.",

                    "Adequate and timely supply of quality inputs to farmers",

                    "High priority to rural electrification",
                    "Setting up of agro-processing units and creation of off-farm employment in rural areas"
            };
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_activated_1, android.R.id.text1, values);



            // Assign adapter to ListView
            listView.setAdapter(adapter);





        }

    }


