예제 #1
0
  @Override
  public void onResume() {

    super.onResume();
    File path =
        new File(Environment.getExternalStorageDirectory(), "/weHappening/profile_image.png");
    Bitmap b = null;
    if (path.exists()) {
      try {
        b = BitmapFactory.decodeStream(new FileInputStream(path));
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
      CircularImageView img = (CircularImageView) findViewById(R.id.imgPicker);
      img.setImageBitmap(b);
    } else {
      CircularImageView img = (CircularImageView) findViewById(R.id.imgPicker);
      img.setImageDrawable(getResources().getDrawable(R.drawable.ic_person));
    }
  }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_profile);

    mFlexibleSpaceImageHeight =
        getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mFlexibleSpaceShowFabOffset =
        getResources().getDimensionPixelSize(R.dimen.flexible_space_show_fab_offset);
    mActionBarSize = getActionBarSize();
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mImageView = findViewById(R.id.image);
    mOverlayView = findViewById(R.id.overlay);
    mScrollView = (ObservableScrollView) findViewById(R.id.scroll);
    mScrollView.setScrollViewCallbacks(this);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);
    mFab = findViewById(R.id.fab);
    mFab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), EditProfile.class);
            startActivity(intent);
          }
        });
    mFabMargin = getResources().getDimensionPixelSize(R.dimen.margin_standard);
    ViewHelper.setScaleX(mFab, 0);
    ViewHelper.setScaleY(mFab, 0);

    ScrollUtils.addOnGlobalLayoutListener(
        mScrollView,
        new Runnable() {
          @Override
          public void run() {
            mScrollView.scrollTo(0, mFlexibleSpaceImageHeight - mActionBarSize);

            // If you'd like to start from scrollY == 0, don't write like this:
            // mScrollView.scrollTo(0, 0);
            // The initial scrollY is 0, so it won't invoke onScrollChanged().
            // To do this, use the following:
            // onScrollChanged(0, false, false);

            // You can also achieve it with the following codes.
            // This causes scroll change from 1 to 0.
            mScrollView.scrollTo(0, 1);
            mScrollView.scrollTo(0, 0);
          }
        });

    File path =
        new File(Environment.getExternalStorageDirectory(), "/weHappening/profile_image.png");
    Bitmap b = null;
    if (path.exists()) {
      try {
        b = BitmapFactory.decodeStream(new FileInputStream(path));
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
      CircularImageView img = (CircularImageView) findViewById(R.id.imgPicker);
      img.setImageBitmap(b);
    } else {
      CircularImageView img = (CircularImageView) findViewById(R.id.imgPicker);
      img.setImageDrawable(getResources().getDrawable(R.drawable.ic_person));
    }
  }
예제 #3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflating view layout
    View layout = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
    recyclerView = (RecyclerView) layout.findViewById(R.id.drawerList);

    adapter = new NavigationDrawerAdapter(getActivity(), getData());
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    List<SimpleSectionedRecyclerViewAdapter.Section> sections =
        new ArrayList<SimpleSectionedRecyclerViewAdapter.Section>();

    // Sections
    sections.add(new SimpleSectionedRecyclerViewAdapter.Section(5, "Categories"));

    // Add your adapter to the sectionAdapter
    SimpleSectionedRecyclerViewAdapter.Section[] dummy =
        new SimpleSectionedRecyclerViewAdapter.Section[sections.size()];
    SimpleSectionedRecyclerViewAdapter mSectionedAdapter =
        new SimpleSectionedRecyclerViewAdapter(
            getContext(), R.layout.section, R.id.section_text, adapter);
    mSectionedAdapter.setSections(sections.toArray(dummy));

    // Apply this adapter to the RecyclerView
    recyclerView.setAdapter(mSectionedAdapter);

    recyclerView.addOnItemTouchListener(
        new RecyclerTouchListener(
            getActivity(),
            recyclerView,
            new ClickListener() {
              @Override
              public void onClick(View view, int position) {
                NavigationDrawerAdapter.selected_item = position;
                recyclerView.getAdapter().notifyDataSetChanged();
                drawerListener.onDrawerItemSelected(view, position);
                mDrawerLayout.closeDrawer(containerView);
              }

              @Override
              public void onLongClick(View view, int position) {}
            }));

    name = (TextView) layout.findViewById(R.id.name);
    email = (TextView) layout.findViewById(R.id.email);
    String fontPath = "fonts/Centurygothic.ttf";
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), fontPath);
    name.setTypeface(tf);
    email.setTypeface(tf);
    options = (ImageView) layout.findViewById(R.id.options);
    options.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            showFilterPopup(view);
          }
        });
    search = (ImageView) layout.findViewById(R.id.imageView3);
    search.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });
    File path =
        new File(Environment.getExternalStorageDirectory(), "/weHappening/profile_image.png");
    Bitmap b = null;
    if (path.exists()) {
      try {
        b = BitmapFactory.decodeStream(new FileInputStream(path));
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
      CircularImageView img = (CircularImageView) layout.findViewById(R.id.imageView2);
      img.setImageBitmap(b);
    } else {
      CircularImageView img = (CircularImageView) layout.findViewById(R.id.imageView2);
      img.setImageDrawable(getResources().getDrawable(R.drawable.ic_person));
    }
    CircularImageView img = (CircularImageView) layout.findViewById(R.id.imageView2);
    img.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getContext(), MyProfile.class);
            startActivity(intent);
          }
        });
    return layout;
  }