-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '515b7600a33f2ced5a15452e8b11af61e8fcfdc9'
- Loading branch information
Showing
21 changed files
with
452 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/mdsgpp/cidadedemocratica/controller/FeedbackManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.mdsgpp.cidadedemocratica.controller; | ||
|
||
import android.app.ProgressDialog; | ||
import android.content.Context; | ||
import android.widget.Toast; | ||
|
||
/** | ||
* Created by luisresende on 18/10/16. | ||
*/ | ||
|
||
public class FeedbackManager { | ||
|
||
static public void createToast(Context context, String message){ | ||
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT); | ||
toast.show(); | ||
} | ||
|
||
static public ProgressDialog createProgressDialog (Context context, String message){ | ||
ProgressDialog dialog = new ProgressDialog(context); | ||
dialog.setMessage(message); | ||
dialog.show(); | ||
return dialog; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 59 additions & 11 deletions
70
app/src/main/java/com/mdsgpp/cidadedemocratica/controller/ProposalsList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,100 @@ | ||
package com.mdsgpp.cidadedemocratica.controller; | ||
|
||
import android.app.ProgressDialog; | ||
import android.net.Uri; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.widget.ListView; | ||
|
||
import com.mdsgpp.cidadedemocratica.External.SlidingTabLayout; | ||
import com.mdsgpp.cidadedemocratica.R; | ||
|
||
import com.mdsgpp.cidadedemocratica.persistence.DataContainer; | ||
import com.mdsgpp.cidadedemocratica.requester.ProposalRequestResponseHandler; | ||
import com.mdsgpp.cidadedemocratica.requester.RequestUpdateListener; | ||
import com.mdsgpp.cidadedemocratica.requester.Requester; | ||
import com.mdsgpp.cidadedemocratica.view.ListProposalFragment; | ||
|
||
|
||
public class ProposalsList extends AppCompatActivity implements ListProposalFragment.OnFragmentInteractionListener{ | ||
|
||
private int numberTabs = 3; | ||
public class ProposalsList extends AppCompatActivity implements ListProposalFragment.OnFragmentInteractionListener, RequestUpdateListener { | ||
|
||
private int numberOfTabs = 3; | ||
private ProgressDialog progressDialog; | ||
private ViewPagerAdapter adapter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_proposals_list); | ||
if (DataContainer.getInstance().getUsers().size() == 0) { | ||
pullProposalsData(); | ||
} else { | ||
loadProposalsList(); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public void onFragmentInteraction(Uri uri) { | ||
|
||
} | ||
|
||
public void pullProposalsData() { | ||
if (progressDialog == null) { | ||
progressDialog = FeedbackManager.createProgressDialog(this, getString(R.string.message_load_proposals)); | ||
} | ||
ProposalRequestResponseHandler proposalRequestResponseHandler = new ProposalRequestResponseHandler(); | ||
setDataUpdateListener(proposalRequestResponseHandler); | ||
|
||
Requester requester = new Requester(ProposalRequestResponseHandler.proposalsEndpointUrl, proposalRequestResponseHandler); | ||
requester.setParameter("page", String.valueOf(ProposalRequestResponseHandler.nextPageToRequest)); | ||
requester.request(Requester.RequestType.GET); | ||
} | ||
|
||
CharSequence titles[] = {getString(R.string.titulo_tab_tudo),getString(R.string.titulo_tab_porAqui), | ||
getString(R.string.titulo_tab_localidade)}; | ||
private void loadProposalsList() { | ||
|
||
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(),titles,numberTabs); | ||
CharSequence titles[] = {getString(R.string.titulo_tab_tudo), getString(R.string.titulo_tab_porAqui), | ||
getString(R.string.titulo_tab_localidade)}; | ||
|
||
ViewPager pager = (ViewPager)findViewById(R.id.pager); | ||
if (adapter == null) { | ||
adapter = new ViewPagerAdapter(getSupportFragmentManager(), titles, numberOfTabs); | ||
} | ||
|
||
ViewPager pager = (ViewPager) findViewById(R.id.pager); | ||
pager.setAdapter(adapter); | ||
|
||
SlidingTabLayout tabs = (SlidingTabLayout) findViewById(R.id.tabs); | ||
tabs.setDistributeEvenly(true); | ||
|
||
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer(){ | ||
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { | ||
@Override | ||
public int getIndicatorColor(int position){ | ||
public int getIndicatorColor(int position) { | ||
return getResources().getColor(R.color.colorAccent); | ||
} | ||
}); | ||
|
||
tabs.setViewPager(pager); | ||
} | ||
|
||
public void setDataUpdateListener(ProposalRequestResponseHandler handler) { | ||
handler.setRequestUpdateListener(this); | ||
} | ||
|
||
public void afterSuccess() { | ||
progressDialog.dismiss(); | ||
loadProposalsList(); | ||
createToast(getString(R.string.message_success_load_proposals)); | ||
ProposalRequestResponseHandler.nextPageToRequest++; | ||
} | ||
|
||
@Override | ||
public void onFragmentInteraction(Uri uri) { | ||
|
||
|
||
private void createToast(String message) { | ||
FeedbackManager.createToast(this, message); | ||
} | ||
|
||
public void afterError(String message) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.