@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(LOG_TAG, "onCreate"); Intent intent = getIntent(); imageId = intent.getIntExtra(IMAGE_ID_EXTRA, -1); Log.d(LOG_TAG, "Image ID: " + String.valueOf(imageId)); getSupportLoaderManager().restartLoader(0, null, this); setContentView(R.layout.activity_comments); mCommentsRecyclerView = (RecyclerView) findViewById(R.id.comments_recycler_view); mCommentsAdapter = new CommentsAdapter(); mCommentsAdapter.setOnItemClickListener(this); mCommentsRecyclerView.setAdapter(mCommentsAdapter); mCommentsRecyclerView.setItemAnimator(new DefaultItemAnimator()); mCommentsRecyclerView.setLayoutManager( new LinearLayoutManager(getApplication().getApplicationContext())); mSendButton = (ImageView) findViewById(R.id.send_button); mSendButton.setOnClickListener(this); mMessageTextInput = (EditText) findViewById(R.id.message_text_input); mMessageTextInput.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} @Override public void afterTextChanged(Editable s) { mSendButton.setImageDrawable( getResources() .getDrawable( s.length() >= MIN_INPUT_TEXT_LENGTH ? R.drawable.ic_arrow_forward_white_48dp : R.drawable.ic_arrow_forward_black_48dp)); } }); if (isNeedToShowAd) { mAdView = (AdView) findViewById(R.id.advertising_block); mAdView.loadAd(adRequest); } requestsIdMap.put( SendServiceHelper.getInstance(this).requestCommentList(imageId), RequestType.COMMENT_LIST); }
@Override public void onCreate(Bundle savedInstanceState) { this.hasNoGroup = this.getIntent().getExtras().getBoolean("NoGroup"); this.school = this.getIntent().getExtras().getString("School"); this.layout = R.layout.activity_group_select; super.onCreate(savedInstanceState); EpiTime.getInstance().setCurrentActivity(this); if (hasNoGroup) { this.drawerToggle.isDrawerOpened = true; this.drawerLayout.openDrawer(Gravity.LEFT); } this.groupList = (ListView) this.findViewById(R.id.group_list); this.groupList.setOnItemClickListener(new OnGroupListItemClick()); this.addHeaders(); this.reloadListView(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // inflate your activity layout here! View contentView = inflater.inflate(R.layout.folder_list_activity_main, null, false); mDrawerLayout.addView(contentView, 0); androidOpenDbHelperObj = new NoteshareDatabaseHelper(context); sqliteDatabase = androidOpenDbHelperObj.getWritableDatabase(); DataManager.sharedDataManager().setSelectedIndex(-1); initlizeUIElement(contentView); // getDeafultNote(); getallNotes(); // getAllFolder(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_options); // Initializes the button to test the connection to the server testCon = (Button) findViewById(R.id.buttonCon); testCon.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Gets the URL String urlString = ((EditText) findViewById(R.id.editTextURL)).getText().toString(); if (!(urlString.startsWith("http://") || urlString.startsWith("https://"))) { urlString = "http://" + urlString; } // Tries to connect try { URL url = new URL(urlString); HttpURLConnection urlc = (HttpURLConnection) url.openConnection(); urlc.setRequestMethod("HEAD"); urlc.setConnectTimeout(5 * 1000); urlc.setReadTimeout(5 * 1000); urlc.connect(); if (urlc.getResponseCode() == HttpURLConnection.HTTP_OK) { Log.d(TAG, "Reachable destination"); Toast.makeText(OptionsActivity.this, R.string.toast_r_dest, Toast.LENGTH_SHORT) .show(); if (!urlString.endsWith("/")) { urlString += "/"; } Log.d(TAG, "Saving URL " + urlString); SharedPreferences settings = getSharedPreferences("Settings", Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString("url", urlString); editor.apply(); } } catch (IOException e) { Log.d(TAG, "Unreachable destination"); Toast.makeText(OptionsActivity.this, R.string.toast_unr_dest, Toast.LENGTH_SHORT) .show(); } } }); // Button to change the user's nickname acceptNick = (Button) findViewById(R.id.ok_button); acceptNick.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Changes the user's nickname in the preferences String nickname = ((EditText) findViewById(R.id.editTextNick)).getText().toString(); SharedPreferences settings = getSharedPreferences("Settings", Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString("nickname", nickname); editor.apply(); Toast.makeText( OptionsActivity.this, getResources().getString(R.string.toast_new_nick) + " : " + nickname, Toast.LENGTH_SHORT) .show(); } }); // Button to change the language loadLocale = (Button) findViewById(R.id.buttonLocale); loadLocale.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Restart the activity Intent intent = OptionsActivity.this.getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); OptionsActivity.this.finish(); startActivity(intent); } }); // Spinner of languages langSelect = (Spinner) findViewById(R.id.spinnerLanguages); langSelect.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selected = parent.getSelectedItem().toString(); String lang; switch (selected) { case "Français": lang = "fr_FR"; break; case "English": default: lang = "en_US"; break; } Log.d(TAG, "SELECTED lang=" + lang); // Updates the preferences SharedPreferences settings = getSharedPreferences("Settings", Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString("locale", lang); editor.apply(); OptionsActivity.super.updateLocale(); } @Override public void onNothingSelected(AdapterView<?> parent) {} }); allowNotif = (CheckBox) findViewById(R.id.allowNotifCheck); allowNotif.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences notifSettings = getSharedPreferences("notifications", Context.MODE_PRIVATE); SharedPreferences.Editor editor = notifSettings.edit(); editor.putBoolean("allow", isChecked); editor.apply(); if (isChecked) { Intent notifIntent = new Intent(getApplicationContext(), NotificationService.class); notifIntent.addCategory(NotificationService.TAG); stopService(notifIntent); startService(notifIntent); } } }); }