Back to project page openMusicTagger-Android.
The source code is released under:
GNU General Public License
If you think the Android project openMusicTagger-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.amethystAnt.openmusictagger; //from w ww. ja v a 2 s . c o m import java.io.File; import java.util.ArrayList; import android.support.v7.app.ActionBarActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.graphics.drawable.Drawable; public class MainActivity extends ActionBarActivity { private Button dialogButton; private EditText path; private PicturePathEditor picturePath; private ImageView cover; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dialogButton = (Button) findViewById(R.id.button2); path = (EditText) findViewById(R.id.editText1); picturePath = (PicturePathEditor) findViewById(R.id.editText3); cover = (ImageView) findViewById(R.id.imageView1); dialogButton.setOnClickListener(new DialogOnClickListener(this, path)); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @SuppressWarnings("unchecked") @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == 0 && resultCode == RESULT_OK){ ArrayList<File> files = (ArrayList<File>) data.getSerializableExtra("upload"); setPaths(files); } } private void setPaths(ArrayList<File> files) { String paths = ""; char[] comma = {'"'}; String sComma = String.copyValueOf(comma); if(files.size() == 1) { paths = files.get(0).getAbsolutePath(); } else if(files.size() > 1) { int i = 0; while(i < files.size()) { paths = paths + sComma + files.get(i).getAbsolutePath() + sComma + "; "; i++; } } path.setText(paths); } } class PicturePathEditor extends EditText { private ImageView image; public PicturePathEditor(Context context, ImageView image) { super(context); this.image = image; } @Override public void setText(CharSequence text, BufferType type) { super.setText(text, BufferType.EDITABLE); Drawable d = Drawable.createFromPath(text.toString()); image.setImageDrawable(d); } }