Skip to content

Commit

Permalink
bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
HUPENG committed Sep 13, 2016
1 parent fcb5373 commit fec684b
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 1 deletion.
16 changes: 16 additions & 0 deletions res/layout/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@
android:layout_weight="1"/>
</LinearLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="偏转角度:"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/et_angle"
android:layout_weight="1"/>
</LinearLayout>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
17 changes: 17 additions & 0 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@
android:id="@+id/tv_server_ip"/>
</LinearLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="偏转角度:"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="0.0.0.0"
android:id="@+id/tv_angle"/>
</LinearLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
Expand Down
5 changes: 5 additions & 0 deletions src/me/hupeng/android/monitor/Mina/MyImageEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput ou
ioBuffer.capacity(length+8);
ioBuffer.flip();
out.write(ioBuffer);

if (message instanceof MyData){

myData.bitmap.recycle();
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/me/hupeng/android/monitor/UI/ConfigActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ConfigActivity extends Activity{
private EditText etServerIp;
private Button btn_save;
private EditText etClientId;
private EditText etAngle;

private void init(){
ActionBar actionBar = getActionBar();
Expand All @@ -27,11 +28,14 @@ private void init(){
etServerIp = (EditText) findViewById(R.id.et_server_address);
btn_save = (Button) findViewById(R.id.btn_save_config);
etClientId = (EditText) findViewById(R.id.et_client_id);
etAngle = (EditText) findViewById(R.id.et_angle);

//绑定单击回调
btn_save.setOnClickListener(new MyOnClickListener());

etServerIp.setText(getServerIp());
etClientId.setText(SharedPreferencesUtil.readInt(ConfigActivity.this,"client_id")+"");
etAngle.setText(getAngle()+"");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -52,6 +56,8 @@ public void onClick(View view) {
try{
int clientId = Integer.parseInt(tempClientId);
SharedPreferencesUtil.writeInt(ConfigActivity.this, "client_id", clientId);
int angle = Integer.parseInt(etAngle.getText().toString());
SharedPreferencesUtil.writeInt(ConfigActivity.this, "angle" , angle);
}catch (Exception e){

}
Expand Down Expand Up @@ -79,4 +85,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
return super.onOptionsItemSelected(item);
}

private int getAngle(){
int angle = SharedPreferencesUtil.readInt(ConfigActivity.this, "angle",-1);
return angle==-1? 90 : angle;
}
}
7 changes: 6 additions & 1 deletion src/me/hupeng/android/monitor/UI/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void onPreviewFrame(byte[] bytes, Camera camera) {
50, stream);
Bitmap bmp = BitmapFactory.decodeByteArray(
stream.toByteArray(), 0, stream.size());
this.bitmap = rotateBitmapByDegree(bmp,90);
this.bitmap = rotateBitmapByDegree(bmp,getAngle());
sendPic();

stream.close();
Expand Down Expand Up @@ -331,4 +331,9 @@ public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
}
return returnBm;
}

private int getAngle(){
int angle = SharedPreferencesUtil.readInt(MainActivity.this, "angle", -1);
return angle==-1? 90 : angle;
}
}
8 changes: 8 additions & 0 deletions src/me/hupeng/android/monitor/Util/SharedPreferencesUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ public static int readInt(Context context, String key){
SharedPreferences sharedPreferences = context.getSharedPreferences("config", context.MODE_PRIVATE);
return sharedPreferences.getInt(key,0);
}

/**
* 读出value值
* */
public static int readInt(Context context, String key, int def){
SharedPreferences sharedPreferences = context.getSharedPreferences("config", context.MODE_PRIVATE);
return sharedPreferences.getInt(key,def);
}
}

0 comments on commit fec684b

Please sign in to comment.