Commit 92296cd5015b99e36beb1bb5bf073124fb021b6c

Authored by geraldo morais
1 parent 15180ba7
Exists in master

implementado os comentários em projetos

@@ -120,45 +120,45 @@ @@ -120,45 +120,45 @@
120 </content> 120 </content>
121 <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" /> 121 <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
122 <orderEntry type="sourceFolder" forTests="false" /> 122 <orderEntry type="sourceFolder" forTests="false" />
123 - <orderEntry type="library" exported="" name="design-22.2.0" level="project" />  
124 - <orderEntry type="library" exported="" name="iconics-1.0.2" level="project" />  
125 - <orderEntry type="library" exported="" name="play-services-base-7.5.0" level="project" />  
126 - <orderEntry type="library" exported="" name="crashlytics-core-2.3.3" level="project" />  
127 - <orderEntry type="library" exported="" name="Parse-1.9.2" level="project" />  
128 - <orderEntry type="library" exported="" name="play-services-appinvite-7.5.0" level="project" />  
129 - <orderEntry type="library" exported="" name="play-services-panorama-7.5.0" level="project" /> 123 + <orderEntry type="library" exported="" name="play-services-wallet-7.5.0" level="project" />
  124 + <orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
  125 + <orderEntry type="library" exported="" name="play-services-cast-7.5.0" level="project" />
  126 + <orderEntry type="library" exported="" name="mediarouter-v7-22.0.0" level="project" />
  127 + <orderEntry type="library" exported="" name="recyclerview-v7-22.2.0" level="project" />
130 <orderEntry type="library" exported="" name="play-services-drive-7.5.0" level="project" /> 128 <orderEntry type="library" exported="" name="play-services-drive-7.5.0" level="project" />
131 - <orderEntry type="library" exported="" name="crashlytics-2.4.0" level="project" />  
132 - <orderEntry type="library" exported="" name="answers-1.2.2" level="project" />  
133 - <orderEntry type="library" exported="" name="play-services-gcm-7.5.0" level="project" /> 129 + <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
  130 + <orderEntry type="library" exported="" name="play-services-analytics-7.5.0" level="project" />
  131 + <orderEntry type="library" exported="" name="play-services-panorama-7.5.0" level="project" />
  132 + <orderEntry type="library" exported="" name="materialdrawer-3.0.6" level="project" />
  133 + <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
134 <orderEntry type="library" exported="" name="play-services-appindexing-7.5.0" level="project" /> 134 <orderEntry type="library" exported="" name="play-services-appindexing-7.5.0" level="project" />
135 - <orderEntry type="library" exported="" name="MPAndroidChart-v2.1.0" level="project" />  
136 - <orderEntry type="library" exported="" name="play-services-wearable-7.5.0" level="project" /> 135 + <orderEntry type="library" exported="" name="play-services-location-7.5.0" level="project" />
  136 + <orderEntry type="library" exported="" name="Parse-1.9.2" level="project" />
  137 + <orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" />
137 <orderEntry type="library" exported="" name="play-services-safetynet-7.5.0" level="project" /> 138 <orderEntry type="library" exported="" name="play-services-safetynet-7.5.0" level="project" />
138 - <orderEntry type="library" exported="" name="play-services-games-7.5.0" level="project" />  
139 - <orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />  
140 - <orderEntry type="library" exported="" name="fabric-1.3.4" level="project" />  
141 - <orderEntry type="library" exported="" name="play-services-plus-7.5.0" level="project" />  
142 - <orderEntry type="library" exported="" name="play-services-maps-7.5.0" level="project" />  
143 - <orderEntry type="library" exported="" name="play-services-fitness-7.5.0" level="project" />  
144 - <orderEntry type="library" exported="" name="mediarouter-v7-22.0.0" level="project" /> 139 + <orderEntry type="library" exported="" name="play-services-base-7.5.0" level="project" />
145 <orderEntry type="library" exported="" name="play-services-7.5.0" level="project" /> 140 <orderEntry type="library" exported="" name="play-services-7.5.0" level="project" />
146 - <orderEntry type="library" exported="" name="play-services-analytics-7.5.0" level="project" />  
147 - <orderEntry type="library" exported="" name="play-services-wallet-7.5.0" level="project" />  
148 - <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />  
149 - <orderEntry type="library" exported="" name="play-services-identity-7.5.0" level="project" /> 141 + <orderEntry type="library" exported="" name="play-services-gcm-7.5.0" level="project" />
150 <orderEntry type="library" exported="" name="bolts-android-1.2.0" level="project" /> 142 <orderEntry type="library" exported="" name="bolts-android-1.2.0" level="project" />
151 - <orderEntry type="library" exported="" name="materialdrawer-3.0.6" level="project" />  
152 - <orderEntry type="library" exported="" name="recyclerview-v7-22.2.0" level="project" />  
153 - <orderEntry type="library" exported="" name="cardview-v7-22.2.0" level="project" />  
154 - <orderEntry type="library" exported="" name="gson-2.3.1" level="project" />  
155 - <orderEntry type="library" exported="" name="play-services-appstate-7.5.0" level="project" />  
156 - <orderEntry type="library" exported="" name="play-services-nearby-7.5.0" level="project" /> 143 + <orderEntry type="library" exported="" name="play-services-appinvite-7.5.0" level="project" />
  144 + <orderEntry type="library" exported="" name="iconics-1.0.2" level="project" />
  145 + <orderEntry type="library" exported="" name="fabric-1.3.4" level="project" />
157 <orderEntry type="library" exported="" name="beta-1.1.3" level="project" /> 146 <orderEntry type="library" exported="" name="beta-1.1.3" level="project" />
158 <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" /> 147 <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
159 - <orderEntry type="library" exported="" name="play-services-cast-7.5.0" level="project" />  
160 - <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />  
161 - <orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" />  
162 - <orderEntry type="library" exported="" name="play-services-location-7.5.0" level="project" /> 148 + <orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />
  149 + <orderEntry type="library" exported="" name="crashlytics-core-2.3.3" level="project" />
  150 + <orderEntry type="library" exported="" name="play-services-fitness-7.5.0" level="project" />
  151 + <orderEntry type="library" exported="" name="play-services-nearby-7.5.0" level="project" />
  152 + <orderEntry type="library" exported="" name="crashlytics-2.4.0" level="project" />
  153 + <orderEntry type="library" exported="" name="play-services-plus-7.5.0" level="project" />
  154 + <orderEntry type="library" exported="" name="play-services-wearable-7.5.0" level="project" />
  155 + <orderEntry type="library" exported="" name="play-services-appstate-7.5.0" level="project" />
  156 + <orderEntry type="library" exported="" name="play-services-games-7.5.0" level="project" />
  157 + <orderEntry type="library" exported="" name="play-services-identity-7.5.0" level="project" />
  158 + <orderEntry type="library" exported="" name="MPAndroidChart-v2.1.0" level="project" />
  159 + <orderEntry type="library" exported="" name="answers-1.2.2" level="project" />
  160 + <orderEntry type="library" exported="" name="design-22.2.0" level="project" />
  161 + <orderEntry type="library" exported="" name="play-services-maps-7.5.0" level="project" />
  162 + <orderEntry type="library" exported="" name="cardview-v7-22.2.0" level="project" />
163 </component> 163 </component>
164 </module> 164 </module>
165 \ No newline at end of file 165 \ No newline at end of file
app/build.gradle
@@ -18,13 +18,14 @@ repositories { @@ -18,13 +18,14 @@ repositories {
18 android { 18 android {
19 compileSdkVersion 22 19 compileSdkVersion 22
20 buildToolsVersion "23.0.0 rc2" 20 buildToolsVersion "23.0.0 rc2"
  21 + compileOptions.encoding = 'ISO-8859-1'
21 22
22 defaultConfig { 23 defaultConfig {
23 applicationId "com.monitorabrasil.monitoramunicipio" 24 applicationId "com.monitorabrasil.monitoramunicipio"
24 minSdkVersion 16 25 minSdkVersion 16
25 targetSdkVersion 22 26 targetSdkVersion 22
26 - versionCode 4  
27 - versionName "0.4" 27 + versionCode 5
  28 + versionName "0.5"
28 } 29 }
29 buildTypes { 30 buildTypes {
30 release { 31 release {
app/src/main/java/com/monitorabrasil/monitoralegislativo/ComentarioActivity.java
1 package com.monitorabrasil.monitoralegislativo; 1 package com.monitorabrasil.monitoralegislativo;
2 2
  3 +import android.content.Intent;
  4 +import android.os.Build;
  5 +import android.support.design.widget.Snackbar;
3 import android.support.v7.app.ActionBarActivity; 6 import android.support.v7.app.ActionBarActivity;
4 import android.os.Bundle; 7 import android.os.Bundle;
  8 +import android.support.v7.app.AppCompatActivity;
  9 +import android.support.v7.widget.LinearLayoutManager;
  10 +import android.support.v7.widget.RecyclerView;
  11 +import android.support.v7.widget.Toolbar;
  12 +import android.transition.Transition;
  13 +import android.transition.TransitionInflater;
  14 +import android.util.Log;
5 import android.view.Menu; 15 import android.view.Menu;
6 import android.view.MenuItem; 16 import android.view.MenuItem;
  17 +import android.view.View;
  18 +import android.widget.Button;
  19 +import android.widget.EditText;
  20 +import android.widget.ProgressBar;
7 21
  22 +import com.google.gson.Gson;
8 import com.monitorabrasil.monitoralegislativo.R; 23 import com.monitorabrasil.monitoralegislativo.R;
  24 +import com.monitorabrasil.monitoralegislativo.adapters.ComentarioAdapter;
  25 +import com.monitorabrasil.monitoralegislativo.application.MyApp;
  26 +import com.parse.FindCallback;
  27 +import com.parse.GetCallback;
  28 +import com.parse.ParseException;
  29 +import com.parse.ParseObject;
  30 +import com.parse.ParseQuery;
  31 +import com.parse.ParseUser;
  32 +import com.parse.SaveCallback;
9 33
10 -public class ComentarioActivity extends ActionBarActivity { 34 +import java.util.List;
  35 +
  36 +public class ComentarioActivity extends AppCompatActivity {
  37 +
  38 + private ParseObject projeto;
  39 + private Toolbar mToolbar;
  40 + private RecyclerView mRecyclerView;
  41 + private ComentarioAdapter mAdapter;
  42 + private List<ParseObject> ob;
  43 + private ProgressBar pb;
11 44
12 @Override 45 @Override
13 protected void onCreate(Bundle savedInstanceState) { 46 protected void onCreate(Bundle savedInstanceState) {
14 super.onCreate(savedInstanceState); 47 super.onCreate(savedInstanceState);
15 setContentView(R.layout.activity_comentario); 48 setContentView(R.layout.activity_comentario);
  49 + Gson gson =new Gson();
  50 + Intent bundle = getIntent();
  51 +
  52 + ParseQuery<ParseObject> query = ParseQuery.getQuery("Projeto");
  53 + query.getInBackground(getIntent().getStringExtra("projeto"), new GetCallback<ParseObject>() {
  54 + public void done(ParseObject object, ParseException e) {
  55 + if (e == null) {
  56 + projeto = object;
  57 + mToolbar.setTitle(projeto.get("classificacao").toString());
  58 + buscaComentarios();
  59 + } else {
  60 + // something went wrong
  61 + }
  62 + }
  63 + });
  64 +
  65 +
  66 + // TOOLBAR
  67 + mToolbar = (Toolbar) findViewById(R.id.tb_main);
  68 +
  69 + //mToolbar.setSubtitle("just a subtitle");
  70 + //mToolbar.setLogo(R.drawable.ic_launcher);
  71 + setSupportActionBar(mToolbar);
  72 + mToolbar.setTitleTextColor(getResources().getColor(R.color.md_white_1000));
  73 +
  74 + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
  75 + //fazer a animacao
  76 + TransitionInflater inflater = TransitionInflater.from(this);
  77 + Transition transition = inflater.inflateTransition(R.transition.transitions);
  78 +
  79 + getWindow().setSharedElementEnterTransition(transition);
  80 + }
  81 +
  82 + //botao para enviar mensagem
  83 + Button btnEnviar = (Button)findViewById(R.id.btnEnviar);
  84 + btnEnviar.setOnClickListener(new View.OnClickListener() {
  85 + @Override
  86 + public void onClick(View v) {
  87 + enviarMensagem(v);
  88 + }
  89 + });
  90 +
  91 + pb = (ProgressBar) findViewById(R.id.progressBar);
  92 +
  93 +
  94 + //tableview
  95 + mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
  96 +
  97 + // use this setting to improve performance if you know that changes
  98 + // in content do not change the layout size of the RecyclerView
  99 + mRecyclerView.setHasFixedSize(true);
  100 +
  101 + LinearLayoutManager llm = new LinearLayoutManager(this);
  102 + llm.setOrientation(LinearLayoutManager.VERTICAL);
  103 + mRecyclerView.setLayoutManager(llm);
  104 +
  105 +
  106 +
  107 + }
  108 +
  109 + public void buscaComentarios(){
  110 + pb.setVisibility(View.VISIBLE);
  111 + ParseQuery<ParseObject> query = ParseQuery.getQuery("Comentario");
  112 + query.whereEqualTo("projeto",projeto);
  113 + query.addAscendingOrder("createdAt");
  114 + //query.whereEqualTo("playerName", "Dan Stemkoski");
  115 + query.findInBackground(new FindCallback<ParseObject>() {
  116 + @Override
  117 + public void done(List<ParseObject> list, com.parse.ParseException e) {
  118 + if (e == null) {
  119 + ob = list;
  120 + carregaList(list);
  121 + } else {
  122 + Log.d("score", "Error: " + e.getMessage());
  123 + }
  124 + }
  125 +
  126 +
  127 + });
  128 + }
  129 + public void carregaList(List<ParseObject> list){
  130 + mAdapter = new ComentarioAdapter(list);
  131 + // mAdapter.setRecyclerViewOnClickListenerHack(this);
  132 + mRecyclerView.setAdapter(mAdapter);
  133 + pb.setVisibility(View.INVISIBLE);
  134 + }
  135 +
  136 +
  137 + private void enviarMensagem(final View v) {
  138 + final EditText txtMensagem = (EditText)findViewById(R.id.mensagem);
  139 + String mensagem = txtMensagem.getText().toString();
  140 + ParseUser user = ParseUser.getCurrentUser();
  141 + if(user!= null){
  142 + ParseObject comentario = new ParseObject("Comentario");
  143 + comentario.put("mensagem",mensagem);
  144 + comentario.put("user",user);
  145 + comentario.put("nome",user.getString("nome"));
  146 + comentario.put("projeto",projeto);
  147 + comentario.saveInBackground(new SaveCallback() {
  148 + @Override
  149 + public void done(ParseException e) {
  150 + Snackbar.make(v, "Comentário enviado", Snackbar.LENGTH_LONG)
  151 + .setAction("Action", null).show();
  152 +
  153 + //recarregar lista
  154 + buscaComentarios();
  155 + }
  156 + });
  157 + projeto.increment("nr_comentarios");
  158 + projeto.saveInBackground();
  159 +
  160 + }else{
  161 + Snackbar.make(v, "Para comentar é necessário estar logado", Snackbar.LENGTH_LONG)
  162 + .setAction("Action", null).show();
  163 + return;
  164 + }
  165 +
  166 + txtMensagem.setText("");
16 } 167 }
17 168
18 @Override 169 @Override
app/src/main/java/com/monitorabrasil/monitoralegislativo/MainActivity.java
@@ -67,8 +67,6 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr @@ -67,8 +67,6 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr
67 67
68 68
69 69
70 -  
71 -  
72 @Override 70 @Override
73 protected void onCreate(Bundle savedInstanceState) { 71 protected void onCreate(Bundle savedInstanceState) {
74 super.onCreate(savedInstanceState); 72 super.onCreate(savedInstanceState);
@@ -95,11 +93,12 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr @@ -95,11 +93,12 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr
95 93
96 // TOOLBAR 94 // TOOLBAR
97 mToolbar = (Toolbar) findViewById(R.id.tb_main); 95 mToolbar = (Toolbar) findViewById(R.id.tb_main);
98 - mToolbar.setTitle("Monitora, Ouro Branco!");  
99 - //mToolbar.setSubtitle("just a subtitle"); 96 + mToolbar.setTitle(getString(R.string.app_name));
  97 + mToolbar.setSubtitle("Ouro Branco - MG");
100 //mToolbar.setLogo(R.drawable.ic_launcher); 98 //mToolbar.setLogo(R.drawable.ic_launcher);
101 setSupportActionBar(mToolbar); 99 setSupportActionBar(mToolbar);
102 - mToolbar.setTitleTextColor(getResources().getColor(R.color.md_white_1000)); 100 + mToolbar.setTitleTextColor(getResources().getColor(R.color.md_white_1000));
  101 + mToolbar.setSubtitleTextColor(getResources().getColor(R.color.md_white_1000));
103 102
104 /*getSupportActionBar().setDisplayHomeAsUpEnabled(true); 103 /*getSupportActionBar().setDisplayHomeAsUpEnabled(true);
105 getSupportActionBar().setHomeButtonEnabled(false);*/ 104 getSupportActionBar().setHomeButtonEnabled(false);*/
@@ -173,7 +172,7 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr @@ -173,7 +172,7 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr
173 172
174 } else { 173 } else {
175 headerNavigationLeft.addProfiles( 174 headerNavigationLeft.addProfiles(
176 - new ProfileDrawerItem().withName("Faça seu cadastro")); 175 + new ProfileDrawerItem().withName("Faça seu cadastro"));
177 } 176 }
178 177
179 navigationDrawerLeft = new DrawerBuilder() 178 navigationDrawerLeft = new DrawerBuilder()
@@ -190,7 +189,7 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr @@ -190,7 +189,7 @@ public class MainActivity extends AppCompatActivity implements HomeFragment.OnFr
190 new DividerDrawerItem(), 189 new DividerDrawerItem(),
191 new PrimaryDrawerItem().withName("Vereadores"), 190 new PrimaryDrawerItem().withName("Vereadores"),
192 new SecondaryDrawerItem().withName("Projetos"), 191 new SecondaryDrawerItem().withName("Projetos"),
193 - new SecondaryDrawerItem().withName("Câmara") 192 + new SecondaryDrawerItem().withName("Câmara")
194 ) 193 )
195 .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 194 .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
196 @Override 195 @Override
app/src/main/java/com/monitorabrasil/monitoralegislativo/adapters/ComentarioAdapter.java 0 → 100644
@@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
  1 +package com.monitorabrasil.monitoralegislativo.adapters;
  2 +
  3 +import android.support.v7.widget.RecyclerView;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +import android.widget.TextView;
  8 +
  9 +import com.monitorabrasil.monitoralegislativo.R;
  10 +import com.monitorabrasil.monitoralegislativo.interfaces.RecyclerViewOnClickListenerHack;
  11 +import com.parse.ParseObject;
  12 +
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * Created by geral_000 on 05/07/2015.
  17 + */
  18 +public class ComentarioAdapter extends RecyclerView.Adapter<ComentarioAdapter.ViewHolder> {
  19 +
  20 + private List<ParseObject> mDataset;
  21 + private RecyclerViewOnClickListenerHack mRecyclerViewOnClickListenerHack;
  22 +
  23 + // Provide a reference to the views for each data item
  24 + // Complex data items may need more than one view per item, and
  25 + // you provide access to all the views for a data item in a view holder
  26 + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
  27 + // each data item is just a string in this case
  28 + public TextView txtUser;
  29 + public TextView txtComentario;
  30 + public ViewHolder(View v) {
  31 + super(v);
  32 + txtUser = (TextView) v.findViewById(R.id.txtUser);
  33 + txtComentario = (TextView) v.findViewById(R.id.txtComentario);
  34 +
  35 + itemView.setOnClickListener(this);
  36 + }
  37 +
  38 + @Override
  39 + public void onClick(View v) {
  40 + if(mRecyclerViewOnClickListenerHack != null){
  41 + mRecyclerViewOnClickListenerHack.onClickListener(v, getPosition());
  42 + }
  43 + }
  44 + }
  45 +
  46 + public ComentarioAdapter(List<ParseObject> myDataset) {
  47 + mDataset = myDataset;
  48 + }
  49 +
  50 + @Override
  51 + public ComentarioAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
  52 + // create a new view
  53 + View v = LayoutInflater.from(viewGroup.getContext())
  54 + .inflate(R.layout.item_comentario, viewGroup, false);
  55 + // set the view's size, margins, paddings and layout parameter
  56 + ViewHolder vh = new ViewHolder(v);
  57 + return vh;
  58 + }
  59 + public void setRecyclerViewOnClickListenerHack(RecyclerViewOnClickListenerHack r){
  60 + mRecyclerViewOnClickListenerHack = r;
  61 + }
  62 +
  63 + @Override
  64 + public void onBindViewHolder(ComentarioAdapter.ViewHolder viewHolder, int i) {
  65 + ParseObject comentario = mDataset.get(i);
  66 + // vereador.pinInBackground();
  67 + viewHolder.txtUser.setText(comentario.get("nome").toString());
  68 + viewHolder.txtComentario.setText(comentario.get("mensagem").toString());
  69 + }
  70 +
  71 + @Override
  72 + public int getItemCount() {
  73 + return mDataset.size();
  74 + }
  75 +}
app/src/main/java/com/monitorabrasil/monitoralegislativo/adapters/ProjetoAdapter.java
@@ -2,8 +2,13 @@ package com.monitorabrasil.monitoralegislativo.adapters; @@ -2,8 +2,13 @@ package com.monitorabrasil.monitoralegislativo.adapters;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.graphics.drawable.Drawable; 4 import android.graphics.drawable.Drawable;
  5 +import android.os.Build;
  6 +import android.os.Bundle;
5 import android.support.design.widget.Snackbar; 7 import android.support.design.widget.Snackbar;
  8 +import android.support.v4.app.ActivityOptionsCompat;
  9 +import android.support.v4.app.FragmentActivity;
6 import android.support.v4.content.ContextCompat; 10 import android.support.v4.content.ContextCompat;
  11 +import android.support.v4.util.Pair;
7 import android.support.v7.widget.RecyclerView; 12 import android.support.v7.widget.RecyclerView;
8 import android.view.LayoutInflater; 13 import android.view.LayoutInflater;
9 import android.view.View; 14 import android.view.View;
@@ -11,6 +16,7 @@ import android.view.ViewGroup; @@ -11,6 +16,7 @@ import android.view.ViewGroup;
11 import android.widget.Button; 16 import android.widget.Button;
12 import android.widget.TextView; 17 import android.widget.TextView;
13 18
  19 +import com.google.gson.Gson;
14 import com.monitorabrasil.monitoralegislativo.ComentarioActivity; 20 import com.monitorabrasil.monitoralegislativo.ComentarioActivity;
15 import com.monitorabrasil.monitoralegislativo.R; 21 import com.monitorabrasil.monitoralegislativo.R;
16 import com.monitorabrasil.monitoralegislativo.application.MyApp; 22 import com.monitorabrasil.monitoralegislativo.application.MyApp;
@@ -32,6 +38,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold @@ -32,6 +38,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
32 38
33 private List<ParseObject> mDataset; 39 private List<ParseObject> mDataset;
34 private RecyclerViewOnClickListenerHack mRecyclerViewOnClickListenerHack; 40 private RecyclerViewOnClickListenerHack mRecyclerViewOnClickListenerHack;
  41 + private FragmentActivity mActivity;
35 42
36 // Provide a reference to the views for each data item 43 // Provide a reference to the views for each data item
37 // Complex data items may need more than one view per item, and 44 // Complex data items may need more than one view per item, and
@@ -49,6 +56,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold @@ -49,6 +56,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
49 public Button btnDiscordo; 56 public Button btnDiscordo;
50 public Button btnComentar; 57 public Button btnComentar;
51 public String voto; 58 public String voto;
  59 + public ParseObject projeto;
52 60
53 public ViewHolder(View v) { 61 public ViewHolder(View v) {
54 super(v); 62 super(v);
@@ -73,8 +81,9 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold @@ -73,8 +81,9 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
73 } 81 }
74 } 82 }
75 83
76 - public ProjetoAdapter(List<ParseObject> myDataset) { 84 + public ProjetoAdapter(List<ParseObject> myDataset, FragmentActivity activity) {
77 mDataset = myDataset; 85 mDataset = myDataset;
  86 + mActivity = activity;
78 } 87 }
79 88
80 @Override 89 @Override
@@ -101,6 +110,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold @@ -101,6 +110,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
101 viewHolder.btnConcordo.setEnabled(true); 110 viewHolder.btnConcordo.setEnabled(true);
102 viewHolder.voto = "sem_voto"; 111 viewHolder.voto = "sem_voto";
103 final ParseObject projeto = mDataset.get(i); 112 final ParseObject projeto = mDataset.get(i);
  113 + viewHolder.projeto = projeto;
104 //verifica se ja votou 114 //verifica se ja votou
105 ParseQuery<ParseObject> query = ParseQuery.getQuery("Voto"); 115 ParseQuery<ParseObject> query = ParseQuery.getQuery("Voto");
106 query.fromLocalDatastore(); 116 query.fromLocalDatastore();
@@ -112,7 +122,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold @@ -112,7 +122,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
112 String voto = list.get(0).get("voto").toString(); 122 String voto = list.get(0).get("voto").toString();
113 viewHolder.projetoVotado = list.get(0); 123 viewHolder.projetoVotado = list.get(0);
114 if (voto.equals("s")) { 124 if (voto.equals("s")) {
115 - viewHolder.btnConcordo .setBackground(apoioVerde); 125 + viewHolder.btnConcordo.setBackground(apoioVerde);
116 viewHolder.btnConcordo.setEnabled(false); 126 viewHolder.btnConcordo.setEnabled(false);
117 viewHolder.voto = "apoioado"; 127 viewHolder.voto = "apoioado";
118 ; 128 ;
@@ -129,6 +139,11 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold @@ -129,6 +139,11 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
129 viewHolder.classificacao.setText(projeto.get("classificacao").toString()); 139 viewHolder.classificacao.setText(projeto.get("classificacao").toString());
130 viewHolder.data.setText(projeto.get("data").toString()); 140 viewHolder.data.setText(projeto.get("data").toString());
131 viewHolder.descricao.setText(projeto.get("descricao").toString()); 141 viewHolder.descricao.setText(projeto.get("descricao").toString());
  142 + int numComentario = 0;
  143 + if(projeto.get("nr_comentarios") != null){
  144 + numComentario = Integer.valueOf( projeto.get("nr_comentarios").toString());
  145 + }
  146 + viewHolder.btnComentar.setText(String.valueOf(numComentario));
132 int num=0; 147 int num=0;
133 if(projeto.get("apoio") != null){ 148 if(projeto.get("apoio") != null){
134 num = Integer.valueOf( projeto.get("apoio").toString()); 149 num = Integer.valueOf( projeto.get("apoio").toString());
@@ -167,8 +182,21 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold @@ -167,8 +182,21 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
167 @Override 182 @Override
168 public void onClick(View v) { 183 public void onClick(View v) {
169 Intent mIntent =new Intent(MyApp.getInstance().getApplicationContext(), ComentarioActivity.class); 184 Intent mIntent =new Intent(MyApp.getInstance().getApplicationContext(), ComentarioActivity.class);
  185 + Gson gson = new Gson();
  186 + mIntent.putExtra("projeto",viewHolder.projeto.getObjectId());
  187 +
170 mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 188 mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
171 - MyApp.getInstance().startActivity(mIntent); 189 + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
  190 + View titulo = viewHolder.descricao;
  191 + ActivityOptionsCompat options = ActivityOptionsCompat.
  192 + makeSceneTransitionAnimation(mActivity,
  193 + Pair.create(titulo, "element1"));
  194 + mActivity.startActivity(mIntent, options.toBundle());
  195 + }else{
  196 + MyApp.getInstance().startActivity(mIntent);
  197 + }
  198 +
  199 +
172 } 200 }
173 }); 201 });
174 } 202 }
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/ListaProjetosFragment.java
@@ -80,7 +80,7 @@ public class ListaProjetosFragment extends Fragment implements RecyclerViewOnCli @@ -80,7 +80,7 @@ public class ListaProjetosFragment extends Fragment implements RecyclerViewOnCli
80 }); 80 });
81 } 81 }
82 public void carregaList(List<ParseObject> list){ 82 public void carregaList(List<ParseObject> list){
83 - mAdapter = new ProjetoAdapter(list); 83 + mAdapter = new ProjetoAdapter(list,getActivity());
84 mAdapter.setRecyclerViewOnClickListenerHack(this); 84 mAdapter.setRecyclerViewOnClickListenerHack(this);
85 mRecyclerView.setAdapter(mAdapter); 85 mRecyclerView.setAdapter(mAdapter);
86 pb.setVisibility(View.INVISIBLE); 86 pb.setVisibility(View.INVISIBLE);
@@ -92,17 +92,17 @@ public class ListaProjetosFragment extends Fragment implements RecyclerViewOnCli @@ -92,17 +92,17 @@ public class ListaProjetosFragment extends Fragment implements RecyclerViewOnCli
92 92
93 PoliticoFragment frag = new PoliticoFragment(); 93 PoliticoFragment frag = new PoliticoFragment();
94 Bundle bundle = new Bundle(); 94 Bundle bundle = new Bundle();
95 - try {  
96 - ob.get(position).pin();  
97 - } catch (ParseException e) {  
98 - e.printStackTrace();  
99 - }  
100 - bundle.putString("politico", ob.get(position).getObjectId());  
101 - frag.setArguments(bundle);  
102 - FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();  
103 - ft.replace(R.id.rl_fragment_container, frag, "politicoFrag");  
104 - ft.addToBackStack(null);  
105 - ft.commit(); 95 +// try {
  96 +// ob.get(position).pin();
  97 +// } catch (ParseException e) {
  98 +// e.printStackTrace();
  99 +// }
  100 +// bundle.putString("politico", ob.get(position).getObjectId());
  101 +// frag.setArguments(bundle);
  102 +// FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
  103 +// ft.replace(R.id.rl_fragment_container, frag, "politicoFrag");
  104 +// ft.addToBackStack(null);
  105 +// ft.commit();
106 } 106 }
107 107
108 } 108 }
app/src/main/res/drawable-hdpi/ic_action_send.png 0 → 100644

359 Bytes

app/src/main/res/drawable-mdpi/ic_action_send.png 0 → 100644

227 Bytes

app/src/main/res/drawable-xhdpi/ic_action_send.png 0 → 100644

351 Bytes

app/src/main/res/drawable-xxhdpi/ic_action_send.png 0 → 100644

638 Bytes

app/src/main/res/layout/activity_comentario.xml
1 -<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"  
2 - xmlns:app="http://schemas.android.com/apk/res-auto"  
3 - xmlns:tools="http://schemas.android.com/tools"  
4 - android:id="@+id/drawerLayout"  
5 - android:layout_width="match_parent"  
6 - android:layout_height="match_parent"  
7 - tools:context="com.monitorabrasil.monitoralegislativo.ComentarioActivity">  
8 -  
9 - <android.support.design.widget.CoordinatorLayout  
10 - android:id="@+id/rootLayout" 1 + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:app="http://schemas.android.com/apk/res-auto"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:id="@+id/drawerLayout"
11 android:layout_width="match_parent" 5 android:layout_width="match_parent"
12 - android:layout_height="match_parent">  
13 -  
14 - <android.support.design.widget.AppBarLayout  
15 - android:layout_width="match_parent"  
16 - android:layout_height="@dimen/app_bar_height"  
17 - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">  
18 -  
19 - <android.support.design.widget.CollapsingToolbarLayout  
20 - android:id="@+id/collapsingToolbarLayout"  
21 - android:layout_width="match_parent"  
22 - android:layout_height="match_parent"  
23 - app:contentScrim="?attr/colorPrimary"  
24 - app:expandedTitleMarginStart="@dimen/expanded_toolbar_title_margin_start"  
25 - app:layout_scrollFlags="scroll|exitUntilCollapsed">  
26 -  
27 - <ImageView  
28 - android:layout_width="match_parent"  
29 - android:layout_height="match_parent"  
30 - android:scaleType="centerCrop"  
31 - android:src="@drawable/pattern1"  
32 - app:layout_collapseMode="parallax"  
33 - app:layout_collapseParallaxMultiplier="0.7" />  
34 - <TextView  
35 - android:layout_width="wrap_content"  
36 - android:layout_height="wrap_content"  
37 - android:textAppearance="?android:attr/textAppearanceMedium"  
38 - android:text="Projeto"  
39 - android:id="@+id/projeto" />  
40 -  
41 -  
42 - <android.support.v7.widget.Toolbar  
43 - android:id="@+id/toolbar"  
44 - android:layout_width="match_parent"  
45 - android:layout_height="?attr/actionBarSize"  
46 - app:layout_collapseMode="pin"  
47 - app:popupTheme="@style/ThemeOverlay.AppCompat.Light"  
48 - app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />  
49 -  
50 - </android.support.design.widget.CollapsingToolbarLayout> 6 + android:layout_height="match_parent"
  7 + android:orientation="vertical"
  8 + tools:context="com.monitorabrasil.monitoralegislativo.ComentarioActivity">
51 9
52 - </android.support.design.widget.AppBarLayout>  
53 -  
54 - <android.support.v4.widget.NestedScrollView 10 + <android.support.v7.widget.Toolbar
  11 + android:id="@+id/tb_main"
  12 + android:layout_height="?attr/actionBarSize"
55 android:layout_width="match_parent" 13 android:layout_width="match_parent"
56 - android:layout_height="match_parent"  
57 - app:layout_behavior="@string/appbar_scrolling_view_behavior">  
58 -  
59 - <LinearLayout  
60 - android:layout_width="match_parent"  
61 - android:layout_height="match_parent"  
62 - android:orientation="vertical">  
63 -  
64 -  
65 - <include layout="@layout/fragment_politico_detalhe"/>  
66 - <RelativeLayout  
67 - android:id="@+id/rl_fragment_container"  
68 - android:layout_width="match_parent"  
69 - android:layout_height="400dp"> 14 + android:minHeight="?attr/actionBarSize"
  15 + android:background="?attr/colorPrimary"
  16 + app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
  17 +
  18 + <RelativeLayout
  19 + android:id="@+id/rl_fragment_container"
  20 + android:layout_width="match_parent"
  21 + android:layout_height="match_parent">
  22 +
  23 + <android.support.v7.widget.RecyclerView
  24 + android:id="@+id/my_recycler_view"
  25 + android:scrollbars="vertical"
  26 + android:layout_width="match_parent"
  27 + android:layout_height="match_parent"
  28 + android:layout_above="@+id/mensagem"/>
  29 +
  30 + <ProgressBar
  31 + android:layout_width="wrap_content"
  32 + android:layout_height="wrap_content"
  33 + android:id="@+id/progressBar"
  34 + android:layout_gravity="center"
  35 + android:layout_centerHorizontal="true"
  36 + android:layout_centerVertical="true"
  37 + android:indeterminate="false" />
  38 +
  39 +
  40 + <Button
  41 + style="?android:attr/buttonStyleSmall"
  42 + android:layout_width="wrap_content"
  43 + android:layout_height="wrap_content"
  44 + android:id="@+id/btnEnviar"
  45 + android:layout_alignParentBottom="true"
  46 + android:layout_alignParentRight="true"
  47 + android:layout_alignParentEnd="true"
  48 + android:background="@drawable/ic_action_send" />
  49 +
  50 + <EditText
  51 + android:layout_width="match_parent"
  52 + android:layout_height="wrap_content"
  53 + android:hint="Envie seu comentário"
  54 + android:id="@+id/mensagem"
  55 + android:textColorHint="@color/hint_text"
  56 + android:textColorLink="@color/hint_text"
  57 + android:textColor="@color/colorPrimarytext"
  58 + android:layout_alignParentBottom="true"
  59 + android:layout_alignParentLeft="true"
  60 + android:layout_alignParentStart="true"
  61 + android:layout_toLeftOf="@+id/btnEnviar"
  62 + android:layout_toStartOf="@+id/btnEnviar" />
  63 +
  64 +
  65 + </RelativeLayout>
70 66
71 - </RelativeLayout>  
72 -  
73 - </LinearLayout>  
74 -  
75 - </android.support.v4.widget.NestedScrollView>  
76 67
77 <android.support.design.widget.FloatingActionButton 68 <android.support.design.widget.FloatingActionButton
78 - android:id="@+id/fabBtn"  
79 - android:layout_width="wrap_content"  
80 - android:layout_height="wrap_content"  
81 - android:layout_gravity="bottom|right"  
82 - android:layout_marginBottom="@dimen/fab_margin_bottom"  
83 - android:layout_marginRight="@dimen/fab_margin_right"  
84 - android:src="@drawable/ic_done"  
85 - app:borderWidth="0dp"  
86 - app:fabSize="normal" />  
87 -  
88 - </android.support.design.widget.CoordinatorLayout>  
89 -  
90 -</android.support.v4.widget.DrawerLayout>  
91 \ No newline at end of file 69 \ No newline at end of file
  70 + android:id="@+id/fabBtn"
  71 + android:layout_width="wrap_content"
  72 + android:layout_height="wrap_content"
  73 + android:layout_gravity="bottom|right"
  74 + android:layout_marginBottom="@dimen/fab_margin_bottom"
  75 + android:layout_marginRight="@dimen/fab_margin_right"
  76 + android:src="@drawable/ic_done"
  77 + app:borderWidth="0dp"
  78 + app:fabSize="normal" />
  79 +
  80 + </LinearLayout>
92 \ No newline at end of file 81 \ No newline at end of file
app/src/main/res/layout/item_comentario.xml 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  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:paddingTop="3dp"
  6 + android:paddingBottom="3dp">
  7 +
  8 + <TextView
  9 + android:layout_width="wrap_content"
  10 + android:layout_height="wrap_content"
  11 + android:text="Nome"
  12 + android:id="@+id/txtUser"
  13 + android:textSize="16dp"
  14 + android:textColor="@color/black"
  15 + android:textStyle="bold"
  16 + android:layout_marginLeft="@dimen/activity_horizontal_margin"
  17 + android:layout_marginTop="3dp" />
  18 +
  19 + <TextView
  20 + android:layout_width="wrap_content"
  21 + android:layout_height="wrap_content"
  22 + android:textSize="15dp"
  23 + android:text="Partido"
  24 + android:id="@+id/txtComentario"
  25 + android:layout_marginLeft="20dp"
  26 + android:textColor="@color/colorPrimarytext" />
  27 +</LinearLayout>
0 \ No newline at end of file 28 \ No newline at end of file
app/src/main/res/values/strings.xml
1 <resources> 1 <resources>
2 - <string name="app_name">MonitoraMunicipio</string> 2 + <string name="app_name">Participa Cidadão</string>
3 3
4 <string name="hello_world">Hello world!</string> 4 <string name="hello_world">Hello world!</string>
5 <string name="action_settings">Settings</string> 5 <string name="action_settings">Settings</string>