Advertisement
MarouaneTheViper

Untitled

Sep 7th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. public class MainActivity extends AppCompatActivity {
  2.  
  3. private ActionBar actionbar;
  4. private Tab tabOne;
  5. private Tab tabTwo;
  6. private Fragment register = new RegisterFragment();
  7. private Fragment browse = new BrowseFragment();
  8. private Button saveButton, randButton;
  9. private EditText editTitle,editUser,editPass;
  10. private RadioGroup radioGroup;
  11. private RadioButton radioButton;
  12.  
  13.  
  14. private void link()
  15. {
  16. saveButton = findViewById(R.id.buttonSave);
  17. randButton = findViewById(R.id.buttonRand);
  18. editTitle = findViewById(R.id.acc_title);
  19. editUser = findViewById(R.id.acc_username);
  20. editPass = findViewById(R.id.password);
  21. radioGroup = findViewById(R.id.rGroup);
  22. }
  23.  
  24. @Override
  25. protected void onCreate(Bundle savedInstanceState) {
  26. super.onCreate(savedInstanceState);
  27. setContentView(R.layout.activity_main);
  28. link();
  29.  
  30. actionbar = getSupportActionBar();
  31. actionbar.show();
  32. actionbar.setNavigationMode(NAVIGATION_MODE_TABS);
  33.  
  34. tabOne = actionbar.newTab().setText(R.string.new_account);
  35. tabTwo = actionbar.newTab().setText(R.string.browse);
  36.  
  37. tabOne.setTabListener(new TabAction(register));
  38. tabTwo.setTabListener(new TabAction(browse));
  39.  
  40. actionbar.addTab(tabOne);
  41. actionbar.addTab(tabTwo);
  42.  
  43. saveButtonHandler();
  44. randomButtonHandler();
  45.  
  46. }
  47.  
  48. private void saveButtonHandler()
  49. {
  50.  
  51. }
  52.  
  53. private void randomButtonHandler()
  54. {
  55.  
  56. }
  57.  
  58. private String randomPassword()
  59. {
  60. Character[] characters = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
  61. 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
  62. '!','@','#','$','%','^','&','*','(',')','_','+','1','2','3','4','5','6','7','8','9','0'};
  63.  
  64. List<Character> characterList = new ArrayList<>(Arrays.asList(characters));
  65. Collections.shuffle(characterList);
  66. Random rand = new Random();
  67. String result ="";
  68. for(int i = 0;i<9;i++)
  69. {
  70. int count = rand.nextInt(characterList.size());
  71. result = result + characterList.get(count).toString();
  72. }
  73.  
  74. return result;
  75. }
  76.  
  77. class TabAction implements ActionBar.TabListener {
  78.  
  79. Fragment f;
  80.  
  81. public TabAction(Fragment f) {
  82. this.f = f;
  83. }
  84.  
  85. @Override
  86. public void onTabSelected(Tab tab, FragmentTransaction ft) {
  87. ft.replace(R.id.frame, f);
  88. }
  89.  
  90. @Override
  91. public void onTabUnselected(Tab tab, FragmentTransaction ft) {
  92. ft.remove(f);
  93. }
  94.  
  95. @Override
  96. public void onTabReselected(Tab tab, FragmentTransaction ft) {
  97.  
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement