Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LoginActivity.java:
- btnGallery.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- AlertDialog.Builder alertdialog = new AlertDialog.Builder(LoginActivity.this);
- alertdialog.setTitle(getResources().getString(R.string.app_name));
- alertdialog.setMessage("No Images found in UploadActivity");
- alertdialog.setPositiveButton("OK", new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int which) {
- finish(); //Finish your UploadActivity here.
- }
- });
- alertdialog.show();
- }
- });
- UploadActivity.java:-
- public class UploadActivity extends Activity {
- final private static int DIALOG_LOGIN = 1;
- EditText editPersonName, editPersonaEmail, editPersonTelephone, parental_email ;
- TextView editImageName ;
- String fileName;
- static ListView lstView;
- private Handler handler = new Handler();;
- static List <String> ImageList;
- String strPath;
- CheckBox chkOption3;
- TextView tv1, tv2;
- CheckBox chkOption1, chkOption2 ;
- int position ;
- static File f1;
- static String folder = null ;
- Intent i;
- Intent intent ;
- TextView textHeading1;
- static File[] files;
- static File file ;
- static List <String> it ;
- static String textHeading = null;
- // new Class DB
- final myDBClasss myDb = new myDBClasss(this);
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_upload);
- textHeading1 = (TextView) findViewById(R.id.txtEventNameDate1);
- textHeading1.setText(CameraLauncherActivity.folder);
- final ImageButton buttonBack = (ImageButton) findViewById(R.id.back_btn);
- buttonBack.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // Perform action on click
- CameraLauncherActivity.isReturning = true;
- i = new Intent(getApplicationContext(), CameraLauncherActivity.class);
- i.putExtra("folder_name", CameraLauncherActivity.folder);
- i.putExtra("isReturning", true);
- startActivity(i);
- }
- });
- ImageButton buttonSync = (ImageButton) findViewById(R.id.sync_btn);
- buttonSync.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- // TODO Auto-generated method stub
- for(int i=0; i<lstView.getChildCount(); i++)
- {
- startUpload(i);
- }
- }
- });
- /*** Get Images from SDCard ***/
- ImageList = getSD();
- // ListView and imageAdapter
- lstView = (ListView) findViewById(R.id.listView1);
- lstView.setAdapter(new ImageAdapter(this));
- }
- public static List <String> getSD()
- {
- it = new ArrayList <String>();
- String string = "/mnt/sdcard/Pictures/Awesome/";
- f1 = new File (string+ CameraLauncherActivity.folder+ "/");
- files = f1.listFiles ();
- for (int i = 0; i < files.length; i++)
- {
- file = files[i];
- Log.d("Count",file.getPath());
- it.add (file.getPath());
- }
- return it;
- }
- public class ImageAdapter extends BaseAdapter
- {
- private Context context;
- public ImageAdapter(Context c)
- {
- // TODO Auto-generated method stub
- context = c;
- }
- public int getCount() {
- // TODO Auto-generated method stub
- return ImageList.size();
- }
- public Object getItem(int position) {
- // TODO Auto-generated method stub
- return position;
- }
- public long getItemId(int position) {
- // TODO Auto-generated method stub
- return position;
- }
- public View getView(final int position, View convertView, ViewGroup parent) {
- // TODO Auto-generated method stub
- LayoutInflater inflater = (LayoutInflater) context
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- if (convertView == null) {
- convertView = inflater.inflate(R.layout.list_upload, null);
- }
- // ColImgName
- TextView txtName = (TextView) convertView.findViewById(R.id.ColImgName);
- strPath = ImageList.get(position).toString();
- // Get File Name
- fileName = strPath.substring( strPath.lastIndexOf('/')+1, strPath.length() );
- file = new File(strPath);
- @SuppressWarnings("unused")
- long length = file.length();
- txtName.setText(fileName);
- // Image Resource
- ImageView imageView = (ImageView) convertView.findViewById(R.id.ColImgPath);
- final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inSampleSize = 8;
- Bitmap bm = BitmapFactory.decodeFile(strPath,options);
- imageView.setImageBitmap(bm);
- // ColStatus
- final ImageView txtStatus = (ImageView) convertView.findViewById(R.id.ColStatus);
- txtStatus.setImageResource(R.drawable.bullet_button);
- // progressBar
- final ProgressBar progress = (ProgressBar) convertView.findViewById(R.id.progressBar);
- progress.setVisibility(View.GONE);
- //btnUpload
- final ImageButton btnUpload = (ImageButton) convertView.findViewById(R.id.btnUpload);
- btnUpload.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // Upload
- btnUpload.setEnabled(false);
- startUpload(position);
- }
- });
- return convertView;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement