Exemple #1
0
  // ****************************************************************
  // * Life Cycle
  // ****************************************************************
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    try {
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);

      final ActionBar actionBar = getSupportActionBar();
      actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setElevation(0);

      mySohaAPI.setReceive(this);

      viewHolder =
          new MainViewHolder(
              this, this, findViewById(R.id.drawer_layout), getSupportFragmentManager());

      mySohaAPI.requestApi(RequestType.GIFT_POPUP, GiftPopupDTO.class, null, getTagId());

      Utils.showMessageNotify(findViewById(R.id.app_content), R.string.notify_user_login_success);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 private void initActionBar() {
   ActionBar actionBar = getSupportActionBar();
   actionBar.setDisplayHomeAsUpEnabled(true);
   actionBar.setHomeButtonEnabled(true);
   actionBar.setElevation(0f);
   SpannableString s = new SpannableString(getResources().getString(R.string.str_calorie_menu));
   s.setSpan(
       new TypefaceSpan(this, "ClementePDai-Regular.otf"),
       0,
       s.length(),
       Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   actionBar.setTitle(s);
 }
  private void setTitleBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.actionbar_title);
    actionBar.setElevation(0);

    int actionbarcolor = getResources().getColor(R.color.background_title);
    actionBar.setBackgroundDrawable(new ColorDrawable(actionbarcolor));
    actionBar.setDisplayHomeAsUpEnabled(true);
    TextView title =
        (TextView) actionBar.getCustomView().findViewById(R.id.actionbar_title_textview);
    title.setText("Confirm");
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.yj_activity_user_info);
    ButterKnife.bind(this);
    EventBus.getDefault().register(this);
    initView();

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        actionBar.setElevation(0);
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_photo_pager);

    int currentItem = getIntent().getIntExtra(EXTRA_CURRENT_ITEM, 0);
    List<String> paths = getIntent().getStringArrayListExtra(EXTRA_PHOTOS);

    pagerFragment =
        (ImagePagerFragment) getSupportFragmentManager().findFragmentById(R.id.photoPagerFragment);
    pagerFragment.setPhotos(paths, currentItem);

    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    actionBar = getSupportActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);
    updateActionBarTitle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      actionBar.setElevation(25);
    }

    pagerFragment
        .getViewPager()
        .addOnPageChangeListener(
            new ViewPager.OnPageChangeListener() {
              @Override
              public void onPageScrolled(
                  int position, float positionOffset, int positionOffsetPixels) {
                updateActionBarTitle();
              }

              @Override
              public void onPageSelected(int i) {}

              @Override
              public void onPageScrollStateChanged(int i) {}
            });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preferences);

    setContentView(R.layout.activity_preferences);

    // do toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    Resources r = getResources();
    float elevation =
        TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, r.getDisplayMetrics());
    actionBar.setElevation(elevation);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("Settings");

    getFragmentManager()
        .beginTransaction()
        .replace(R.id.content_frame, new SharedPreferencesFragment())
        .commit();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    View view = getLayoutInflater().inflate(R.layout.action_bar_view, null);
    view.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    TextView titleView = (TextView) view.findViewById(R.id.title_text);
    titleView.setText(R.string.actionBar_title);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setElevation(0);
      actionBar.setCustomView(view);
      actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffff")));
      actionBar.setDisplayShowCustomEnabled(true);
    }

    firstNameEditView = (EditText) findViewById(R.id.firstName);
    lastNameEditView = (EditText) findViewById(R.id.lastName);
    emailIdEditView = (EditText) findViewById(R.id.email);
    cityEditView = (EditText) findViewById(R.id.city);
    zipEditView = (EditText) findViewById(R.id.zip);
    next = (Button) findViewById(R.id.next);

    stateSpinner = (Spinner) findViewById(R.id.state);

    // Edit Text view click Time only open the keyboard
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(firstNameEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(lastNameEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(emailIdEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(cityEditView.getWindowToken(), 0);
    mgr.hideSoftInputFromWindow(zipEditView.getWindowToken(), 0);
    mgr.showSoftInput(firstNameEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(lastNameEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(emailIdEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(cityEditView, InputMethodManager.SHOW_IMPLICIT);
    mgr.showSoftInput(zipEditView, InputMethodManager.SHOW_IMPLICIT);

    boolean tabletSize = getResources().getBoolean(R.bool.isTablet);
    if (tabletSize) {
      stateDetail =
          new String[] {
            "AZ", "NY", "AL", "AK", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "ID",
            "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT",
            "NE", "NV", "NH", "NJ", "NM", "NC", "ND", "OH", "OK", "OR", "PA", "PR", "RI", "SC",
            "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"
          };

    } else {
      specialtySpinner = (Spinner) findViewById(R.id.specialty);
      String[] specialtyItem =
          new String[] {
            "Pulmonologist",
            "Cardiologist",
            "Hematologist",
            "Rheumatologist",
            "Infectious Disease",
            "Other"
          };
      ArrayAdapter<String> adapter =
          new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, specialtyItem);
      specialtySpinner.setAdapter(adapter);
      stateDetail =
          new String[] {
            "NY", "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "ID",
            "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT",
            "NE", "NV", "NH", "NJ", "NM", "NC", "ND", "OH", "OK", "OR", "PA", "PR", "RI", "SC",
            "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"
          };
    }

    ArrayAdapter<String> stateAdapter =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_spinner_item, stateDetail); // State = AZ(tab)

    stateSpinner.setAdapter(stateAdapter);

    next.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            validateRegisterInfo();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_text);
    Log.d(getString(R.string.log_tag), "The AddTextActivity onCreate() event");
    mySwitch = (Switch) findViewById(R.id.mySwitch);
    editText = (EditText) findViewById(R.id.edit_message);
    doneButton = (View) findViewById(R.id.btnDone);
    checkedCategories = new ArrayList<Category>();
    dbHandle = ReminderItemDbHelper.getInstance(getApplicationContext());

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar == null) Log.d(getString(R.string.log_tag), "ActionBar is null");
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    actionBar.setElevation(0);

    // set the switch to OFF by default
    // remind inStore OFF by default
    mySwitch.setChecked(false);
    inStore = false;

    // attach a listener to check for changes in state
    mySwitch.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if (isChecked) {
              inStore = true;
            } // if
            else {
              inStore = false;
            } // else
          } // onCheckedChanged
        }); // setOnCheckedChangeListener

    doneButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Log.d(getString(R.string.log_tag), "Done button clicked");

            // Enforce that the necessary fields are non empty
            String name = editText.getText().toString();
            if (name.equals("")) {
              Toast.makeText(
                      getApplicationContext(),
                      "Item must have a non-empty name.",
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }
            if (checkedCategories.isEmpty()) {
              Toast.makeText(
                      getApplicationContext(),
                      "Item must be associated with at least 1 category.",
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }

            // Add the item to the db
            dbHandle.addItem(name, inStore, checkedCategories);

            // Return back to the home screen
            finish();
          }
        });
  } // onCreate
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_share_note);

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setElevation(0.0f);
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setHomeButtonEnabled(true);
    }

    FragmentManager fragmentManager = getFragmentManager();
    Bundle extras = getIntent().getExtras();
    String action = getIntent().getAction();

    if (savedInstanceState == null) {
      if (extras != null) {
        // Load post from the postId passed in extras
        long localNoteId = extras.getLong(EXTRA_NOTEID, 0L);

        mNote = Leanote.leaDB.getLocalNoteById(localNoteId);
        AppLog.i("mnote:" + mNote);
      } else {
        // A postId extra must be passed to this activity
        showErrorAndFinish(R.string.note_not_found);
        return;
      }
    }

    // Ensure we have a valid post
    if (mNote == null) {
      showErrorAndFinish(R.string.note_not_found);
      return;
    }

    setTitle(StringUtils.unescapeHTML("Share Notes"));

    publishToLeaBlog = (Button) findViewById(R.id.share_note_blog_btn);
    publishToLeaBlog.setOnClickListener(
        new Button.OnClickListener() {
          @Override
          public void onClick(View v) {
            mNote.setIsPublicBlog(true);
            Leanote.leaDB.updateNote(mNote);
            Toast.makeText(getApplicationContext(), "Publish to Lea++ Blog", Toast.LENGTH_LONG)
                .show();
          }
        });

    sendMailBtn = (Button) findViewById(R.id.share_note_mail_btn);
    //        mailAddrEditText = (EditText) findViewById(R.id.sourceview_mail_addr);
    //        pwdEditText = (EditText) findViewById(R.id.sourceview_mail_pwd);
    sendMailBtn.setOnClickListener(
        new Button.OnClickListener() {
          @Override
          public void onClick(View v) {
            //                if( mailAddrEditText.getText().length() == 0 ) {
            //                    Toast.makeText(getApplicationContext(), "Please input you e-mail
            // address", Toast.LENGTH_LONG).show();
            //                }
            //
            //                if( pwdEditText.getText().length() == 0 ) {
            //                    Toast.makeText(getApplicationContext(), "Please input you e-mail
            // password", Toast.LENGTH_LONG).show();
            //                }

            Intent data = new Intent(Intent.ACTION_SENDTO);
            data.setData(Uri.parse("mailto:"));
            data.putExtra(Intent.EXTRA_SUBJECT, mNote.getTitle());
            data.putExtra(Intent.EXTRA_TEXT, mNote.getContent());
            startActivity(data);
          }
        });
  }