@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_CANCELED) { onBackPressed(); } if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) { long createdAt = HelpMe.getCurrentTime(); String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) .getAbsolutePath() + "/vid_" + TJPreferences.getUserId(this) + "_" + TJPreferences.getActiveJourneyId(this) + "_" + createdAt + ".mp4"; try { AssetFileDescriptor videoAsset = getContentResolver().openAssetFileDescriptor(data.getData(), "r"); FileInputStream fis = videoAsset.createInputStream(); File root = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) .getAbsolutePath()); if (!root.exists()) { root.mkdirs(); } File file; file = new File(filePath); FileOutputStream fos = new FileOutputStream(file); byte[] buf = new byte[1024]; int len; while ((len = fis.read(buf)) > 0) { fos.write(buf, 0, len); } fis.close(); fos.close(); } catch (Exception e) { e.printStackTrace(); } /* Uri videoUri = data.getData(); Log.d(TAG, "video saved at" + videoUri); Log.d(TAG, "Real path URI" + getRealPathFromURI(videoUri));*/ Intent i = new Intent(this, VideoPreview.class); i.putExtra("VIDEO_PATH", filePath); i.putExtra("CREATED_AT", createdAt); startActivity(i); finish(); } }
// Replace the contents of a view (invoked by the layout manager) @Override public void onBindViewHolder(ViewHolder holder, final int position) { // - get element from your dataset at this position // - replace the contents of the view with that element final Contact contactsItem = mDataset.get(position); final String name = contactsItem.getPhoneBookName() == null ? contactsItem.getProfileName() : contactsItem.getPhoneBookName(); final String status = contactsItem.getStatus() == null ? "" : contactsItem.getStatus(); final String picLocalURL = contactsItem.getPicLocalUrl(); Log.d(TAG, "info are : " + name + "---" + status + "---" + picLocalURL); if (picLocalURL != null) { Bitmap bitmap = BitmapFactory.decodeFile(picLocalURL, new BitmapFactory.Options()); holder.buddyPicImageView.setImageBitmap(bitmap); } else { holder.buddyPicImageView.setImageResource(R.drawable.gumnaam_profile_image); } holder.buddyName.setText(name); holder.buddyStatus.setText(status); if (HelpMe.isAdmin(context) && !contactsItem.getIdOnServer().equals(TJPreferences.getUserId(context))) { holder.removeBuddyIcon.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(context) .setTitle("Remove Friend") .setMessage("Are you sure you want to remove your friend from this journey") .setPositiveButton( android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mDialog.show(); JourneyUtil.getInstance() .setExitJourneyListener(JourneyInfoBuddiesListAdapter.this); JourneyUtil.getInstance() .exitJourney(context, mDataset.get(position).getIdOnServer()); } }) .setNegativeButton( android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }) .setIcon(android.R.drawable.ic_dialog_alert) .show(); } }); } else { holder.removeBuddyIcon.setVisibility(View.GONE); } Journey journey = JourneyDataSource.getJourneyById(context, TJPreferences.getActiveJourneyId(context)); if (journey.getCreatedBy().equals(contactsItem.getIdOnServer())) { holder.adminText.setVisibility(View.VISIBLE); } else { holder.adminText.setVisibility(View.GONE); } }