Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.38 KB | None | 0 0
  1. Button btnLogin;
  2. Button btnRegister;
  3. Button btnsignUp;
  4. ViewFlipper viewFlipper;
  5. EditText etUserName;
  6. EditText etPassword;
  7.  
  8. EditText etUserNameSignUp;
  9. EditText etPasswordSignUp;
  10. EditText etPhoneSignUp;
  11.  
  12. Button btnExit;
  13. Button btnHome;
  14. Button btnNotifications;
  15. Button btnAvalability;
  16. Button btnUpdate;
  17.  
  18. Button btnPublish;
  19. Button btnStatus;
  20. Button btnNotify;
  21.  
  22. String[] companies = new String[] { "Infosys", "Wipro", "Cisco", "ibm",
  23. "tcs", "NWS" };
  24.  
  25. int[] images = new int[] { R.drawable.notifications,
  26. R.drawable.notifications, R.drawable.notifications,
  27. R.drawable.notifications, R.drawable.notifications,
  28. R.drawable.notifications,
  29.  
  30. };
  31.  
  32. String[] dates = new String[] { "21/08/12", "22/08/12", "20/08/12",
  33. "16/08/12", "18/08/12", "24/08/12", };
  34.  
  35. String[] type = new String[] { "Face To Face", "Written", "Online",
  36. "telephonc", "group discussion", "telephonic" };
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. @Override
  44. public void onCreate(Bundle savedInstanceState) {
  45. super.onCreate(savedInstanceState);
  46. requestWindowFeature(Window.FEATURE_NO_TITLE);
  47. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  48. WindowManager.LayoutParams.FLAG_FULLSCREEN);
  49. setContentView(R.layout.home);
  50. userName.add("Raghu");
  51. password.add("Raghu");
  52.  
  53. viewFlipper = (ViewFlipper) findViewById(R.id.main);
  54. btnLogin = (Button) findViewById(R.id.loginButton);
  55. btnLogin.setOnClickListener(this);
  56. btnRegister = (Button) findViewById(R.id.signupButton);
  57. btnRegister.setOnClickListener(this);
  58.  
  59. btnsignUp = (Button) findViewById(R.id.signupButton);
  60. btnsignUp.setOnClickListener(this);
  61. etUserName = (EditText) findViewById(R.id.userEditText);
  62. etPassword = (EditText) findViewById(R.id.pwEditText);
  63.  
  64. etUserNameSignUp = (EditText) findViewById(R.id.regNameEditText);
  65. etPasswordSignUp = (EditText) findViewById(R.id.regEmailEditText);
  66. etPhoneSignUp = (EditText) findViewById(R.id.regPhEditText);
  67.  
  68. btnHome = (Button) findViewById(R.id.homeButton);
  69. btnHome.setOnClickListener(this);
  70.  
  71. btnExit = (Button) findViewById(R.id.exitButton);
  72. btnExit.setOnClickListener(this);
  73.  
  74. btnNotifications = (Button) findViewById(R.id.listButton);
  75. btnNotifications.setOnClickListener(this);
  76.  
  77. btnAvalability = (Button) findViewById(R.id.rightButton);
  78. btnAvalability.setOnClickListener(this);
  79.  
  80. btnUpdate = (Button) findViewById(R.id.plusButton);
  81. btnUpdate.setOnClickListener(this);
  82.  
  83. btnPublish = (Button) findViewById(R.id.publishButton);
  84. btnPublish.setOnClickListener(this);
  85.  
  86. btnStatus = (Button) findViewById(R.id.updateButton);
  87. btnStatus.setOnClickListener(this);
  88.  
  89. btnNotify = (Button) findViewById(R.id.notificationButton);
  90. btnNotify.setOnClickListener(this);
  91.  
  92. // Each row in the list stores company name, interview date,
  93. // notification icon and type of interview
  94. List<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
  95.  
  96. for (int i = 0; i < 6; i++) {
  97. HashMap<String, String> hm = new HashMap<String, String>();
  98. hm.put("cmp", companies[i]);
  99. hm.put("date", " " + dates[i]);
  100. hm.put("img", Integer.toString(images[i]));
  101. hm.put("type", " " + type[i]);
  102. aList.add(hm);
  103. }
  104.  
  105. // Keys used in Hashmap
  106. String[] from = { "cmp", "date", "img", "type" };
  107.  
  108. // Ids of views in lvrow.xml
  109. int[] to = { R.id.cmp, R.id.date, R.id.imgv, R.id.type };
  110.  
  111. // Instantiating an adapter to store each items
  112. // R.layout.lvrow.xml defines the layout of each item
  113. SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), aList,
  114. R.layout.listview, from, to);
  115.  
  116. // Getting a reference to listview of listvi.xml layout file
  117. ListView listView = (ListView) findViewById(R.id.listview);
  118.  
  119. // Setting the adapter to the listView
  120. listView.setAdapter(adapter);
  121. /*listView.setOnItemClickListener(listener);*/
  122.  
  123. }
  124.  
  125. OnItemClickListener listener = new OnItemClickListener() {
  126.  
  127. // @Override
  128. // onItemClick(AdapterView<?> parent, View view, int position, long id)
  129. // {
  130. // ((TextView) view.findViewById(R.id.yourTextViewId)).getText();
  131. // // or do your stuff
  132. // }
  133.  
  134. public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
  135. long arg3) {
  136. ImageView viewObj = (ImageView) arg1.findViewById(R.id.imgv);
  137. viewObj.setImageResource(R.drawable.bgrighticon);
  138.  
  139. }
  140. };
  141.  
  142.  
  143. private void readContent(String uriString) {
  144.  
  145. Uri calendarUri;
  146. Uri eventUri;
  147. if (android.os.Build.VERSION.SDK_INT <= 7 )
  148. {
  149. //the old way
  150. calendarUri = Uri.parse("content://calendar/calendars");
  151. eventUri = Uri.parse("content://calendar/events");
  152. }
  153. else
  154. {
  155. //the new way
  156. calendarUri = Uri.parse("content://com.android.calendar/calendars");
  157. eventUri = Uri.parse("content://com.android.calendar/events");
  158. }
  159.  
  160. }
  161.  
  162. private void addEvent(){
  163. try {
  164. ContentValues event = new ContentValues();
  165. event.put("calendar_id", "1");
  166. event.put("title", "tet event");
  167. event.put("description", "hello this is testing of event");
  168. event.put("eventLocation", "Ahmedabad");
  169. Calendar c = Calendar.getInstance();
  170. long date = c.getTimeInMillis();
  171. event.put("dtstart", date);
  172. event.put("dtend", date);
  173. event.put("allDay", 1);
  174. event.put("eventStatus", 1);
  175. event.put("hasAlarm", 1);
  176. Uri eventsUri = Uri.parse("content://calendar/events");
  177. Uri url = getContentResolver().insert(eventsUri, event);
  178. Log.e("uri", url.toString());
  179. } catch (Exception e) {
  180. Log.e("error", e.getMessage());
  181. e.printStackTrace();
  182. }
  183. }
  184.  
  185. @Override
  186. public boolean onCreateOptionsMenu(Menu menu) {
  187. getMenuInflater().inflate(R.menu.home, menu);
  188. return true;
  189. }
  190.  
  191. public void onClick(View v) {
  192. if (v == btnLogin) {
  193. if (userName.contains(etUserName.getText().toString())
  194. && password.contains(etPassword.getText().toString()))
  195.  
  196. {
  197. viewFlipper.setDisplayedChild(3);
  198.  
  199. } else {
  200.  
  201. }
  202.  
  203. loggedin = true;
  204.  
  205. } else if (v == btnRegister) {
  206. viewFlipper.setDisplayedChild(5);
  207. } else if (v == btnsignUp) {// reister new user
  208. // Take the values from the user entered data and save it in
  209. // Arraylist
  210.  
  211. } else if (v == btnHome) {
  212. if (loggedin) {
  213. viewFlipper.setDisplayedChild(3);
  214. } else {
  215. viewFlipper.setDisplayedChild(0);
  216. }
  217.  
  218. } else if (v == btnExit) {
  219. System.exit(0);
  220. } else if (v == btnNotifications) {
  221. if (loggedin) {
  222. viewFlipper.setDisplayedChild(4);
  223. }
  224. } else if (v == btnAvalability) {
  225. if (loggedin) {
  226. viewFlipper.setDisplayedChild(2);
  227. }
  228. } else if (v == btnUpdate) {
  229. if (loggedin) {
  230. viewFlipper.setDisplayedChild(1);
  231. }
  232. }
  233.  
  234. else if (v == btnPublish) {
  235. if (loggedin) {
  236. viewFlipper.setDisplayedChild(2);
  237. }
  238.  
  239. } else if (v == btnStatus) {
  240. if (loggedin) {
  241. viewFlipper.setDisplayedChild(1);
  242. }
  243.  
  244. } else if (v == btnNotify) {
  245. if (loggedin) {
  246. viewFlipper.setDisplayedChild(4);
  247. }
  248.  
  249. }
  250.  
  251. }
  252.  
  253. public boolean check()
  254. {
  255. try{
  256. ApplicationInfo info = getPackageManager().getApplicationInfo("packagename", 0 );
  257. return true;
  258. } catch( PackageManager.NameNotFoundException e ){
  259. return false;
  260. }
  261. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement