private void initNavigation() { drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); drawerToggle = new ActionBarDrawerToggle( MainActivity.this, drawerLayout, R.string.hello_world, R.string.hello_world); drawerLayout.setDrawerListener(drawerToggle); NavigationView navigationView = (NavigationView) findViewById(R.id.navigation); navigationView.setNavigationItemSelectedListener(new MyOnNavItemListener()); navMenu = navigationView.getMenu(); navMenu.getItem(0).setChecked(true); sharedPreferences = getSharedPreferences(SpConfig.Name, Context.MODE_PRIVATE); String icon = sharedPreferences.getString(SpConfig.PERSON_ICON, ""); TextView navName = (TextView) navigationView.findViewById(R.id.nav_header_name); String name = sharedPreferences.getString(SpConfig.PERSON_NAME, ""); navName.setText(name); ImageView navIcon = (ImageView) navigationView.findViewById(R.id.nav_header_icon); ImageHelper imageHelper = ImageHelper.getInstance(getApplicationContext()); imageHelper.loadCircleImage(navIcon, icon, 120); String portalName = sharedPreferences.getString(SpConfig.P_NAME, ""); String portalPw = sharedPreferences.getString(SpConfig.P_PW, ""); portalHelper = new PortalHelper(getApplicationContext()); if (StringUtil.isNull(portalName) || StringUtil.isNull(portalPw)) { navMenu.getItem(2).setVisible(false); } else { portalHelper.info(new PortalInfo()); } }
private void bindPictureViewHolder(RecyclerView.ViewHolder holder, int position) { PictureMemory memory = (PictureMemory) dataSet.get(position); PictureViewHolder pvh = (PictureViewHolder) holder; pvh.placeTv.setText(memory.getTitle()); pvh.timeTv.setText(memory.getTime()); String[] pictures = memory.getPictures(); if (pictures != null) { if (pictures.length < 3) { String firstPicName = pictures[0]; imageHelper.loadImage(pvh.imageView, firstPicName, 400, 400); pvh.imageView.setVisibility(View.VISIBLE); for (int i = 0; i < 9; i++) { pvh.nine[i].setVisibility(View.GONE); } } else if (pictures.length >= 3 && pictures.length < 6) { for (int i = 0; i < 3; i++) { String firstPicName = pictures[i]; imageHelper.loadSquareImage(pvh.nine[i], firstPicName, 300); pvh.nine[i].setVisibility(View.VISIBLE); } pvh.imageView.setVisibility(View.GONE); for (int i = 3; i < 9; i++) { pvh.nine[i].setVisibility(View.GONE); } } else if (pictures.length >= 6 && pictures.length < 9) { for (int i = 0; i < 6; i++) { String firstPicName = pictures[i]; imageHelper.loadSquareImage(pvh.nine[i], firstPicName, 300); pvh.nine[i].setVisibility(View.VISIBLE); } pvh.imageView.setVisibility(View.GONE); for (int i = 6; i < 9; i++) { pvh.nine[i].setVisibility(View.GONE); } } else if (pictures.length >= 9) { for (int i = 0; i < 9; i++) { String firstPicName = pictures[i]; imageHelper.loadSquareImage(pvh.nine[i], firstPicName, 300); pvh.nine[i].setVisibility(View.VISIBLE); } pvh.imageView.setVisibility(View.GONE); } } }
private void bindMessageViewHolder(RecyclerView.ViewHolder holder, int position) { MessageViewHolder mvh = (MessageViewHolder) holder; MessageMemory memory = (MessageMemory) dataSet.get(position); mvh.name.setText(memory.getPersonName()); imageHelper.loadSquareImage(mvh.icon, memory.getPersonIconName(), 40); mvh.time.setText(memory.getTime()); mvh.message.setText(memory.getMessage()); }
// Provide a suitable constructor (depends on the kind of dataSet) public MainRecyclerViewAdapter(ArrayList<Memory> myDataSet, Context context) { dataSet = myDataSet; this.context = context; this.imageHelper = ImageHelper.getInstance(context); }