烦
This commit is contained in:
@@ -2,13 +2,16 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="wesayallright.timemanager">
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||
android:theme="@style/AppTheme"
|
||||
>
|
||||
|
||||
<activity android:name="wesayallright.timemanager.surface.MainActivity">
|
||||
@@ -18,7 +21,8 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
|
||||
</manifest>
|
||||
@@ -3,15 +3,23 @@ package wesayallright.timemanager.InnerLayer.Network;
|
||||
import android.accounts.NetworkErrorException;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by mj on 17-4-16.
|
||||
@@ -153,4 +161,69 @@ public class NetWork {
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
public void POST (String addr, HashMap<String, String> data) {
|
||||
addr = "http://alphamj.cn/timemanager/share.php";
|
||||
try {
|
||||
URL url = new URL(addr);
|
||||
|
||||
|
||||
HttpURLConnection con = (HttpURLConnection)url.openConnection();
|
||||
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
|
||||
|
||||
data.put("user", "super");
|
||||
data.put("count", "10");
|
||||
data.put("startAndEnd","7:00/16:00");
|
||||
data.put("1", "课1/1/7:00/10:00");
|
||||
data.put("2", "课2/2/7:00/8:00");
|
||||
data.put("3", "课3/3/8:00/9:30");
|
||||
data.put("4", "课4/4/7:00/8:00");
|
||||
data.put("5", "课5/5/11:00/13:00");
|
||||
data.put("6", "课6/4/10:00/15:00");
|
||||
data.put("7", "课7/6/7:00/9:00");
|
||||
data.put("8", "课8/7/7:00/8:00");
|
||||
data.put("9", "课9/2/10:00/13:00");
|
||||
data.put("10", "课10/3/10:00/12:00");
|
||||
|
||||
StringBuilder d = new StringBuilder();
|
||||
|
||||
for (Map.Entry<String, String> i : data.entrySet()) {
|
||||
d.append(i.getKey() + "=" + i.getValue() + "&");
|
||||
}
|
||||
|
||||
String sd = new String(d);
|
||||
|
||||
con.setDoOutput(true);
|
||||
con.setDoInput(true);
|
||||
DataOutputStream o = new DataOutputStream(con.getOutputStream());
|
||||
o.writeBytes(sd);
|
||||
o.flush();
|
||||
o.close();
|
||||
|
||||
int responseCode = con.getResponseCode();
|
||||
System.out.println("\nSending 'POST' request to URL : " + url);
|
||||
System.out.println("Post parameters : " + addr);
|
||||
System.out.println("Response Code : " + responseCode);
|
||||
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
|
||||
//打印结果
|
||||
System.out.println(response.toString());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,16 +68,16 @@ public class MainActivity extends AppCompatActivity implements
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
showFragment(ACTIVITIES);
|
||||
showFragment(CALENDAR);
|
||||
|
||||
// 设置程序路径
|
||||
LocalFile.setCwd(getApplicationContext().getFilesDir().getAbsolutePath());
|
||||
Log.i("Path", getApplicationContext().getFilesDir().getAbsolutePath());
|
||||
try {
|
||||
User u = User.signIn("rightID", "rightPassword");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Log.i("Path", getApplicationContext().getFilesDir().getAbsolutePath());
|
||||
// try {
|
||||
// User u = User.signIn("rightID", "rightPassword");
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
Package.dateFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
|
||||
Package.timeFormatter = new SimpleDateFormat("hh:mm", Locale.CHINA);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package wesayallright.timemanager.surface;
|
||||
|
||||
/**
|
||||
* Created by mj on 17-5-2.
|
||||
*
|
||||
* 把view保存成图片
|
||||
*/
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import static android.content.ContentValues.TAG;
|
||||
|
||||
public class SaveViewToImage {
|
||||
|
||||
public SaveViewToImage() {}
|
||||
|
||||
public void save(View v) {
|
||||
// v.setDrawingCacheEnabled(true); // 打开view缓存
|
||||
|
||||
int width = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
|
||||
int height = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
|
||||
v.measure(width, height);
|
||||
int h =v.getMeasuredHeight();
|
||||
int w =v.getMeasuredWidth();
|
||||
|
||||
if (w == 0)
|
||||
Log.e(TAG, "save: w == 0");
|
||||
if (h == 0)
|
||||
Log.e(TAG, "save: h == 0");
|
||||
Bitmap b = Bitmap.createBitmap( w, h, Bitmap.Config.ARGB_8888);
|
||||
Canvas c = new Canvas(b);
|
||||
v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
|
||||
v.draw(c);
|
||||
|
||||
//b = Bitmap.createBitmap(v.getDrawingCache()); // 创建bitmap
|
||||
FileOutputStream fos;
|
||||
try {
|
||||
// 判断手机设备是否有SD卡
|
||||
boolean isHasSDCard = Environment.getExternalStorageState().equals(
|
||||
android.os.Environment.MEDIA_MOUNTED);
|
||||
if (isHasSDCard) {
|
||||
// SD卡根目录
|
||||
File sdRoot = Environment.getExternalStorageDirectory();
|
||||
new File(sdRoot + "/DCIM/TimeManager").mkdir();
|
||||
File file = new File(sdRoot, "/DCIM/TimeManager/test.PNG");
|
||||
file.createNewFile();
|
||||
fos = new FileOutputStream(file);
|
||||
} else
|
||||
throw new Exception("创建文件失败!");
|
||||
|
||||
b.compress(Bitmap.CompressFormat.PNG, 90, fos);
|
||||
|
||||
fos.flush();
|
||||
fos.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -94,7 +94,6 @@ abstract public class NewActivityDialog{
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
chosenTime[3] = hourOfDay;
|
||||
chosenTime[4] = minute;
|
||||
chosenTime[5] = 2;
|
||||
time.setText(String.format(Locale.CHINA, "%02d:%02d",
|
||||
chosenTime[3], chosenTime[4]));
|
||||
}
|
||||
|
||||
+25
@@ -28,11 +28,17 @@ import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import wesayallright.timemanager.InnerLayer.Network.NetWork;
|
||||
import wesayallright.timemanager.R;
|
||||
import wesayallright.timemanager.surface.SaveViewToImage;
|
||||
|
||||
public class ScheduleFragment extends Fragment implements View.OnClickListener , AdapterView.OnItemSelectedListener , View.OnTouchListener , ToggleButton.OnCheckedChangeListener , NumberPicker.OnValueChangeListener {
|
||||
private static final String TAG = "ScheduleFragment";
|
||||
private ArrayList<ArrayList<ArrayList<Course>>> pcourse = new ArrayList<>();//pcourse.get(week).get(day).get(xth in day)
|
||||
@@ -358,8 +364,27 @@ public class ScheduleFragment extends Fragment implements View.OnClickListener ,
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.i("ON CLICK", "ON CLICK CLICK CLICK CLICK CLICK CLICK CLICK CLICK");
|
||||
switch (view.getId()) {
|
||||
case R.id.STRimageview:
|
||||
/* 分享 */
|
||||
// send Information to server
|
||||
// get return from server
|
||||
// create image and save
|
||||
// shareDialog();
|
||||
Log.i("点击按钮", "分享");
|
||||
View v = View.inflate(getActivity(), R.layout.schedule_fragment, null);
|
||||
View schedule = v.findViewById(R.id.Sframe);
|
||||
|
||||
if(schedule == null) try {
|
||||
throw new Exception("获取日程view失败");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//(new SaveViewToImage()).save(schedule);
|
||||
(new NetWork()).POST("", new HashMap<String, String>());
|
||||
|
||||
break;
|
||||
case R.id.dialogweek:
|
||||
LayoutInflater inflaterweek = LayoutInflater.from(getActivity());
|
||||
|
||||
Reference in New Issue
Block a user