1 ) Folder Adapter
public class FoldersListTagMainAdapter extends RecyclerView.Adapter
{
private int mViewItem = 1;
private Activity mActivity;
private PopupMenu popupMenu;
private SharedPreferences MainTagId;
private LayoutInflater mLayoutInflater;
private String mGreenbox_internal_sharing;
private String mConfiguration,mConfigurationName;
public static final String PREFS_REFID = "RefId";
private OnAdapterClickEventListener mClickListener;
public static final String PREFS_NAME = "SourceId";
public static final String PREFS_FOLDER_ID = "FolderId";
public static final String PREFS_MAIN_TAG_ID = "MainTagId";
public static final String PREFS_FOLDER_NAME ="FolderName";
public static final String PREFS_FOLDER_DEST_ID = "DestFolderId";
// private ArrayList<MainTagModel> mArrMainTagModel = new ArrayList<>();
public static final String PREFS_CREATED_BY_FOLDER ="createdByFolder";
public static final String PREFS_CREATED_ON_FOLDER ="createdOnFolder";
private ArrayList<FolderListModel> mArrFolderListModel = new ArrayList<>();
private String mID,mFolderId,mRefId,mObjectId,mParentTagId,mCreatedBy,mCreatedOn,mFolderName;
private SharedPreferences.Editor FolderId,SourceId,FolderName,RefId,CreatedByFolder, CreatedOnFolder,DestId;
public FoldersListTagMainAdapter(Activity mActivity, ArrayList mFolderListModel,OnAdapterClickEventListener listener)
{
this.mActivity = mActivity;
this.mArrFolderListModel = mFolderListModel;
this.mClickListener = listener;
mLayoutInflater = LayoutInflater.from(mActivity);
}
/**
* Create an interface for the recycler view click events
*/
public interface OnAdapterClickEventListener
{
void onMoveToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onCopyToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onRenameToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onShareToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onCopyLinkToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onRemoveFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View view = mLayoutInflater.inflate(R.layout.row_folders_list_item, parent,
false);
return new CustomViewHolder(view);
}
@Override
public int getItemViewType(int position)
{
return mArrFolderListModel.get(position) != null ? mViewItem : 0;
}
@Override
public int getItemCount()
{
return mArrFolderListModel.size();
}
public void setFilter(List<FolderListModel> mfolderListModels)
{
mArrFolderListModel = new ArrayList<>();
mArrFolderListModel.addAll(mfolderListModels);
notifyDataSetChanged();
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position)
{
final FolderListModel mAllFolderList = mArrFolderListModel.get(position);
// if (holder instanceof CustomViewHolder) {
((CustomViewHolder) holder).mTextFolderName.setText(mAllFolderList.getTagName());
((CustomViewHolder) holder).mTextFolderOwnerName.setText(Common.getDateFromMillis
(Long.parseLong(mAllFolderList.getCreatedOn()), mActivity.getResources()
.getString(R.string.common_date_format_DMYHMA)));
((CustomViewHolder) holder).mLinearRowFolderList.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setDataToPreference(mArrFolderListModel,position);
goToNextFragment();
}
});
/*
Option Image Click
*/
((CustomViewHolder) holder).mLinearRowFolderListMenuImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popupMenu = new PopupMenu(mActivity, ((CustomViewHolder) holder).mLinearRowFolderListMenuImage);
popupMenu.inflate(R.menu.folder_popup_menu);
// For Showing Icon In To The Popup Menu
Object menuHelper;
Class[] argTypes;
try {
Field fMenuHelper = PopupMenu.class.getDeclaredField(AppConstants.STR_MPOPUP);
fMenuHelper.setAccessible(true);
menuHelper = fMenuHelper.get(popupMenu);
argTypes = new Class[]{boolean.class};
menuHelper.getClass().getDeclaredMethod(AppConstants.STR_SET_FORCE_SHOW_ICON, argTypes).invoke
(menuHelper, true);
} catch (Exception e) {
return;
}
try {
mGreenbox_internal_sharing = AppConstants.STR_GREENBOX_INTERNAL_SHARING;
mConfiguration = SessionManager.getConfiguration(mActivity);
JSONObject jObject = null;
jObject = new JSONObject(mConfiguration);
mConfigurationName = (jObject.getString(mGreenbox_internal_sharing));
if (mConfigurationName.equalsIgnoreCase("false"))
{
popupMenu.getMenu().removeItem(R.id.share_folder_popup_menu);
}
/* else
{
popupMenu.getMenu().add(1,R.id.share_folder_popup_menu,3,"Share");
}*/
} catch (JSONException e) {
e.printStackTrace();
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId())
{
case R.id.share_folder_popup_menu:
try {
AppConstants.isFolder = true;
mObjectId = mAllFolderList.getId();
SessionManager.setObjectID(mActivity, mObjectId);
mFolderName = mArrFolderListModel.get(position).getTagName();
FolderName = mActivity.getSharedPreferences(PREFS_FOLDER_NAME,
MODE_PRIVATE).edit();
FolderName.putString("FolderName", mFolderName);
FolderName.apply();
mClickListener.onShareToFolderTagMainList(position, mArrFolderListModel);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.copy_link_folder_popup_menu:
try {
mClickListener.onCopyLinkToFolderTagMainList(position, mArrFolderListModel);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.move_to_folder_popup_menu:
try {
AppConstants.isMove = true;
AppConstants.isFolder = true;
MainTagId = mActivity.getSharedPreferences(PREFS_MAIN_TAG_ID, MODE_PRIVATE);
mParentTagId = MainTagId.getString("MainTagId", null);
SourceId = mActivity.getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit();
SourceId.putInt("SourceId", Integer.parseInt(mParentTagId));
SourceId.apply();
mObjectId = mAllFolderList.getId();
SessionManager.setObjectID(mActivity, mObjectId);
Common.insertLog("Object Id " + mObjectId);
mClickListener.onMoveToFolderTagMainList(position, mArrFolderListModel);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.rename_folder_popup_menu:
try {
mFolderId = mArrFolderListModel.get(position).getId();
FolderId = mActivity.getSharedPreferences(PREFS_FOLDER_ID, Context.MODE_PRIVATE).edit();
FolderId.putString("FolderId", mFolderId);
FolderId.apply();
mRefId = mArrFolderListModel.get(position).getRefId();
RefId = mActivity.getSharedPreferences(PREFS_REFID, Context.MODE_PRIVATE).edit();
RefId.putString("RefId", mRefId);
RefId.apply();
mClickListener.onRenameToFolderTagMainList(position, mArrFolderListModel);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.view_details_folder_popup_menu:
try {
//Save File Details TO Shared Preference
mCreatedBy = mArrFolderListModel.get(position).getCreatedByName();
CreatedByFolder = mActivity.getSharedPreferences
(PREFS_CREATED_BY_FOLDER, MODE_PRIVATE).edit();
CreatedByFolder.putString("createdByFolder", mCreatedBy);
CreatedByFolder.apply();
CreatedOnFolder = mActivity.getSharedPreferences
(PREFS_CREATED_ON_FOLDER, MODE_PRIVATE).edit();
CreatedOnFolder.putString("createdOnFolder", mCreatedOn);
CreatedOnFolder.apply();
mFolderId = mArrFolderListModel.get(position).getId();
FolderId = mActivity.getSharedPreferences(PREFS_FOLDER_ID, Context.MODE_PRIVATE).edit();
FolderId.putString("FolderId", mFolderId);
FolderId.apply();
Intent intent = new Intent(mActivity, ViewFoldersDetailsActivity.class);
mActivity.startActivity(intent);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.copy_to_folder_popup_menu:
try {
AppConstants.isCopy = true;
AppConstants.isFolder = true;
MainTagId = mActivity.getSharedPreferences(PREFS_MAIN_TAG_ID, MODE_PRIVATE);
mParentTagId = MainTagId.getString("MainTagId", null);
SourceId = mActivity.getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit();
SourceId.putInt("SourceId", Integer.parseInt(mParentTagId));
SourceId.apply();
mObjectId = mAllFolderList.getId();
SessionManager.setObjectID(mActivity, mObjectId);
Common.insertLog("Object Id " + mObjectId);
mClickListener.onCopyToFolderTagMainList(position, mArrFolderListModel);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.remove_folder_popup_menu:
try {
mID = mAllFolderList.getId();
SessionManager.setFolderID(mActivity, mID);
callRemoveTagAPI(position);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
}
return false;
}
});
popupMenu.show();
}
});
}
private void setDataToPreference(ArrayList<FolderListModel> mArrFolderListModel, int position) {
try {
mID = mArrFolderListModel.get(position).getId();
mRefId = mArrFolderListModel.get(position).getRefId();
mParentTagId = mArrFolderListModel.get(position).getId();
mFolderName = mArrFolderListModel.get(position).getTagName();
FolderName = mActivity.getSharedPreferences(PREFS_FOLDER_NAME,
MODE_PRIVATE).edit();
FolderName.putString("FolderName", mFolderName);
FolderName.apply();
SourceId = mActivity.getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit();
SourceId.putInt("SourceId", Integer.parseInt(mParentTagId));
SourceId.apply();
mFolderId = mArrFolderListModel.get(position).getId();
FolderId = mActivity.getSharedPreferences(PREFS_FOLDER_ID, Context.MODE_PRIVATE).edit();
FolderId.putString("FolderId", mFolderId);
FolderId.apply();
RefId = mActivity.getSharedPreferences(PREFS_REFID, Context.MODE_PRIVATE).edit();
RefId.putString("RefId", mRefId);
RefId.apply();
DestId = mActivity.getSharedPreferences(PREFS_FOLDER_DEST_ID, MODE_PRIVATE).edit();
DestId.putInt("DestFolderId", Integer.parseInt(mParentTagId));
DestId.apply();
Common.insertLog("Parent Id::>>>>>" + mParentTagId);
// Common.insertLog("Parent Tag Id " + mParentTagId);
//
SessionManager.setParentTagID(mActivity, mParentTagId);
SessionManager.setRefId(mActivity, mRefId);
SessionManager.setFolderID(mActivity, mID);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
private void goToNextFragment()
{
try {
FragmentManager fragmentManager;
if (AppConstants.menuClick == true) {
fragmentManager = ((FoldersAndFilesMoveAndCopyToActivity) mActivity).getSupportFragmentManager();
} else {
fragmentManager = ((MainActivity) mActivity).getSupportFragmentManager();
}
//initialization Of Fragments
Fragment folderstagmainfragment = null;
folderstagmainfragment = new FoldersTagMainFragment();
Fragment folderschildtagonefragment = null;
folderschildtagonefragment = new FoldersChildTagOneFragment();
Fragment folderschildtagtwofragment = null;
folderschildtagtwofragment = new FoldersChildTagTwoFragment();
Fragment fileschildtagonefragment = null;
fileschildtagonefragment = new FilesChildTagOneFragment();
if (AppConstants.STR_CURRENT_FOLDER_FRAGMENT == AppConstants
.STR_FOLDER_CONTENT_MAIN_FRAGMENT) {
if (AppConstants.menuClick == true) {
fragmentManager.beginTransaction().add(R.id.frame_activity_folders_move_to,
folderschildtagonefragment, mActivity.getResources().getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources().getString(R.string.back_stack_main_fragment_folder))
.commit();
} else {
fragmentManager.beginTransaction().add(R.id.frame_content_greenbox_main,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources().getString(R.string.back_stack_folder_main))
.commit();
}
} else if (AppConstants.STR_CURRENT_FOLDER_FRAGMENT == AppConstants.STR_FOLDER_CONTENT_ONE_FRAGMENT) {
if (AppConstants.menuClick == true) {
fragmentManager.beginTransaction().add(R.id.frame_activity_folders_move_to,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
} else {
fragmentManager.beginTransaction().add(R.id.frame_content_greenbox_main,
folderschildtagtwofragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
}
} else if (AppConstants.STR_CURRENT_FOLDER_FRAGMENT == AppConstants.STR_FOLDER_CONTENT_TWO_FRAGMENT) {
if (AppConstants.menuClick == true) {
fragmentManager.beginTransaction().add(R.id.frame_activity_folders_move_to,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
} else {
fragmentManager.beginTransaction().add(R.id.frame_content_greenbox_main,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
}
}
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
public static class CustomViewHolder extends RecyclerView.ViewHolder
{
private TextView mTextFolderName, mTextFolderOwnerName;
private LinearLayout mLinearRowFolderList,mLinearRowFolderListMenuImage;
public CustomViewHolder(View view)
{
super(view);
mTextFolderName = (TextView) view.findViewById(R.id.text_row_folder_list_name);
mTextFolderOwnerName = (TextView) view.findViewById(R.id.text_row_folder_list_owner_name);
mLinearRowFolderList = (LinearLayout) view.findViewById(R.id.linear_row_folder_list);
mLinearRowFolderListMenuImage = (LinearLayout) view.findViewById(R.id.linear_row_folder_list_menu_image);
if(AppConstants.menuClick==true)
{
mLinearRowFolderListMenuImage.setVisibility(View.GONE);
}
}
}
/*
This Mehtod Sould Remove Item
*/
public void removeItem(int position)
{
mArrFolderListModel.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, mArrFolderListModel.size());
}
/*
This Method Will Call Remove API
*/
private void callRemoveTagAPI(final int position)
{
try
{
if (ConnectivityDetector.IS_INTERNET_AVAILABLE(mActivity))
{
new OkHTTPCallBackGetJsonObjectRemoveFolderOrFile(mActivity, AppConstants
.API_REMOVE_TAG_FOLDER, WebFields.REMOVE_TAG.MODE, AppConstants.intFlagShow,
new OnUpdateListenerJsonObject()
{
@Override
public void onUpdateComplete(JSONObject jsonObject, boolean isSuccess)
{
if (isSuccess)
{
removeItem(position);
mClickListener.onRemoveFolderTagMainList(position, mArrFolderListModel);
}
else
{
try
{
SnackBarAlertDialog.SUCCESS(mActivity,
jsonObject.getString(AppConstants.STR_FOLDER_REMOVED_ERROR));
} catch (JSONException exception)
{
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
}
}).execute();
}
else
{
SnackBarAlertDialog.ERROR(mActivity, AppConstants.STR_INETRNET_ALERT_MESSAGE);
}
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
}
public class FoldersListTagMainAdapter extends RecyclerView.Adapter
{
private int mViewItem = 1;
private Activity mActivity;
private PopupMenu popupMenu;
private SharedPreferences MainTagId;
private LayoutInflater mLayoutInflater;
private String mGreenbox_internal_sharing;
private String mConfiguration,mConfigurationName;
public static final String PREFS_REFID = "RefId";
private OnAdapterClickEventListener mClickListener;
public static final String PREFS_NAME = "SourceId";
public static final String PREFS_FOLDER_ID = "FolderId";
public static final String PREFS_MAIN_TAG_ID = "MainTagId";
public static final String PREFS_FOLDER_NAME ="FolderName";
public static final String PREFS_FOLDER_DEST_ID = "DestFolderId";
// private ArrayList<MainTagModel> mArrMainTagModel = new ArrayList<>();
public static final String PREFS_CREATED_BY_FOLDER ="createdByFolder";
public static final String PREFS_CREATED_ON_FOLDER ="createdOnFolder";
private ArrayList<FolderListModel> mArrFolderListModel = new ArrayList<>();
private String mID,mFolderId,mRefId,mObjectId,mParentTagId,mCreatedBy,mCreatedOn,mFolderName;
private SharedPreferences.Editor FolderId,SourceId,FolderName,RefId,CreatedByFolder, CreatedOnFolder,DestId;
public FoldersListTagMainAdapter(Activity mActivity, ArrayList mFolderListModel,OnAdapterClickEventListener listener)
{
this.mActivity = mActivity;
this.mArrFolderListModel = mFolderListModel;
this.mClickListener = listener;
mLayoutInflater = LayoutInflater.from(mActivity);
}
/**
* Create an interface for the recycler view click events
*/
public interface OnAdapterClickEventListener
{
void onMoveToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onCopyToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onRenameToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onShareToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onCopyLinkToFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
void onRemoveFolderTagMainList(int pos, ArrayList<FolderListModel> mArrFolderListModel);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View view = mLayoutInflater.inflate(R.layout.row_folders_list_item, parent,
false);
return new CustomViewHolder(view);
}
@Override
public int getItemViewType(int position)
{
return mArrFolderListModel.get(position) != null ? mViewItem : 0;
}
@Override
public int getItemCount()
{
return mArrFolderListModel.size();
}
public void setFilter(List<FolderListModel> mfolderListModels)
{
mArrFolderListModel = new ArrayList<>();
mArrFolderListModel.addAll(mfolderListModels);
notifyDataSetChanged();
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position)
{
final FolderListModel mAllFolderList = mArrFolderListModel.get(position);
// if (holder instanceof CustomViewHolder) {
((CustomViewHolder) holder).mTextFolderName.setText(mAllFolderList.getTagName());
((CustomViewHolder) holder).mTextFolderOwnerName.setText(Common.getDateFromMillis
(Long.parseLong(mAllFolderList.getCreatedOn()), mActivity.getResources()
.getString(R.string.common_date_format_DMYHMA)));
((CustomViewHolder) holder).mLinearRowFolderList.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setDataToPreference(mArrFolderListModel,position);
goToNextFragment();
}
});
/*
Option Image Click
*/
((CustomViewHolder) holder).mLinearRowFolderListMenuImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popupMenu = new PopupMenu(mActivity, ((CustomViewHolder) holder).mLinearRowFolderListMenuImage);
popupMenu.inflate(R.menu.folder_popup_menu);
// For Showing Icon In To The Popup Menu
Object menuHelper;
Class[] argTypes;
try {
Field fMenuHelper = PopupMenu.class.getDeclaredField(AppConstants.STR_MPOPUP);
fMenuHelper.setAccessible(true);
menuHelper = fMenuHelper.get(popupMenu);
argTypes = new Class[]{boolean.class};
menuHelper.getClass().getDeclaredMethod(AppConstants.STR_SET_FORCE_SHOW_ICON, argTypes).invoke
(menuHelper, true);
} catch (Exception e) {
return;
}
try {
mGreenbox_internal_sharing = AppConstants.STR_GREENBOX_INTERNAL_SHARING;
mConfiguration = SessionManager.getConfiguration(mActivity);
JSONObject jObject = null;
jObject = new JSONObject(mConfiguration);
mConfigurationName = (jObject.getString(mGreenbox_internal_sharing));
if (mConfigurationName.equalsIgnoreCase("false"))
{
popupMenu.getMenu().removeItem(R.id.share_folder_popup_menu);
}
/* else
{
popupMenu.getMenu().add(1,R.id.share_folder_popup_menu,3,"Share");
}*/
} catch (JSONException e) {
e.printStackTrace();
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId())
{
case R.id.share_folder_popup_menu:
try {
AppConstants.isFolder = true;
mObjectId = mAllFolderList.getId();
SessionManager.setObjectID(mActivity, mObjectId);
mFolderName = mArrFolderListModel.get(position).getTagName();
FolderName = mActivity.getSharedPreferences(PREFS_FOLDER_NAME,
MODE_PRIVATE).edit();
FolderName.putString("FolderName", mFolderName);
FolderName.apply();
mClickListener.onShareToFolderTagMainList(position, mArrFolderListModel);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.copy_link_folder_popup_menu:
try {
mClickListener.onCopyLinkToFolderTagMainList(position, mArrFolderListModel);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.move_to_folder_popup_menu:
try {
AppConstants.isMove = true;
AppConstants.isFolder = true;
MainTagId = mActivity.getSharedPreferences(PREFS_MAIN_TAG_ID, MODE_PRIVATE);
mParentTagId = MainTagId.getString("MainTagId", null);
SourceId = mActivity.getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit();
SourceId.putInt("SourceId", Integer.parseInt(mParentTagId));
SourceId.apply();
mObjectId = mAllFolderList.getId();
SessionManager.setObjectID(mActivity, mObjectId);
Common.insertLog("Object Id " + mObjectId);
mClickListener.onMoveToFolderTagMainList(position, mArrFolderListModel);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.rename_folder_popup_menu:
try {
mFolderId = mArrFolderListModel.get(position).getId();
FolderId = mActivity.getSharedPreferences(PREFS_FOLDER_ID, Context.MODE_PRIVATE).edit();
FolderId.putString("FolderId", mFolderId);
FolderId.apply();
mRefId = mArrFolderListModel.get(position).getRefId();
RefId = mActivity.getSharedPreferences(PREFS_REFID, Context.MODE_PRIVATE).edit();
RefId.putString("RefId", mRefId);
RefId.apply();
mClickListener.onRenameToFolderTagMainList(position, mArrFolderListModel);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.view_details_folder_popup_menu:
try {
//Save File Details TO Shared Preference
mCreatedBy = mArrFolderListModel.get(position).getCreatedByName();
CreatedByFolder = mActivity.getSharedPreferences
(PREFS_CREATED_BY_FOLDER, MODE_PRIVATE).edit();
CreatedByFolder.putString("createdByFolder", mCreatedBy);
CreatedByFolder.apply();
CreatedOnFolder = mActivity.getSharedPreferences
(PREFS_CREATED_ON_FOLDER, MODE_PRIVATE).edit();
CreatedOnFolder.putString("createdOnFolder", mCreatedOn);
CreatedOnFolder.apply();
mFolderId = mArrFolderListModel.get(position).getId();
FolderId = mActivity.getSharedPreferences(PREFS_FOLDER_ID, Context.MODE_PRIVATE).edit();
FolderId.putString("FolderId", mFolderId);
FolderId.apply();
Intent intent = new Intent(mActivity, ViewFoldersDetailsActivity.class);
mActivity.startActivity(intent);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.copy_to_folder_popup_menu:
try {
AppConstants.isCopy = true;
AppConstants.isFolder = true;
MainTagId = mActivity.getSharedPreferences(PREFS_MAIN_TAG_ID, MODE_PRIVATE);
mParentTagId = MainTagId.getString("MainTagId", null);
SourceId = mActivity.getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit();
SourceId.putInt("SourceId", Integer.parseInt(mParentTagId));
SourceId.apply();
mObjectId = mAllFolderList.getId();
SessionManager.setObjectID(mActivity, mObjectId);
Common.insertLog("Object Id " + mObjectId);
mClickListener.onCopyToFolderTagMainList(position, mArrFolderListModel);
mActivity.overridePendingTransition(R.anim.fab_slide_out_to_left, Integer.parseInt(null));
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
case R.id.remove_folder_popup_menu:
try {
mID = mAllFolderList.getId();
SessionManager.setFolderID(mActivity, mID);
callRemoveTagAPI(position);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
break;
}
return false;
}
});
popupMenu.show();
}
});
}
private void setDataToPreference(ArrayList<FolderListModel> mArrFolderListModel, int position) {
try {
mID = mArrFolderListModel.get(position).getId();
mRefId = mArrFolderListModel.get(position).getRefId();
mParentTagId = mArrFolderListModel.get(position).getId();
mFolderName = mArrFolderListModel.get(position).getTagName();
FolderName = mActivity.getSharedPreferences(PREFS_FOLDER_NAME,
MODE_PRIVATE).edit();
FolderName.putString("FolderName", mFolderName);
FolderName.apply();
SourceId = mActivity.getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit();
SourceId.putInt("SourceId", Integer.parseInt(mParentTagId));
SourceId.apply();
mFolderId = mArrFolderListModel.get(position).getId();
FolderId = mActivity.getSharedPreferences(PREFS_FOLDER_ID, Context.MODE_PRIVATE).edit();
FolderId.putString("FolderId", mFolderId);
FolderId.apply();
RefId = mActivity.getSharedPreferences(PREFS_REFID, Context.MODE_PRIVATE).edit();
RefId.putString("RefId", mRefId);
RefId.apply();
DestId = mActivity.getSharedPreferences(PREFS_FOLDER_DEST_ID, MODE_PRIVATE).edit();
DestId.putInt("DestFolderId", Integer.parseInt(mParentTagId));
DestId.apply();
Common.insertLog("Parent Id::>>>>>" + mParentTagId);
// Common.insertLog("Parent Tag Id " + mParentTagId);
//
SessionManager.setParentTagID(mActivity, mParentTagId);
SessionManager.setRefId(mActivity, mRefId);
SessionManager.setFolderID(mActivity, mID);
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
private void goToNextFragment()
{
try {
FragmentManager fragmentManager;
if (AppConstants.menuClick == true) {
fragmentManager = ((FoldersAndFilesMoveAndCopyToActivity) mActivity).getSupportFragmentManager();
} else {
fragmentManager = ((MainActivity) mActivity).getSupportFragmentManager();
}
//initialization Of Fragments
Fragment folderstagmainfragment = null;
folderstagmainfragment = new FoldersTagMainFragment();
Fragment folderschildtagonefragment = null;
folderschildtagonefragment = new FoldersChildTagOneFragment();
Fragment folderschildtagtwofragment = null;
folderschildtagtwofragment = new FoldersChildTagTwoFragment();
Fragment fileschildtagonefragment = null;
fileschildtagonefragment = new FilesChildTagOneFragment();
if (AppConstants.STR_CURRENT_FOLDER_FRAGMENT == AppConstants
.STR_FOLDER_CONTENT_MAIN_FRAGMENT) {
if (AppConstants.menuClick == true) {
fragmentManager.beginTransaction().add(R.id.frame_activity_folders_move_to,
folderschildtagonefragment, mActivity.getResources().getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources().getString(R.string.back_stack_main_fragment_folder))
.commit();
} else {
fragmentManager.beginTransaction().add(R.id.frame_content_greenbox_main,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources().getString(R.string.back_stack_folder_main))
.commit();
}
} else if (AppConstants.STR_CURRENT_FOLDER_FRAGMENT == AppConstants.STR_FOLDER_CONTENT_ONE_FRAGMENT) {
if (AppConstants.menuClick == true) {
fragmentManager.beginTransaction().add(R.id.frame_activity_folders_move_to,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
} else {
fragmentManager.beginTransaction().add(R.id.frame_content_greenbox_main,
folderschildtagtwofragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
}
} else if (AppConstants.STR_CURRENT_FOLDER_FRAGMENT == AppConstants.STR_FOLDER_CONTENT_TWO_FRAGMENT) {
if (AppConstants.menuClick == true) {
fragmentManager.beginTransaction().add(R.id.frame_activity_folders_move_to,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
} else {
fragmentManager.beginTransaction().add(R.id.frame_content_greenbox_main,
folderschildtagonefragment, mActivity.getResources()
.getString(R.string.tag_folder_main))
.addToBackStack(mActivity.getResources()
.getString(R.string.back_stack_main_fragment_folder))
.commit();
}
}
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
public static class CustomViewHolder extends RecyclerView.ViewHolder
{
private TextView mTextFolderName, mTextFolderOwnerName;
private LinearLayout mLinearRowFolderList,mLinearRowFolderListMenuImage;
public CustomViewHolder(View view)
{
super(view);
mTextFolderName = (TextView) view.findViewById(R.id.text_row_folder_list_name);
mTextFolderOwnerName = (TextView) view.findViewById(R.id.text_row_folder_list_owner_name);
mLinearRowFolderList = (LinearLayout) view.findViewById(R.id.linear_row_folder_list);
mLinearRowFolderListMenuImage = (LinearLayout) view.findViewById(R.id.linear_row_folder_list_menu_image);
if(AppConstants.menuClick==true)
{
mLinearRowFolderListMenuImage.setVisibility(View.GONE);
}
}
}
/*
This Mehtod Sould Remove Item
*/
public void removeItem(int position)
{
mArrFolderListModel.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, mArrFolderListModel.size());
}
/*
This Method Will Call Remove API
*/
private void callRemoveTagAPI(final int position)
{
try
{
if (ConnectivityDetector.IS_INTERNET_AVAILABLE(mActivity))
{
new OkHTTPCallBackGetJsonObjectRemoveFolderOrFile(mActivity, AppConstants
.API_REMOVE_TAG_FOLDER, WebFields.REMOVE_TAG.MODE, AppConstants.intFlagShow,
new OnUpdateListenerJsonObject()
{
@Override
public void onUpdateComplete(JSONObject jsonObject, boolean isSuccess)
{
if (isSuccess)
{
removeItem(position);
mClickListener.onRemoveFolderTagMainList(position, mArrFolderListModel);
}
else
{
try
{
SnackBarAlertDialog.SUCCESS(mActivity,
jsonObject.getString(AppConstants.STR_FOLDER_REMOVED_ERROR));
} catch (JSONException exception)
{
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
}
}).execute();
}
else
{
SnackBarAlertDialog.ERROR(mActivity, AppConstants.STR_INETRNET_ALERT_MESSAGE);
}
} catch (Exception exception) {
Common.exceptionPrintStackTrace(mActivity, AppConstants.STR_EXCEPTION, exception);
}
}
}
Comments
Post a Comment