diff --git a/Soft1614080902103/app/src/main/AndroidManifest.xml b/Soft1614080902103/app/src/main/AndroidManifest.xml index 51f2c1392..71a28e140 100644 --- a/Soft1614080902103/app/src/main/AndroidManifest.xml +++ b/Soft1614080902103/app/src/main/AndroidManifest.xml @@ -1,15 +1,7 @@ + package="androidlabs.hzuapps.edu.soft1614080902103"> - - - - - - - - - + + \ No newline at end of file diff --git a/Soft1614080902103/app/src/main/java/edu/hzuapps/androidlabs/myapplication/MainActivity.java b/Soft1614080902103/app/src/main/java/edu/hzuapps/androidlabs/myapplication/MainActivity.java deleted file mode 100644 index 30b554660..000000000 --- a/Soft1614080902103/app/src/main/java/edu/hzuapps/androidlabs/myapplication/MainActivity.java +++ /dev/null @@ -1,171 +0,0 @@ -package edu.hzuapps.androidlabs.myapplication; - -import android.annotation.SuppressLint; -import android.app.ProgressDialog; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.os.Environment; -import android.os.Handler; -import android.os.Message; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.Toast; - -import java.io.BufferedOutputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; - -public class MainActivity extends AppCompatActivity { - - private final static String TAG = "soft1614080902103MainActivity"; - private final static String ALBUM_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/download_test/"; - private ImageView mImageView; - private Button mBtnSave; - private Button mBtnRead; - private ProgressDialog mSaveDialog = null; - private Bitmap mBitmap; - private String mFileName; - private String mSaveMessage; - private EditText editText; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - mImageView = (ImageView)findViewById(R.id.imageView); - mBtnSave = (Button)findViewById(R.id.button2); - editText = (EditText)findViewById(R.id.url); - - mBtnSave.setOnClickListener(new Button.OnClickListener(){ - public void onClick(View v) { - new Thread(connectNet).start(); - mSaveDialog = ProgressDialog.show(MainActivity.this, "保存图片", "图片正在保存中,请稍等...", true); - new Thread(saveFileRunnable.get()).start(); - } - }); - } - public byte[] getImage(String path) throws Exception{ - URL url = new URL(path); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setConnectTimeout(5 * 1000); - conn.setRequestMethod("GET"); - InputStream inStream = conn.getInputStream(); - if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){ - return readStream(inStream); - } - return null; - } - - - public InputStream getImageStream(String path) throws Exception{ - URL url = new URL(path); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setConnectTimeout(5 * 1000); - conn.setRequestMethod("GET"); - if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){ - return conn.getInputStream(); - } - return null; - } - - public static byte[] readStream(InputStream inStream) throws Exception{ - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int len = 0; - while( (len=inStream.read(buffer)) != -1){ - outStream.write(buffer, 0, len); - } - outStream.close(); - inStream.close(); - return outStream.toByteArray(); - } - public void saveFile(Bitmap bm, String fileName) throws IOException { - File dirFile = new File(ALBUM_PATH); - if(!dirFile.exists()){ - dirFile.mkdir(); - } - File myCaptureFile = new File(ALBUM_PATH + fileName); - BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile)); - bm.compress(Bitmap.CompressFormat.JPEG, 80, bos); - bos.flush(); - bos.close(); - } - - private final ThreadLocal saveFileRunnable = new ThreadLocal() { - @Override - protected Runnable initialValue() { - return new Runnable() { - @Override - public void run() { - try { - saveFile(mBitmap, mFileName); - mSaveMessage = "图片保存成功!"; - } catch (IOException e) { - mSaveMessage = "图片保存失败!"; - e.printStackTrace(); - } - messageHandler.sendMessage(messageHandler.obtainMessage()); - } - - }; - } - }; - private Handler messageHandler = new Handler() { - @SuppressLint("LongLogTag") - @Override - public void handleMessage(Message msg) { - mSaveDialog.dismiss(); - Log.d(TAG, mSaveMessage); - Toast.makeText(MainActivity.this, mSaveMessage, Toast.LENGTH_SHORT).show(); - } - }; - - /* - * 连接网络 - */ - private Runnable connectNet = new Runnable(){ - @SuppressLint({"LongLogTag", "WrongConstant"}) - @Override - public void run() { - try { - String Url=editText.getText().toString(); - mFileName = "test.jpg"; - byte[] data = getImage(Url); - if(data!=null){ - mBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);// bitmap - }else{ - Toast.makeText(MainActivity.this, "Image error!", 1).show(); - } - // 发送消息,通知handler在主线程中更新UI - connectHanlder.sendEmptyMessage(0); - Log.d(TAG, "set image ..."); - } catch (Exception e) { - Toast.makeText(MainActivity.this,"无法链接网络!", 1).show(); - e.printStackTrace(); - } - - } - - }; - - private Handler connectHanlder = new Handler() { - @SuppressLint("LongLogTag") - @Override - public void handleMessage(Message msg) { - Log.d(TAG, "display image"); - // 更新UI,显示图片 - if (mBitmap != null) { - mImageView.setImageBitmap(mBitmap);// display image - } - } - }; -} diff --git a/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/SecondActivity.java b/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/SecondActivity.java deleted file mode 100644 index 94bd269ca..000000000 --- a/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/SecondActivity.java +++ /dev/null @@ -1,116 +0,0 @@ - -package edu.hzuapps.appforjiaxing; - -import android.content.Context; -import android.os.Build; -import android.os.Bundle; -import android.os.Environment; -import android.support.annotation.RequiresApi; -//import android.support.design.widget.FloatingActionButton; -//import android.support.design.widget.Snackbar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.util.Log; -import android.widget.ListView; -import android.widget.ArrayAdapter; - - -import java.io.File; -import java.io.FileWriter; -import java.io.FileReader; -import java.io.BufferedReader; -import java.io.IOException; -import java.util.LinkedList; - -public class SecondActivity extends AppCompatActivity { - - private final String TAG = SecondActivity.class.getSimpleName(); - private Context mContext; - - @RequiresApi(api = Build.VERSION_CODES.FROYO) - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_second); - - //根据id找到事先声明好的listview - ListView listView = (ListView) findViewById(R.id.lvSongs ); - - //定义一个数组,存放列表的项 - String[] names={"张三","李四","王五","赵六","田七"}; - - //定义adapter (适配器), 搭建listview和数据的通路 - //第一个参数是当前的activity,第二个参数是列表项的布局,android.R.layout.simple_list_item_1 是android自带的一个简单的布局,只有一个文本框,这里直接拿来使用 - //第三个参数是含有数据的数组,用来填充列表项的布局 - ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,names); - - //为listview设置adapter - listView.setAdapter(arrayAdapter); - - saveData(names); - - String[] anotherNames = readData(); - // do something - } - - @RequiresApi(api = Build.VERSION_CODES.FROYO) - public void saveData(String[] data){ - // 获取需要写入的文件 - File f = new File("/mnt/sdcard","data.txt"); - try{ - FileWriter writer = new FileWriter(f); - for(int i=0;i list = new LinkedList<>(); - File f = new File("/mnt/sdcard","data.txt"); - try{ - FileReader reader = new FileReader(f); - BufferedReader br = new BufferedReader(reader); - String temp; - while( (temp=br.readLine())!=null){ - list.add(temp); - } - }catch (IOException e){ - } - String[] result = new String[list.size()]; - list.toArray(result); - return result; - } - /* Checks if external storage is available for read and write */ - private boolean isExternalStorageWritable() { - String state = Environment.getExternalStorageState(); - if (Environment.MEDIA_MOUNTED.equals(state)) { - return true; - } - return false; - } - - /* Checks if external storage is available to at least read */ - private boolean isExternalStorageReadable() { - String state = Environment.getExternalStorageState(); - if (Environment.MEDIA_MOUNTED.equals(state) || - Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { - return true; - } - return false; - } - - @RequiresApi(api = Build.VERSION_CODES.FROYO) - private File getPrivateExtStorageDir(String dirName) { - File file = new File(mContext.getExternalFilesDir(null), dirName); - if (!file.mkdirs()) { - Log.e(TAG, "目录无法创建!"); - } - return file; - } -} \ No newline at end of file diff --git a/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/Soft1614080902103Activity.java b/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/Soft1614080902103Activity.java deleted file mode 100644 index 0afa1654c..000000000 --- a/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/Soft1614080902103Activity.java +++ /dev/null @@ -1,31 +0,0 @@ -package edu.hzuapps.appforjiaxing; - -import android.content.Intent; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; -import org.w3c.dom.Text; - -public class Soft1614080902103Activity extends AppCompatActivity { - private TextView textView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_soft1614080902103); - - textView=(TextView)findViewById(R.id.musicplayer); - - textView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent=new Intent(Soft1614080902103Activity.this,SecondActivity.class); - startActivity(intent); - } - }); - - - - } -} \ No newline at end of file diff --git a/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/SongItem.java b/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/SongItem.java deleted file mode 100644 index 7a7eef4ac..000000000 --- a/Soft1614080902103/app/src/main/java/edu/hzuapps/appforjiaxing/SongItem.java +++ /dev/null @@ -1,4 +0,0 @@ -package edu.hzuapps.appforjiaxing; - -class SongItem { -} diff --git a/Soft1614080902103/app/src/main/res/drawable/ic_launcher_background.xml b/Soft1614080902103/app/src/main/res/drawable/ic_launcher_background.xml index d5fccc538..3a37cf6d0 100644 --- a/Soft1614080902103/app/src/main/res/drawable/ic_launcher_background.xml +++ b/Soft1614080902103/app/src/main/res/drawable/ic_launcher_background.xml @@ -1,170 +1,170 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Soft1614080902103/app/src/main/res/drawable/musicplayer.png b/Soft1614080902103/app/src/main/res/drawable/musicplayer.png deleted file mode 100644 index 26d1f6b6e..000000000 Binary files a/Soft1614080902103/app/src/main/res/drawable/musicplayer.png and /dev/null differ diff --git a/Soft1614080902103/app/src/main/res/drawable/next.jpg b/Soft1614080902103/app/src/main/res/drawable/next.jpg deleted file mode 100644 index 526f86668..000000000 Binary files a/Soft1614080902103/app/src/main/res/drawable/next.jpg and /dev/null differ diff --git a/Soft1614080902103/app/src/main/res/drawable/photo.jpeg b/Soft1614080902103/app/src/main/res/drawable/photo.jpeg deleted file mode 100644 index df630587c..000000000 Binary files a/Soft1614080902103/app/src/main/res/drawable/photo.jpeg and /dev/null differ diff --git a/Soft1614080902103/app/src/main/res/drawable/picture.jpeg b/Soft1614080902103/app/src/main/res/drawable/picture.jpeg deleted file mode 100644 index d5033f31e..000000000 Binary files a/Soft1614080902103/app/src/main/res/drawable/picture.jpeg and /dev/null differ diff --git a/Soft1614080902103/app/src/main/res/drawable/progressbar.jpg b/Soft1614080902103/app/src/main/res/drawable/progressbar.jpg deleted file mode 100644 index 2a3a6afe1..000000000 Binary files a/Soft1614080902103/app/src/main/res/drawable/progressbar.jpg and /dev/null differ diff --git a/Soft1614080902103/app/src/main/res/drawable/stop.jpg b/Soft1614080902103/app/src/main/res/drawable/stop.jpg deleted file mode 100644 index 3fccd3b42..000000000 Binary files a/Soft1614080902103/app/src/main/res/drawable/stop.jpg and /dev/null differ diff --git a/Soft1614080902103/app/src/main/res/drawable/timg.jpg b/Soft1614080902103/app/src/main/res/drawable/timg.jpg deleted file mode 100644 index 875a5ff1f..000000000 Binary files a/Soft1614080902103/app/src/main/res/drawable/timg.jpg and /dev/null differ diff --git a/Soft1614080902103/app/src/main/res/layout/activity_main.xml b/Soft1614080902103/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 0e6bf4a31..000000000 --- a/Soft1614080902103/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - -