Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. public class AllMovieRating extends ActionBarActivity implements View.OnClickListener {
  2.  
  3. private Views mViews;
  4. final ArrayList ilist = new ArrayList();
  5.  
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.activity_all_movie_rating);
  10.  
  11. mViews=new Views();
  12. mViews.irating.setOnClickListener(this);
  13.  
  14. } @Override
  15. public void onClick(View v) {
  16. switch (v.getId()){
  17. case R.id.imdb_rating:
  18. ilist.clear();
  19. ilist();
  20. break;
  21.  
  22. }
  23.  
  24. }
  25. private void filtervalues() {
  26. Intent intent = new Intent(AllRating.this,sharedcollect.class);
  27. intent.putExtra("im",ilist);
  28. startActivity(intent);
  29.  
  30. } public ArrayList ilist() { final String[] ratings = new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  31. final boolean[] ratingschecked = {false, false, false, false, false, false, false, false, false, false};
  32. SharedPreferences sharedPreferences = this.getSharedPreferences("checkedrate_i", Context.MODE_PRIVATE);
  33. final SharedPreferences.Editor editor = sharedPreferences.edit();
  34.  
  35. final AlertDialog.Builder builder = new AlertDialog.Builder(this);
  36.  
  37. int size = sharedPreferences.getInt("size", 0);
  38. for(int j=0;j<size;j++)
  39. {
  40. imdblist.add(sharedPreferences.getString("selectedratings" + j, null));
  41. //Log.e("Kumar", "" + selectedratings);
  42. }
  43.  
  44. for(int j=0;j<=ratingschecked.length;j++){
  45. if(imdblist.contains((String.valueOf(j)))) {
  46. ratingschecked[j-1] = true;
  47. }
  48. }
  49.  
  50. builder.setTitle("Select Ratings");
  51. builder.setMultiChoiceItems(ratings, ratingschecked, new DialogInterface.OnMultiChoiceClickListener() {
  52. @Override
  53. public void onClick(DialogInterface dialog, int which, boolean isChecked) {
  54.  
  55. if (isChecked) {
  56.  
  57. if(!imdblist.contains(ratings[which])){
  58. imdblist.add(ratings[which]);
  59.  
  60. }
  61. //Log.e("Shiva", ""+imdblist);
  62. } else if (imdblist.remove(ratings[which])) {
  63.  
  64. // Log.e("Kumar", String.valueOf(ratings[which]));
  65.  
  66.  
  67. }
  68. }
  69. }).setPositiveButton("OK", new DialogInterface.OnClickListener() {
  70. @Override
  71. public void onClick(DialogInterface dialog, int which) {
  72.  
  73. // editor.putString("checked", String.valueOf(selectedratings));
  74. for (int i = 0; i < imdblist.size(); i++) {
  75. editor.putString("selectedratings" + i, String.valueOf(imdblist.get(i)));
  76. }
  77. editor.putInt("size", imdblist.size());
  78. editor.apply();
  79. }
  80. }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  81. @Override
  82. public void onClick(DialogInterface dialog, int which) {
  83.  
  84. }
  85. });
  86.  
  87. AlertDialog dialog = builder.create();
  88. builder.show();
  89. return imdblist;
  90. }
  91.  
  92. public class sharedcollect extends ActionBarActivity {
  93.  
  94. ListView movielist;
  95.  
  96.  
  97. @Override
  98. protected void onCreate(Bundle savedInstanceState) {
  99. super.onCreate(savedInstanceState);
  100. setContentView(R.layout.activity_sharedcollect);
  101.  
  102. Intent i = getIntent();
  103. ArrayList<String> list = i.getStringArrayListExtra("im");
  104.  
  105.  
  106.  
  107.  
  108. }
  109.  
  110. @Override
  111. public boolean onCreateOptionsMenu(Menu menu) {
  112. // Inflate the menu; this adds items to the action bar if it is present.
  113. getMenuInflater().inflate(R.menu.menu_sharedcollect, menu);
  114. return true;
  115. }
  116.  
  117.  
  118. @Override
  119. public boolean onOptionsItemSelected(MenuItem item) {
  120. // Handle action bar item clicks here. The action bar will
  121. // automatically handle clicks on the Home/Up button, so long
  122. // as you specify a parent activity in AndroidManifest.xml.
  123.  
  124. switch (item.getItemId()){
  125. case R.id.action_settings:
  126. onBackPressed();
  127. return true;
  128. default:
  129. return super.onOptionsItemSelected(item);
  130. } }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement