Commit 15c33061c313615e1817ae2f92195d69ba2da87b

Authored by geraldo morais
1 parent d0793d22
Exists in master

home e avaliacao de vereador implementado

Showing 22 changed files with 476 additions and 73 deletions   Show diff stats
app/build.gradle
... ... @@ -24,8 +24,8 @@ android {
24 24 applicationId "com.monitorabrasil.monitoramunicipio"
25 25 minSdkVersion 16
26 26 targetSdkVersion 22
27   - versionCode 8
28   - versionName "0.8"
  27 + versionCode 10
  28 + versionName "0.8.2"
29 29 }
30 30 buildTypes {
31 31 release {
... ... @@ -43,7 +43,7 @@ dependencies {
43 43 transitive = true
44 44 }
45 45 compile fileTree(dir: 'libs', include: 'Parse-*.jar')
46   - compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
  46 + compile('com.crashlytics.sdk.android:crashlytics:2.5.0@aar') {
47 47 transitive = true;
48 48 }
49 49 compile 'com.android.support:appcompat-v7:22.2.0'
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/CamaraActivity.java
... ... @@ -8,6 +8,8 @@ import android.support.v7.widget.Toolbar;
8 8 import android.view.Menu;
9 9 import android.view.MenuItem;
10 10  
  11 +import com.crashlytics.android.answers.Answers;
  12 +import com.crashlytics.android.answers.ContentViewEvent;
11 13 import com.monitorabrasil.monitoralegislativo.R;
12 14 import com.monitorabrasil.monitoralegislativo.fragments.GastosCamaraFragment;
13 15  
... ... @@ -18,6 +20,10 @@ public class CamaraActivity extends AppCompatActivity {
18 20 super.onCreate(savedInstanceState);
19 21 setContentView(R.layout.activity_camara);
20 22  
  23 + Answers.getInstance().logContentView(new ContentViewEvent()
  24 + .putContentName("CamaraActivity")
  25 + .putContentType("Activity"));
  26 +
21 27 GastosCamaraFragment frag = (GastosCamaraFragment) getSupportFragmentManager().findFragmentByTag("gastosCamaraFrag");
22 28 if(frag == null) {
23 29 frag = new GastosCamaraFragment();
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/ComentarioActivity.java
... ... @@ -108,10 +108,9 @@ public class ComentarioActivity extends AppCompatActivity {
108 108  
109 109 LinearLayoutManager llm = new LinearLayoutManager(this);
110 110 llm.setOrientation(LinearLayoutManager.VERTICAL);
  111 + llm.setReverseLayout(true);
111 112 mRecyclerView.setLayoutManager(llm);
112 113  
113   -
114   -
115 114 }
116 115  
117 116 private ParseObject buscaPolitico(String id) {
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/MainActivity.java
... ... @@ -178,7 +178,7 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr
178 178 new PrimaryDrawerItem().withName("Home"),
179 179 new DividerDrawerItem(),
180 180 new PrimaryDrawerItem().withName("Vereadores"),
181   - new SecondaryDrawerItem().withName("Projetos"),
  181 + new SecondaryDrawerItem().withName("Indicações"),
182 182 new SecondaryDrawerItem().withName("Câmara")
183 183 )
184 184 .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/PoliticoFichaActivity.java
... ... @@ -93,11 +93,10 @@ public class PoliticoFichaActivity extends AppCompatActivity {
93 93 adapter.addFragment(gastos, "Gastos");
94 94  
95 95 //projetos
96   - ListaProjetosFragment listaProjetosFragment = new ListaProjetosFragment();
97   - listaProjetosFragment.setArguments(getIntent().getExtras());
  96 + ListaProjetosFragment listaProjetosFragment = ListaProjetosFragment.newInstance(null,idPolitico);
  97 + // listaProjetosFragment.setArguments(getIntent().getExtras());
98 98 adapter.addFragment(listaProjetosFragment, "Projetos");
99 99  
100   - //adapter.addFragment(new CheeseListFragment(), "Category 3");
101 100 viewPager.setAdapter(adapter);
102 101 viewPager.getAdapter().notifyDataSetChanged();
103 102  
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/PoliticosActivity.java
... ... @@ -8,6 +8,8 @@ import android.support.v7.widget.Toolbar;
8 8 import android.view.Menu;
9 9 import android.view.MenuItem;
10 10  
  11 +import com.crashlytics.android.answers.Answers;
  12 +import com.crashlytics.android.answers.ContentViewEvent;
11 13 import com.monitorabrasil.monitoralegislativo.R;
12 14 import com.monitorabrasil.monitoralegislativo.fragments.ListaPoliticoFragment;
13 15  
... ... @@ -18,6 +20,10 @@ public class PoliticosActivity extends AppCompatActivity {
18 20 super.onCreate(savedInstanceState);
19 21 setContentView(R.layout.activity_politicos);
20 22  
  23 + Answers.getInstance().logContentView(new ContentViewEvent()
  24 + .putContentName("PoliticosActivity")
  25 + .putContentType("Activity"));
  26 +
21 27 ListaPoliticoFragment frag = (ListaPoliticoFragment) getSupportFragmentManager().findFragmentByTag("listaPoliticoFrag");
22 28 if(frag == null) {
23 29 frag = new ListaPoliticoFragment();
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/ProjetosActivity.java
... ... @@ -7,7 +7,10 @@ import android.support.v7.widget.Toolbar;
7 7 import android.view.Menu;
8 8 import android.view.MenuItem;
9 9  
  10 +import com.crashlytics.android.answers.Answers;
  11 +import com.crashlytics.android.answers.ContentViewEvent;
10 12 import com.monitorabrasil.monitoralegislativo.R;
  13 +import com.monitorabrasil.monitoralegislativo.fragments.EscolhaTipoProjeto;
11 14 import com.monitorabrasil.monitoralegislativo.fragments.ListaPoliticoFragment;
12 15 import com.monitorabrasil.monitoralegislativo.fragments.ListaProjetosFragment;
13 16  
... ... @@ -17,13 +20,27 @@ public class ProjetosActivity extends ActionBarActivity {
17 20 protected void onCreate(Bundle savedInstanceState) {
18 21 super.onCreate(savedInstanceState);
19 22 setContentView(R.layout.activity_projetos);
20   - ListaProjetosFragment frag = (ListaProjetosFragment) getSupportFragmentManager().findFragmentByTag("listaProjFrag");
  23 +
  24 +
  25 + Answers.getInstance().logContentView(new ContentViewEvent()
  26 + .putContentName("ProjetosActivity")
  27 + .putContentType("Activity"));
  28 +
  29 + EscolhaTipoProjeto frag = (EscolhaTipoProjeto) getSupportFragmentManager().findFragmentByTag("listaTipoProjFrag");
  30 + if(frag == null) {
  31 + frag = new EscolhaTipoProjeto();
  32 + FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
  33 + ft.replace(R.id.rl_fragment_container, frag, "listaTipoProjFrag");
  34 + ft.commit();
  35 + }
  36 +
  37 + /*ListaProjetosFragment frag = (ListaProjetosFragment) getSupportFragmentManager().findFragmentByTag("listaProjFrag");
21 38 if(frag == null) {
22 39 frag = new ListaProjetosFragment();
23 40 FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
24 41 ft.replace(R.id.rl_fragment_container, frag, "listaProjFrag");
25 42 ft.commit();
26   - }
  43 + }*/
27 44  
28 45 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
29 46 setSupportActionBar(toolbar);
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/adapters/ProjetoAdapter.java
... ... @@ -40,9 +40,6 @@ public class ProjetoAdapter extends RecyclerView.Adapter<ProjetoAdapter.ViewHold
40 40 private RecyclerViewOnClickListenerHack mRecyclerViewOnClickListenerHack;
41 41 private FragmentActivity mActivity;
42 42  
43   - // Provide a reference to the views for each data item
44   - // Complex data items may need more than one view per item, and
45   - // you provide access to all the views for a data item in a view holder
46 43 public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
47 44 // each data item is just a string in this case
48 45 public ParseObject projetoVotado;
... ... @@ -52,6 +49,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter<ProjetoAdapter.ViewHold
52 49 public TextView descricao;
53 50 public TextView numApoio;
54 51 public TextView numNaoApoio;
  52 + public TextView numero;
55 53 public Button btnConcordo;
56 54 public Button btnDiscordo;
57 55 public Button btnComentar;
... ... @@ -69,6 +67,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter<ProjetoAdapter.ViewHold
69 67 btnConcordo = (Button) v.findViewById(R.id.btnConcordo);
70 68 btnDiscordo = (Button) v.findViewById(R.id.btnDiscordo);
71 69 btnComentar = (Button) v.findViewById(R.id.btnComentar);
  70 + numero = (TextView) v.findViewById(R.id.numero);
72 71  
73 72 itemView.setOnClickListener(this);
74 73 }
... ... @@ -135,7 +134,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter<ProjetoAdapter.ViewHold
135 134 }
136 135 });
137 136  
138   -
  137 + viewHolder.numero.setText("ID: "+projeto.getString("numero"));
139 138 viewHolder.classificacao.setText(projeto.get("classificacao").toString());
140 139 viewHolder.data.setText(projeto.get("data").toString());
141 140 viewHolder.descricao.setText(projeto.get("descricao").toString());
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/adapters/TipoProjetoAdapter.java 0 → 100644
... ... @@ -0,0 +1,92 @@
  1 +package com.monitorabrasil.monitoralegislativo.adapters;
  2 +
  3 +import android.support.v4.app.FragmentActivity;
  4 +import android.support.v7.widget.RecyclerView;
  5 +import android.view.LayoutInflater;
  6 +import android.view.View;
  7 +import android.view.ViewGroup;
  8 +import android.widget.TextView;
  9 +
  10 +import com.monitorabrasil.monitoralegislativo.R;
  11 +import com.monitorabrasil.monitoralegislativo.interfaces.RecyclerViewOnClickListenerHack;
  12 +import com.parse.ParseObject;
  13 +
  14 +import java.util.List;
  15 +
  16 +/**
  17 + * Created by geral_000 on 23/07/2015.
  18 + */
  19 +public class TipoProjetoAdapter extends RecyclerView.Adapter<TipoProjetoAdapter.ViewHolder> {
  20 +
  21 + private List<ParseObject> mDataset;
  22 + private RecyclerViewOnClickListenerHack mRecyclerViewOnClickListenerHack;
  23 + private FragmentActivity mActivity;
  24 + int[] cores = new int[]{R.color.cor1, R.color.cor2,R.color.cor3, R.color.cor4,R.color.cor5, R.color.cor6,
  25 + R.color.cor7, R.color.cor8,R.color.cor9, R.color.cor10};
  26 +
  27 + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
  28 + // each data item is just a string in this case
  29 +
  30 + public TextView txtTipoProjeto;
  31 + public ParseObject tipoProjeto;
  32 +
  33 + public ViewHolder(View v) {
  34 + super(v);
  35 + txtTipoProjeto = (TextView) v.findViewById(R.id.txtTipoProjeto);
  36 + itemView.setOnClickListener(this);
  37 + }
  38 +
  39 + @Override
  40 + public void onClick(View v) {
  41 + if(mRecyclerViewOnClickListenerHack != null){
  42 + mRecyclerViewOnClickListenerHack.onClickListener(v, getPosition());
  43 + }
  44 + }
  45 + }
  46 +
  47 + public TipoProjetoAdapter(List<ParseObject> myDataset, FragmentActivity activity) {
  48 + mDataset = myDataset;
  49 + mActivity = activity;
  50 + }
  51 +
  52 + @Override
  53 + public TipoProjetoAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
  54 + // create a new view
  55 + View v = LayoutInflater.from(viewGroup.getContext())
  56 + .inflate(R.layout.item_tipo_projeto, viewGroup, false);
  57 + // set the view's size, margins, paddings and layout parameter
  58 + ViewHolder vh = new ViewHolder(v);
  59 + return vh;
  60 + }
  61 +
  62 + @Override
  63 + public void onBindViewHolder(final ViewHolder viewHolder, int i) {
  64 +
  65 + final ParseObject tipoProjeto = mDataset.get(i);
  66 + viewHolder.tipoProjeto = tipoProjeto;
  67 +
  68 + viewHolder.txtTipoProjeto.setText(tipoProjeto.getString("nome"));
  69 + int posCor=i;
  70 + if(i > 19)
  71 + posCor = i-20;
  72 + else
  73 + if(i > 9)
  74 + posCor = i-10;
  75 +
  76 + viewHolder.txtTipoProjeto.setBackgroundResource(cores[posCor]);
  77 + }
  78 +
  79 +
  80 + public void setRecyclerViewOnClickListenerHack(RecyclerViewOnClickListenerHack r){
  81 + mRecyclerViewOnClickListenerHack = r;
  82 + }
  83 +
  84 + @Override
  85 + public int getItemCount() {
  86 + return mDataset.size();
  87 + }
  88 +
  89 + public String getItem(int i){
  90 + return mDataset.get(i).getString("nome");
  91 + }
  92 +}
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/EscolhaTipoProjeto.java 0 → 100644
... ... @@ -0,0 +1,164 @@
  1 +package com.monitorabrasil.monitoralegislativo.fragments;
  2 +
  3 +import android.net.Uri;
  4 +import android.os.Bundle;
  5 +import android.support.v4.app.Fragment;
  6 +import android.support.v4.app.FragmentTransaction;
  7 +import android.support.v7.widget.GridLayoutManager;
  8 +import android.support.v7.widget.RecyclerView;
  9 +import android.util.Log;
  10 +import android.view.LayoutInflater;
  11 +import android.view.View;
  12 +import android.view.ViewGroup;
  13 +
  14 +import com.monitorabrasil.monitoralegislativo.R;
  15 +import com.monitorabrasil.monitoralegislativo.adapters.TipoProjetoAdapter;
  16 +import com.monitorabrasil.monitoralegislativo.interfaces.RecyclerViewOnClickListenerHack;
  17 +import com.parse.FindCallback;
  18 +import com.parse.ParseObject;
  19 +import com.parse.ParseQuery;
  20 +
  21 +import java.util.List;
  22 +
  23 +/**
  24 + * A simple {@link Fragment} subclass.
  25 + * Activities that contain this fragment must implement the
  26 + * {@link EscolhaTipoProjeto.OnFragmentInteractionListener} interface
  27 + * to handle interaction events.
  28 + * Use the {@link EscolhaTipoProjeto#newInstance} factory method to
  29 + * create an instance of this fragment.
  30 + */
  31 +public class EscolhaTipoProjeto extends Fragment implements RecyclerViewOnClickListenerHack {
  32 + // TODO: Rename parameter arguments, choose names that match
  33 + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  34 + private static final String ARG_PARAM1 = "param1";
  35 + private static final String ARG_PARAM2 = "param2";
  36 + private RecyclerView mRecyclerView;
  37 + private TipoProjetoAdapter mAdapter;
  38 +
  39 + // TODO: Rename and change types of parameters
  40 + private String mParam1;
  41 + private String mParam2;
  42 +
  43 + private OnFragmentInteractionListener mListener;
  44 +
  45 + /**
  46 + * Use this factory method to create a new instance of
  47 + * this fragment using the provided parameters.
  48 + *
  49 + * @param param1 Parameter 1.
  50 + * @param param2 Parameter 2.
  51 + * @return A new instance of fragment EscolhaTipoProjeto.
  52 + */
  53 + // TODO: Rename and change types and number of parameters
  54 + public static EscolhaTipoProjeto newInstance(String param1, String param2) {
  55 + EscolhaTipoProjeto fragment = new EscolhaTipoProjeto();
  56 + Bundle args = new Bundle();
  57 + args.putString(ARG_PARAM1, param1);
  58 + args.putString(ARG_PARAM2, param2);
  59 + fragment.setArguments(args);
  60 + return fragment;
  61 + }
  62 +
  63 + public EscolhaTipoProjeto() {
  64 + // Required empty public constructor
  65 + }
  66 +
  67 + @Override
  68 + public void onCreate(Bundle savedInstanceState) {
  69 + super.onCreate(savedInstanceState);
  70 + if (getArguments() != null) {
  71 + mParam1 = getArguments().getString(ARG_PARAM1);
  72 + mParam2 = getArguments().getString(ARG_PARAM2);
  73 + }
  74 + }
  75 +
  76 + @Override
  77 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
  78 + Bundle savedInstanceState) {
  79 + View view = inflater.inflate(R.layout.fragment_escolha_tipo_projeto, container, false);
  80 +
  81 + //tableview
  82 + mRecyclerView = (RecyclerView) view.findViewById(R.id.rv_escolha_tipo);
  83 +
  84 + // use this setting to improve performance if you know that changes
  85 + // in content do not change the layout size of the RecyclerView
  86 + mRecyclerView.setHasFixedSize(true);
  87 +
  88 + GridLayoutManager llm = new GridLayoutManager(getActivity(),2,GridLayoutManager.VERTICAL, false);
  89 + mRecyclerView.setLayoutManager(llm);
  90 +
  91 + //busca os tipos de projetos
  92 + buscaTiposProjetos();
  93 +
  94 + return view;
  95 + }
  96 +
  97 + private void buscaTiposProjetos() {
  98 + ParseQuery<ParseObject> query = ParseQuery.getQuery("TipoProjeto");
  99 + query.addAscendingOrder("nome");
  100 + query.findInBackground(new FindCallback<ParseObject>() {
  101 + @Override
  102 + public void done(List<ParseObject> list, com.parse.ParseException e) {
  103 + if (e == null) {
  104 + carregaList(list);
  105 + } else {
  106 + Log.d("score", "Error: " + e.getMessage());
  107 + }
  108 + }
  109 +
  110 +
  111 + });
  112 + }
  113 +
  114 + private void carregaList(List<ParseObject> list) {
  115 + mAdapter = new TipoProjetoAdapter(list,getActivity());
  116 + mAdapter.setRecyclerViewOnClickListenerHack(this);
  117 + mRecyclerView.setAdapter(mAdapter);
  118 + //pb.setVisibility(View.INVISIBLE);
  119 + }
  120 +
  121 + @Override
  122 + public void onClickListener(View view, int position) {
  123 + ListaProjetosFragment frag = (ListaProjetosFragment) getActivity().getSupportFragmentManager().findFragmentByTag("listaProjFrag");
  124 + if(frag == null) {
  125 + frag = ListaProjetosFragment.newInstance(mAdapter.getItem(position),null);
  126 + FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
  127 + ft.replace(R.id.rl_fragment_container, frag, "listaProjFrag");
  128 + ft.addToBackStack(null);
  129 + ft.commit();
  130 + }
  131 +
  132 + }
  133 +
  134 + // TODO: Rename method, update argument and hook method into UI event
  135 + public void onButtonPressed(Uri uri) {
  136 + if (mListener != null) {
  137 + mListener.onFragmentInteraction(uri);
  138 + }
  139 + }
  140 +
  141 +
  142 +
  143 + @Override
  144 + public void onDetach() {
  145 + super.onDetach();
  146 + mListener = null;
  147 + }
  148 +
  149 + /**
  150 + * This interface must be implemented by activities that contain this
  151 + * fragment to allow an interaction in this fragment to be communicated
  152 + * to the activity and potentially other fragments contained in that
  153 + * activity.
  154 + * <p/>
  155 + * See the Android Training lesson <a href=
  156 + * "http://developer.android.com/training/basics/fragments/communicating.html"
  157 + * >Communicating with Other Fragments</a> for more information.
  158 + */
  159 + public interface OnFragmentInteractionListener {
  160 + // TODO: Update argument type and name
  161 + public void onFragmentInteraction(Uri uri);
  162 + }
  163 +
  164 +}
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/GastosCamaraFragment.java
... ... @@ -244,6 +244,27 @@ public class GastosCamaraFragment extends Fragment {
244 244 case "MAI":
245 245 ret=4;
246 246 break;
  247 + case "JUN":
  248 + ret=5;
  249 + break;
  250 + case "JUL":
  251 + ret=6;
  252 + break;
  253 + case "AGO":
  254 + ret=7;
  255 + break;
  256 + case "SET":
  257 + ret=8;
  258 + break;
  259 + case "OUT":
  260 + ret=9;
  261 + break;
  262 + case "NOV":
  263 + ret=10;
  264 + break;
  265 + case "DEZ":
  266 + ret=11;
  267 + break;
247 268  
248 269 }
249 270 return ret;
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/GastosFragment.java
... ... @@ -142,6 +142,7 @@ public class GastosFragment extends Fragment {
142 142  
143 143 ParseQuery<ParseObject> query = ParseQuery.getQuery("Verba");
144 144 query.whereEqualTo("politico",politico);
  145 + query.orderByAscending("createdAt");
145 146 query.findInBackground(new FindCallback<ParseObject>() {
146 147 public void done(List<ParseObject> gastos, ParseException e) {
147 148 Iterator<ParseObject> gastoIt = gastos.iterator();
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/HomeFragment.java
... ... @@ -122,39 +122,35 @@ public class HomeFragment extends Fragment implements RecyclerViewOnClickListene
122 122 query.addAscendingOrder("mes_numero");
123 123 query.findInBackground(new FindCallback<ParseObject>() {
124 124 public void done(List<ParseObject> gastos, ParseException e) {
  125 + if(null != gastos){
  126 + Iterator<ParseObject> gastoIt = gastos.iterator();
  127 +
  128 + while (gastoIt.hasNext()) {
  129 +
  130 + ParseObject g = gastoIt.next();
  131 + String mes = g.getString("mes");
  132 + Float novoValor = Float.valueOf(g.getString("valor"));
  133 + Float valor = valorTotal.get(mes);
  134 + if (valor != null) {
  135 + valor = valor + novoValor;
  136 + valorTotal.remove(mes);
  137 + valorTotal.put(mes, valor);
  138 + } else {
  139 + valorTotal.put(mes, novoValor);
  140 + }
  141 + if (!xVals.contains(mes)) {
  142 + xVals.add(mes);
  143 + }
125 144  
126   - Iterator<ParseObject> gastoIt = gastos.iterator();
127   -
128   - while (gastoIt.hasNext()) {
129   -
130   - ParseObject g = gastoIt.next();
131   - String mes = g.getString("mes");
132   - Float novoValor = Float.valueOf(g.getString("valor"));
133   - Float valor = valorTotal.get(mes);
134   - if (valor != null) {
135   - valor = valor + novoValor;
136   - valorTotal.remove(mes);
137   - valorTotal.put(mes, valor);
138   - } else {
139   - valorTotal.put(mes, novoValor);
140 145 }
141   - if (!xVals.contains(mes)) {
142   - xVals.add(mes);
  146 + for (int j = 0; j < xVals.size(); j++) {
  147 + Float val = valorTotal.get(xVals.get(j));
  148 + yVals1.add(new BarEntry(val, j));
143 149 }
144   -
145   - //
146   -
147   -
148   - }
149   - for (int j = 0; j < xVals.size(); j++) {
150   - Float val = valorTotal.get(xVals.get(j));
151   - yVals1.add(new BarEntry(val, j));
  150 + Grafico grafico = new Grafico("Todos", yVals1, xVals, R.color.cor10);
  151 + buildGraph(grafico);
152 152 }
153   - Grafico grafico = new Grafico("Todos", yVals1, xVals, R.color.cor10);
154   - buildGraph(grafico);
155   -// pb.setVisibility(View.INVISIBLE);
156 153  
157   - // setData();
158 154  
159 155 }
160 156 });
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/ListaProjetosFragment.java
... ... @@ -32,6 +32,32 @@ public class ListaProjetosFragment extends Fragment implements RecyclerViewOnCli
32 32 private ProjetoAdapter mAdapter;
33 33 private List<ParseObject> ob;
34 34 private ProgressBar pb;
  35 + private static final String TIPO_PROJETO = "tipoProjeto";
  36 + private static final String ID_POLITICO = "idPolitico";
  37 + private String tipoProjeto;
  38 + private String idPolitico;
  39 +
  40 +
  41 + public static ListaProjetosFragment newInstance(String tipoProjeto, String idPolitico) {
  42 + ListaProjetosFragment fragment = new ListaProjetosFragment();
  43 + Bundle args = new Bundle();
  44 + args.putString(TIPO_PROJETO, tipoProjeto);
  45 + args.putString(ID_POLITICO, idPolitico);
  46 + fragment.setArguments(args);
  47 + return fragment;
  48 + }
  49 + public ListaProjetosFragment(){
  50 +
  51 + }
  52 +
  53 + @Override
  54 + public void onCreate(Bundle savedInstanceState) {
  55 + super.onCreate(savedInstanceState);
  56 + if (getArguments() != null) {
  57 + tipoProjeto = getArguments().getString(TIPO_PROJETO);
  58 + idPolitico = getArguments().getString(ID_POLITICO);
  59 + }
  60 + }
35 61  
36 62  
37 63 @Override
... ... @@ -39,6 +65,7 @@ public class ListaProjetosFragment extends Fragment implements RecyclerViewOnCli
39 65 Bundle savedInstanceState) {
40 66 // Inflate the layout for this fragment
41 67 View view = inflater.inflate(R.layout.fragment_lista_projetos, container, false);
  68 + // View view = inflater.inflate(R.layout.fragment_escolha_tipo_projeto, container, false);
42 69  
43 70 pb = (ProgressBar) view.findViewById(R.id.progressBar);
44 71  
... ... @@ -61,11 +88,15 @@ public class ListaProjetosFragment extends Fragment implements RecyclerViewOnCli
61 88 public void buscaProjetos(){
62 89 ParseQuery<ParseObject> query = ParseQuery.getQuery("Projeto");
63 90 query.addDescendingOrder("createdAt");
64   - Bundle bundle = getArguments();
65   - if(bundle != null){
66   - if(bundle.get("politico") != null){
67   - query.whereEqualTo("politico", buscaPolitico(bundle.getString("politico")));
68   - }
  91 +
  92 + if(idPolitico!= null){
  93 +
  94 + query.whereEqualTo("politico", buscaPolitico(idPolitico));
  95 +
  96 + }
  97 +
  98 + if(tipoProjeto != null){
  99 + query.whereEqualTo("classificacao", tipoProjeto);
69 100 }
70 101  
71 102  
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/PoliticoFichaFragment.java
... ... @@ -3,6 +3,7 @@ package com.monitorabrasil.monitoralegislativo.fragments;
3 3 import android.content.DialogInterface;
4 4 import android.graphics.PorterDuff;
5 5 import android.graphics.drawable.LayerDrawable;
  6 +import android.os.Build;
6 7 import android.os.Bundle;
7 8 import android.support.design.widget.Snackbar;
8 9 import android.support.v4.app.Fragment;
... ... @@ -15,12 +16,16 @@ import android.widget.ImageView;
15 16 import android.widget.RatingBar;
16 17 import android.widget.TextView;
17 18  
  19 +import com.crashlytics.android.answers.Answers;
  20 +import com.crashlytics.android.answers.ContentViewEvent;
18 21 import com.monitorabrasil.monitoralegislativo.R;
19 22 import com.monitorabrasil.monitoralegislativo.application.MyApp;
20 23 import com.monitorabrasil.monitoralegislativo.dialogs.DialogAvaliacao;
  24 +import com.parse.Parse;
21 25 import com.parse.ParseException;
22 26 import com.parse.ParseObject;
23 27 import com.parse.ParseQuery;
  28 +import com.parse.ParseUser;
24 29  
25 30 /**
26 31 * Created by geral_000 on 20/06/2015.
... ... @@ -38,6 +43,9 @@ public class PoliticoFichaFragment extends Fragment {
38 43 ViewGroup container,
39 44 Bundle savedInstanceState) {
40 45 View view = inflater.inflate(R.layout.fragment_politico_detalhe, container, false);
  46 +
  47 +
  48 +
41 49 mView=view;
42 50 mRatingBar = (RatingBar)view.findViewById(R.id.ratingBar);
43 51  
... ... @@ -48,36 +56,50 @@ public class PoliticoFichaFragment extends Fragment {
48 56 Bundle bundle = getArguments();
49 57 politico = buscaPolitico(bundle.getString("politico")) ;
50 58  
  59 + Answers.getInstance().logContentView(new ContentViewEvent()
  60 + .putContentName("PoliticoFichaFragment")
  61 + .putContentType("Fragment")
  62 + .putCustomAttribute("vereador",politico.getString("nome")));
  63 +
  64 +
51 65 mRatingBar.setRating((float) politico.getDouble("avaliacao"));
52 66  
53   - LayerDrawable stars = (LayerDrawable) mRatingBar.getProgressDrawable();
54   - stars.getDrawable(2).setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
55   - stars.getDrawable(1).setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
56   - stars.getDrawable(0).setColorFilter(getResources().getColor(R.color.coloLink), PorterDuff.Mode.SRC_ATOP);
  67 + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
  68 + LayerDrawable stars = (LayerDrawable) mRatingBar.getProgressDrawable();
  69 + stars.getDrawable(2).setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
  70 + stars.getDrawable(1).setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
  71 + stars.getDrawable(0).setColorFilter(getResources().getColor(R.color.coloLink), PorterDuff.Mode.SRC_ATOP);
  72 + }
  73 +
57 74  
58 75 //btnAvaliar
59 76 btnAvaliar = (Button) view.findViewById(R.id.btnAvalie);
60 77 btnAvaliar.setOnClickListener(new View.OnClickListener() {
61 78 @Override
62 79 public void onClick(final View v) {
63   - DialogAvaliacao avaliacao =new DialogAvaliacao(politico, "Avalie");
64   -
65   - avaliacao.setOnDismissListener(new DialogInterface.OnDismissListener() {
66   - @Override
67   - public void onDismiss(DialogInterface dialog) {
68   - //atualizar a avaliacao
69   - try {
70   - politico.fetchFromLocalDatastore();
71   - mRatingBar.setRating((float) politico.getDouble("avaliacao"));
72   - Snackbar.make(v, "Avaliação salva.", Snackbar.LENGTH_LONG)
73   - .setAction("Action", null).show();
74   - } catch (ParseException e) {
75   - e.printStackTrace();
76   - }
77   -
  80 + if(ParseUser.getCurrentUser() != null){
  81 + DialogAvaliacao avaliacao =new DialogAvaliacao(politico, "Avalie");
  82 + avaliacao.setOnDismissListener(new DialogInterface.OnDismissListener() {
  83 + @Override
  84 + public void onDismiss(DialogInterface dialog) {
  85 + //atualizar a avaliacao
  86 + try {
  87 + politico.fetchFromLocalDatastore();
  88 + mRatingBar.setRating((float) politico.getDouble("avaliacao"));
  89 + Snackbar.make(v, "Avaliação salva.", Snackbar.LENGTH_LONG)
  90 + .setAction("Action", null).show();
  91 + } catch (ParseException e) {
  92 + e.printStackTrace();
78 93 }
79   - });
80   - avaliacao.show(getActivity().getFragmentManager(), "dialogAvaliar");
  94 +
  95 + }
  96 + });
  97 + avaliacao.show(getActivity().getFragmentManager(), "dialogAvaliar");
  98 + }else{
  99 + Snackbar.make(v, "É necessário logar para avaliar.", Snackbar.LENGTH_LONG)
  100 + .setAction("Action", null).show();
  101 + }
  102 +
81 103 }
82 104 });
83 105  
... ...
app/src/main/res/layout/fragment_escolha_tipo_projeto.xml 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent">
  5 +
  6 +
  7 + <TextView
  8 + android:layout_width="wrap_content"
  9 + android:layout_height="wrap_content"
  10 + android:textAppearance="?android:attr/textAppearanceLarge"
  11 + android:text="Escolha o tipo de Indicação"
  12 + android:id="@+id/textView6"
  13 + android:layout_alignParentTop="true"
  14 + android:layout_centerHorizontal="true"
  15 + android:paddingTop="16dp"
  16 + android:textColor="@color/colorPrimarytext" />
  17 +
  18 + <android.support.v7.widget.RecyclerView
  19 + android:id="@+id/rv_escolha_tipo"
  20 + android:scrollbars="vertical"
  21 + android:layout_width="match_parent"
  22 + android:layout_height="match_parent"
  23 + android:layout_below="@+id/textView6"
  24 + android:layout_margin="16dp" />
  25 +
  26 +</RelativeLayout>
0 27 \ No newline at end of file
... ...
app/src/main/res/layout/fragment_home.xml
... ... @@ -28,7 +28,7 @@
28 28 android:layout_width="wrap_content"
29 29 android:layout_height="wrap_content"
30 30 android:textAppearance="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
31   - android:text="Ranking"
  31 + android:text="Avaliação de usuários - ranking"
32 32 android:id="@+id/textView4"
33 33 android:paddingTop="8dp"
34 34 android:paddingLeft="16dp"
... ...
app/src/main/res/layout/fragment_lista_projetos.xml
1 1 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 2 android:layout_width="match_parent"
3   - android:layout_height="match_parent"
4   -
5   - >
  3 + android:layout_height="match_parent">
6 4  
7 5 <android.support.v7.widget.RecyclerView
8 6 android:id="@+id/my_recycler_view"
... ...
app/src/main/res/layout/item_projeto.xml
... ... @@ -26,6 +26,12 @@
26 26 android:id="@+id/data"
27 27 android:textAppearance="@style/TextAppearance.AppCompat.Small"
28 28 />
  29 + <TextView
  30 + android:layout_width="match_parent"
  31 + android:layout_height="wrap_content"
  32 + android:id="@+id/numero"
  33 + android:textAppearance="@style/TextAppearance.AppCompat.Small"
  34 + />
29 35  
30 36 <TextView
31 37 android:layout_width="match_parent"
... ...
app/src/main/res/layout/item_tipo_projeto.xml 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:orientation="vertical" android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + android:background="@color/cor1">
  6 +
  7 + <TextView
  8 + android:layout_width="fill_parent"
  9 + android:layout_height="100dp"
  10 + android:text="New Text"
  11 + android:id="@+id/txtTipoProjeto"
  12 + android:layout_gravity="center_horizontal"
  13 + android:gravity="center_vertical|center_horizontal"
  14 + android:padding="5dp"
  15 + android:textColor="@color/md_white_1000"
  16 + android:textStyle="bold" />
  17 +</LinearLayout>
0 18 \ No newline at end of file
... ...
app/src/main/res/values/strings.xml
... ... @@ -19,5 +19,8 @@
19 19 <string name="projeto_naoapoio">Não Apoio</string>
20 20 <string name="title_activity_comentario">ComentarioActivity</string>
21 21  
  22 +<!-- TODO: Remove or change this placeholder text -->
  23 + <string name="hello_blank_fragment">Hello blank fragment</string>
  24 +
22 25  
23 26 </resources>
... ...
build/intermediates/gradle_project_sync_data.bin
No preview for this file type