Guest User

Untitled

a guest
Jul 5th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.08 KB | None | 0 0
  1. package ru.kurganec.vk.messenger.ui.fragments;
  2.  
  3. import android.app.Activity;
  4. import android.content.ContentValues;
  5. import android.content.Intent;
  6. import android.database.Cursor;
  7. import android.graphics.Bitmap;
  8. import android.graphics.BitmapFactory;
  9. import android.net.Uri;
  10. import android.os.AsyncTask;
  11. import android.os.Bundle;
  12. import android.provider.MediaStore;
  13. import android.support.v4.app.FragmentManager;
  14. import android.support.v4.app.FragmentTransaction;
  15. import android.text.Editable;
  16. import android.util.Log;
  17. import android.util.SparseBooleanArray;
  18. import android.view.LayoutInflater;
  19. import android.view.MotionEvent;
  20. import android.view.View;
  21. import android.view.ViewGroup;
  22. import android.widget.*;
  23. import ru.kurganec.vk.messenger.R;
  24. import ru.kurganec.vk.messenger.model.ImageDownloader;
  25. import ru.kurganec.vk.messenger.model.VK;
  26. import ru.kurganec.vk.messenger.model.VKDatabase;
  27. import ru.kurganec.vk.messenger.model.classes.VKMessage;
  28. import ru.kurganec.vk.messenger.model.classes.VKProfile;
  29. import ru.kurganec.vk.messenger.ui.CompanionPickerActivity;
  30. import ru.kurganec.vk.messenger.ui.LocationPickerActivity;
  31. import ru.kurganec.vk.messenger.ui.SingleDialogActivity;
  32. import ru.kurganec.vk.messenger.ui.helper.AttachPopUp;
  33. import ru.kurganec.vk.messenger.ui.helper.BaseVKFragment;
  34. import ru.kurganec.vk.messenger.ui.helper.VKImageButton;
  35. import ru.kurganec.vk.messenger.ui.helper.VKImageView;
  36. import ru.kurganec.vk.messenger.ui.helper.adapters.HistoryAdapter;
  37. import ru.kurganec.vk.messenger.utils.BaseActionsObserver;
  38. import ru.kurganec.vk.messenger.utils.EmptyTextWatcher;
  39.  
  40. import java.util.ArrayList;
  41. import java.util.HashMap;
  42. import java.util.List;
  43.  
  44. /**
  45.  * User: anatoly
  46.  * Date: 19.06.12
  47.  * Time: 15:19
  48.  */
  49. public class SingleDialogFragment extends BaseVKFragment implements AttachPopUp.AttachActionListener,
  50.         BaseVKFragment.Updatable {
  51.     private static final int REQUEST_CAMERA_CAPTURE = 1;
  52.     private static final int REQUEST_PICK_FROM_GALLERY = 2;
  53.     private static final int REQUEST_PICK_LOCATION = 3;
  54.  
  55.     private VKProfile mProfile;
  56.     DialogObserver mObserver = new DialogObserver();
  57.     HistoryAdapter mAdapter;
  58.     ListView mList;
  59.     EditText mInput;
  60.     TextView footerUserIsTyping;
  61.     AttachPopUp mAttachWindow;
  62.     private Uri mImageUri;
  63.     private AttachHandler mAttachHandler;
  64.  
  65.     FrameLayout navigation;
  66.  
  67.     @Override
  68.     public void onCreate(Bundle savedInstanceState) {
  69.         super.onCreate(savedInstanceState);
  70.         Bundle args = getArguments();
  71.         long profileUID = getArguments().getLong(SingleDialogActivity.EXTRA_PROFILE_UID);
  72.         mProfile = VK.db().getProfile(profileUID);
  73.         if (mProfile == null) {
  74.             getActivity().finish();
  75.             return;
  76.         }
  77.         List<VKMessage> hist = VK.db().getProfileHistory(mProfile.getUid(), VKDatabase.FROM_INF);
  78.         mAdapter = new HistoryAdapter(getActivity(), hist);
  79.     }
  80.  
  81.     @Override
  82.     public void onResume() {
  83.         super.onResume();
  84.         List<VKMessage> hist = VK.db().getProfileHistory(mProfile.getUid(), VKDatabase.FROM_INF);
  85.         if (hist.size() < 15) {
  86.             VK.actions().getProfileHistory(mProfile.getUid(), 20, 0);
  87.         }
  88.         mAdapter.setData(hist);
  89.         VK.actions().registerObserver(mObserver);
  90.     }
  91.  
  92.     @Override
  93.     public void onPause() {
  94.         VK.actions().unRegisterObserver(mObserver);
  95.         super.onPause();
  96.     }
  97.  
  98.     @Override
  99.     public void onDestroy() {
  100.         super.onDestroy();
  101.  
  102.         mObserver = null;
  103.     }
  104.  
  105.  
  106.     @Override
  107.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  108.         View root = inflater.inflate(R.layout.fragment_single_dialog, container, false);
  109.         TextView v = (TextView) root.findViewById(R.id.text_name);
  110.         v.setText(mProfile.getLastName() + " " + mProfile.getFirstName());
  111.  
  112.         mList = (ListView) root.findViewById(R.id.list_history);
  113.         mList.setAdapter(mAdapter);
  114.         mList.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_NORMAL);
  115.         mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
  116.         mList.setItemsCanFocus(false);
  117.  
  118.         mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  119.             @Override
  120.             public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
  121.                 handleMessageSelection();
  122.             }
  123.         });
  124.  
  125.         mList.setOnTouchListener(new View.OnTouchListener() {
  126.             @Override
  127.             public boolean onTouch(View view, MotionEvent motionEvent) {
  128.                 return false;
  129.             }
  130.         });
  131.  
  132.         mList.setOnScrollListener(new AbsListView.OnScrollListener() {
  133.             int currentState;
  134.  
  135.             @Override
  136.             public void onScrollStateChanged(AbsListView absListView, int state) {
  137.                 currentState = state;
  138.             }
  139.  
  140.             @Override
  141.             public void onScroll(AbsListView absListView, int firstVisible, int countVisible, int allCount) {
  142.                 if (currentState != SCROLL_STATE_FLING) {
  143.                     ArrayList<VKMessage> unread = new ArrayList<VKMessage>();
  144.                     for (int position = firstVisible; position < firstVisible + countVisible; ++position) {
  145.                         VKMessage msg = (VKMessage) mAdapter.getItem(position);
  146.                         if (msg.getReadState() == VKMessage.UNREAD && msg.getOutState() == VKMessage.IN) {
  147.                             unread.add(msg);
  148.                         }
  149.                     }
  150.                     if (unread.size() > 0) {
  151.                         VK.actions().markAsRead(unread);
  152.                     }
  153.                 }
  154.             }
  155.         });
  156.  
  157.  
  158.         footerUserIsTyping = (TextView) root.findViewById(R.id.text_user_typing);
  159.  
  160.         Button backButton = (Button) root.findViewById(R.id.btn_back);
  161.         backButton.setOnClickListener(new View.OnClickListener() {
  162.             @Override
  163.             public void onClick(View view) {
  164.                 getActivity().finish();
  165.  
  166.             }
  167.         });
  168.  
  169.         mInput = (EditText) root.findViewById(R.id.input_msg);
  170.         mInput.addTextChangedListener(new EmptyTextWatcher() {
  171.             @Override
  172.             public void afterTextChanged(Editable editable) {
  173.                 if (editable.length() % 7 == 0 || editable.length() == 1) {
  174.                     VK.actions().iAmTyping(mProfile.getUid());
  175.                 }
  176.             }
  177.         });
  178.  
  179.         Button btn = (Button) root.findViewById(R.id.btn_send);
  180.         btn.setOnClickListener(new View.OnClickListener() {
  181.             @Override
  182.             public void onClick(View view) {
  183.  
  184.                 VK.actions().sendMessage(mProfile.getUid(),
  185.                         mInput.getText().toString(),
  186.                         mAttachHandler.getFileNames(),
  187.                         mAttachHandler.getForward(),
  188.                         mAttachHandler.getLatitude(),
  189.                         mAttachHandler.getLongitude()
  190.                 );
  191.                 mInput.setText("");
  192.                 mAttachHandler.clear();
  193.  
  194.             }
  195.         });
  196.  
  197.         VKImageView avatar = (VKImageView) root.findViewById(R.id.ic_avatar);
  198.         avatar.setURI(mProfile.getPhoto());
  199.  
  200.         mAttachWindow = AttachPopUp.build(getActivity());
  201.         mAttachWindow.setAttachListener(SingleDialogFragment.this);
  202.  
  203.         final Button btnAttach = (Button) root.findViewById(R.id.btn_attach);
  204.         btnAttach.setOnClickListener(new View.OnClickListener() {
  205.             @Override
  206.             public void onClick(View view) {
  207.                 if (mAttachHandler.shown()) {
  208.                     mAttachHandler.hide();
  209.                 } else {
  210.                     if (mAttachHandler.empty()) {
  211.                         if (!mAttachWindow.isShowing()) {
  212.                             mAttachWindow.show();
  213.                         }
  214.                     } else {
  215.                         mAttachHandler.show();
  216.                     }
  217.                 }
  218.  
  219.             }
  220.         });
  221.  
  222.         FrameLayout wrapper = (FrameLayout) root.findViewById(R.id.attach_wrapper);
  223.         mAttachHandler = new AttachHandler(wrapper);
  224.  
  225.         if (getArguments().containsKey(CompanionPickerActivity.EXTRA_MIDS_TO_FORWARD)){
  226.             mAttachHandler.handleForward(getArguments().getString(CompanionPickerActivity.EXTRA_MIDS_TO_FORWARD));
  227.         }
  228.         return root;
  229.     }
  230.  
  231.     private MessagesActionFragment mMessageActions = new MessagesActionFragment();
  232.     private int previousCount = 0;
  233.  
  234.     private void handleMessageSelection() {
  235.         SparseBooleanArray arr = mList.getCheckedItemPositions();
  236.         int count = 0;
  237.         List<VKMessage> selected = new ArrayList<VKMessage>();
  238.         for (int i = 0; i < arr.size(); ++i) {
  239.             int key = arr.keyAt(i);
  240.  
  241.             if (arr.get(key)) {
  242.                 selected.add((VKMessage) mAdapter.getItem(key));
  243.                 count++;
  244.             }
  245.         }
  246.         if (count == 1 && previousCount == 0) {
  247.             FragmentManager manager = getFragmentManager();
  248.             FragmentTransaction t = manager.beginTransaction();
  249.  
  250.             t.replace(R.id.navigation, mMessageActions);
  251.             mMessageActions.pass(selected, this);
  252.  
  253.             t.addToBackStack("selected item");
  254.             t.commit();
  255.         } else if (count == 0) {
  256.             getFragmentManager().popBackStackImmediate();
  257.         } else {
  258.             mMessageActions.pass(selected, this);
  259.         }
  260.         previousCount = count;
  261.     }
  262.  
  263.  
  264.     @Override
  265.     public void onAction(AttachPopUp.Action a) {
  266.         switch (a) {
  267.             case ACTION_GALLERY: {
  268.                 requestGallery();
  269.                 break;
  270.             }
  271.             case ACTION_PHOTO: {
  272.                 requestPhoto();
  273.                 break;
  274.             }
  275.             case ACTION_GEO: {
  276.                 requestGeo();
  277.                 break;
  278.             }
  279.         }
  280.     }
  281.  
  282.     @Override
  283.     public void onActivityResult(int requestCode, int resultCode, Intent data) {
  284.         if (mAttachWindow.isShowing()) {
  285.             mAttachWindow.dismiss();
  286.         }
  287.         if (resultCode == Activity.RESULT_OK) {
  288.             mAttachHandler.show();
  289.             switch (requestCode) {
  290.                 case REQUEST_PICK_FROM_GALLERY: {
  291.                     Uri selectedImage = data.getData();
  292.                     String[] filePathColumn = {MediaStore.Images.Media.DATA};
  293.                     Cursor cursor = getActivity().getContentResolver().
  294.                             query(selectedImage, filePathColumn, null, null, null);
  295.                     cursor.moveToFirst();
  296.                     int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
  297.                     String filePath = cursor.getString(columnIndex);
  298.                     cursor.close();
  299.                     //filePath
  300.                     mAttachHandler.handlePhoto(filePath);
  301.                     break;
  302.                 }
  303.                 case REQUEST_CAMERA_CAPTURE: {
  304.                     Uri selectedImage = mImageUri;
  305.                     String[] filePathColumn = {MediaStore.Images.Media.DATA};
  306.                     Cursor cursor = getActivity().getContentResolver().
  307.                             query(selectedImage, filePathColumn, null, null, null);
  308.                     cursor.moveToFirst();
  309.                     int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
  310.                     String filePath = cursor.getString(columnIndex);
  311.                     cursor.close();
  312.                     //filePath
  313.                     mAttachHandler.handlePhoto(filePath);
  314.                     break;
  315.                 }
  316.                 case REQUEST_PICK_LOCATION: {
  317.                     int lat = data.getIntExtra("latitude", 0);
  318.                     int lon = data.getIntExtra("longitude", 0);
  319.                     mAttachHandler.handleGeo(lat, lon);
  320.                     break;
  321.                 }
  322.             }
  323.         }
  324.  
  325.     }
  326.  
  327.  
  328.     private void requestGallery() {
  329.         Intent takePictureFromGalleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  330.         startActivityForResult(takePictureFromGalleryIntent, REQUEST_PICK_FROM_GALLERY);
  331.     }
  332.  
  333.     private void requestPhoto() {
  334.         ContentValues values = new ContentValues();
  335.         mImageUri = getActivity().
  336.                 getContentResolver().
  337.                 insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
  338.         Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  339.         takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
  340.         startActivityForResult(takePictureIntent, REQUEST_CAMERA_CAPTURE);
  341.     }
  342.  
  343.     private void requestGeo() {
  344.         Intent i = new Intent(getActivity(), LocationPickerActivity.class);
  345.         startActivityForResult(i, REQUEST_PICK_LOCATION);
  346.     }
  347.  
  348.  
  349.     @Override
  350.     public void update() {
  351.         List<VKMessage> hist = VK.db().
  352.                 getProfileHistory(mProfile.getUid(),
  353.                         mAdapter.getCount() > 0 ? ((VKMessage) mAdapter.getItem(0)).getMid() : VKDatabase.FROM_INF);
  354.         mAdapter.setData(hist);
  355.         mList.clearChoices();//TODO does not work!!!
  356.         previousCount = 0;
  357.  
  358.     }
  359.  
  360.     private class DialogObserver extends BaseActionsObserver {
  361.         @Override
  362.         public void historyUpdated(long profileUID) {
  363.             if (profileUID == mProfile.getUid()) {
  364.                 List<VKMessage> hist = VK.db().getProfileHistory(profileUID, VKDatabase.FROM_INF);
  365.                 mAdapter.setData(hist);
  366.             }
  367.  
  368.         }
  369.  
  370.         @Override
  371.         public void messageChanged(long uid) {
  372.             if (uid == mProfile.getUid()) {
  373.                 List<VKMessage> hist = VK.db().
  374.                         getProfileHistory(mProfile.getUid(),
  375.                                 mAdapter.getCount() > 0 ? ((VKMessage) mAdapter.getItem(0)).getMid() : VKDatabase.FROM_INF);
  376.                 mAdapter.setData(hist);
  377.             }
  378.  
  379.         }
  380.  
  381.         private AsyncTask<Void, Void, Void> mStatusUpdater;
  382.  
  383.         @Override
  384.         public void userIsTyping(long uid) {
  385.             if (uid == mProfile.getUid()) {
  386.                 if (mStatusUpdater != null) {
  387.                     mStatusUpdater.cancel(true);
  388.                 }
  389.                 mStatusUpdater = new AsyncTask<Void, Void, Void>() {
  390.                     @Override
  391.                     protected void onPreExecute() {
  392.                         footerUserIsTyping.setText(R.string.user_is_typing);
  393.                     }
  394.  
  395.                     @Override
  396.                     protected Void doInBackground(Void... voids) {
  397.                         try {
  398.                             Thread.sleep(5 * 1000);
  399.                         } catch (InterruptedException e) {
  400.                             Log.d("VKLOL", mProfile + "is typing again");
  401.                         }
  402.                         return null;
  403.                     }
  404.  
  405.                     @Override
  406.                     protected void onPostExecute(Void aVoid) {
  407.                         footerUserIsTyping.setText("");
  408.                     }
  409.                 };
  410.                 mStatusUpdater.execute();
  411.  
  412.  
  413.             }
  414.  
  415.         }
  416.     }
  417.  
  418.  
  419.     private class AttachHandler implements View.OnClickListener {
  420.         public static final int MAX_SIZE = 10;
  421.         private FrameLayout wrapper;
  422.         LinearLayout horizontalListView;
  423.         LayoutInflater inflater;
  424.         ArrayList<String> fileNames = new ArrayList<String>();
  425.         String  forward ;
  426.         Integer latitude;
  427.         Integer longitude;
  428.  
  429.         private FrameLayout attachPhoto;
  430.         private FrameLayout attachGallery;
  431.         private FrameLayout attachGeo;
  432.  
  433.         ImageButton btnGallery;
  434.         ImageButton btnPhoto;
  435.         ImageButton btnGeo;
  436.  
  437.         private boolean geoButtonAttached = true;
  438.         private boolean galleryButtonAttached = true;
  439.         private boolean photoButtonAttached = true;
  440.  
  441.         public AttachHandler(FrameLayout wrapper) {
  442.             this.wrapper = wrapper;
  443.             inflater = LayoutInflater.from(getActivity());
  444.             horizontalListView = (LinearLayout) wrapper.findViewById(R.id.list_attach);
  445.  
  446.             attachGallery = (FrameLayout) inflater.inflate(R.layout.view_btn_attach, null);
  447.             attachPhoto = (FrameLayout) inflater.inflate(R.layout.view_btn_attach, null);
  448.             attachGeo = (FrameLayout) inflater.inflate(R.layout.view_btn_attach, null);
  449.  
  450.             btnGallery = (ImageButton) attachGallery.findViewById(R.id.btn_do_attach);
  451.             btnPhoto = (ImageButton) attachPhoto.findViewById(R.id.btn_do_attach);
  452.             btnGeo = (ImageButton) attachGeo.findViewById(R.id.btn_do_attach);
  453.  
  454.             btnGallery.setBackgroundResource(R.drawable.bg_btn_gallery);
  455.             btnPhoto.setBackgroundResource(R.drawable.bg_btn_photo);
  456.             btnGeo.setBackgroundResource(R.drawable.bg_btn_geo);
  457.  
  458.             btnGallery.setOnClickListener(this);
  459.             btnPhoto.setOnClickListener(this);
  460.             btnGeo.setOnClickListener(this);
  461.             clear();
  462.  
  463.         }
  464.  
  465.         public boolean shown() {
  466.             return wrapper.getVisibility() == View.VISIBLE;
  467.         }
  468.  
  469.         private HashMap<String, View> attaches = new HashMap<String, View>();
  470.  
  471.         void handlePhoto(final String fileName) {
  472.             if (fileNames.contains(fileName)) {
  473.                 return;
  474.             }
  475.             fileNames.add(fileName);
  476.             BitmapFactory.Options options = new BitmapFactory.Options();
  477.             options.inSampleSize = 3;
  478.             Bitmap b = BitmapFactory.decodeFile(fileName, options);
  479.             View newAttach = inflater.inflate(R.layout.view_attached, null);
  480.             ImageButton btn = (ImageButton) newAttach.findViewById(R.id.btn_attached);
  481.             btn.setImageBitmap(b);
  482.  
  483.             ImageButton btnDelete = (ImageButton) newAttach.findViewById(R.id.btn_delete_attach);
  484.             btnDelete.setOnClickListener(new View.OnClickListener() {
  485.                 @Override
  486.                 public void onClick(View view) {
  487.                     removePhoto(fileName);
  488.                 }
  489.             });
  490.  
  491.             horizontalListView.addView(newAttach, 0);
  492.             attaches.put(fileName, newAttach);
  493.             handleMaxSize();
  494.         }
  495.  
  496.         private void handleMaxSize() {
  497.             if (size() >= MAX_SIZE) {
  498.                 if (geoButtonAttached) {
  499.                     horizontalListView.removeView(attachGeo);
  500.                     geoButtonAttached = false;
  501.                 }
  502.                 if (galleryButtonAttached) {
  503.                     horizontalListView.removeView(attachGallery);
  504.                     galleryButtonAttached = false;
  505.                 }
  506.                 if (photoButtonAttached) {
  507.                     horizontalListView.removeView(attachPhoto);
  508.                     photoButtonAttached = false;
  509.                 }
  510.             } else {
  511.                 if (!photoButtonAttached) {
  512.                     int count = horizontalListView.getChildCount();
  513.                     horizontalListView.addView(attachPhoto, count);
  514.                     photoButtonAttached = true;
  515.                 }
  516.                 if (!galleryButtonAttached) {
  517.                     int count = horizontalListView.getChildCount();
  518.                     horizontalListView.addView(attachGallery, count);
  519.                     galleryButtonAttached = true;
  520.                 }
  521.                 if (!geoButtonAttached && latitude == null) {
  522.                     int count = horizontalListView.getChildCount();
  523.                     horizontalListView.addView(attachGeo, count);
  524.                     geoButtonAttached = true;
  525.                 }
  526.             }
  527.         }
  528.  
  529.         private void removePhoto(String fileName) {
  530.             if (fileNames.remove(fileName)) {
  531.                 View v = attaches.get(fileName);
  532.                 horizontalListView.removeView(v);
  533.             } else {
  534.                 Log.e("VKLOL", "FTW removed photo doesnot exist");
  535.             }
  536.             handleMaxSize();
  537.         }
  538.  
  539.         public void clear() {
  540.             hide();
  541.             horizontalListView.removeAllViews();
  542.             fileNames.clear();
  543.             forward = null;
  544.             latitude = null;
  545.             longitude = null;
  546.             horizontalListView.addView(attachPhoto);
  547.             horizontalListView.addView(attachGallery);
  548.             horizontalListView.addView(attachGeo);
  549.  
  550.         }
  551.  
  552.         public void handleGeo(int lat, int lon) {
  553.             latitude = lat;
  554.             longitude = lon;
  555.             View newAttach = inflater.inflate(R.layout.view_attached, null);
  556.             VKImageButton btn = (VKImageButton) newAttach.findViewById(R.id.btn_attached);
  557.             btn.setImageResource(R.drawable.ic_attach_geo);
  558.             btn.setURI(ImageDownloader.getMapPreviewUri(lat, lon, true));
  559.             horizontalListView.addView(newAttach, 0);
  560.             ImageButton btnDelete = (ImageButton) newAttach.findViewById(R.id.btn_delete_attach);
  561.             btnDelete.setOnClickListener(new View.OnClickListener() {
  562.                 @Override
  563.                 public void onClick(View view) {
  564.                     removeGeo();
  565.                 }
  566.             });
  567.  
  568.             attaches.put("geo", newAttach);
  569.  
  570.             horizontalListView.removeView(attachGeo);
  571.             geoButtonAttached = false;
  572.             handleMaxSize();
  573.         }
  574.  
  575.         public void handleForward(String fwd){
  576.             forward = fwd;//TODO ADd here forward icon
  577.             handleMaxSize();
  578.         }
  579.  
  580.  
  581.  
  582.  
  583.         private void removeGeo() {
  584.             latitude = null;
  585.             longitude = null;
  586.             View v = attaches.get("geo");
  587.             horizontalListView.removeView(v);
  588.             int count = horizontalListView.getChildCount();
  589.             horizontalListView.addView(attachGeo, count);
  590.             geoButtonAttached = true;
  591.             handleMaxSize();
  592.         }
  593.  
  594.         public int size() {
  595.             int count = 0;
  596.             count += fileNames.size();
  597.             count += forward!= null  ? 1 : 0;
  598.             if (latitude != null) {
  599.                 count += 1;
  600.             }
  601.             return count;
  602.         }
  603.  
  604.         public void show() {
  605.             wrapper.setVisibility(View.VISIBLE);
  606.         }
  607.  
  608.         public void hide() {
  609.             wrapper.setVisibility(View.GONE);
  610.         }
  611.  
  612.         public boolean empty() {
  613.             return fileNames.size() == 0 && forward != null && latitude == null && longitude == null;
  614.         }
  615.  
  616.  
  617.         public Integer getLongitude() {
  618.             return longitude;
  619.         }
  620.  
  621.         public Integer getLatitude() {
  622.             return latitude;
  623.         }
  624.  
  625.         public String getForward() {
  626.             return forward;
  627.         }
  628.  
  629.         public ArrayList<String> getFileNames() {
  630.             return fileNames;
  631.         }
  632.  
  633.         @Override
  634.         public void onClick(View view) {
  635.             if (view == btnGeo) {
  636.                 requestGeo();
  637.             } else if (view == btnPhoto) {
  638.                 requestPhoto();
  639.             } else {
  640.                 requestGallery();
  641.             }
  642.         }
  643.     }
  644.  
  645.  
  646. }
Advertisement
Add Comment
Please, Sign In to add comment