改正了sonarqube提示的错误,但仍有两个错误无法解决。

This commit is contained in:
qinjiaming_branch 2016-08-20 09:16:56 +08:00
parent 954d049f3e
commit 668cd69b6e
12 changed files with 41 additions and 38 deletions

View File

@ -5,6 +5,9 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.stone.shop.R;
import com.stone.shop.model.Reservation;
import com.stone.shop.model.User;
@ -20,13 +23,13 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.DeleteListener;
//import cn.bmob.v3.listener.DeleteListener;
import cn.bmob.v3.listener.FindListener;
import cn.bmob.v3.listener.SaveListener;
public class LibraryReservationActivity extends Activity {
private Button btn_login;
private Button btnLogin;
private SimpleDateFormat dateFormat;
@Override
@ -34,16 +37,16 @@ public class LibraryReservationActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_libraryreservation);
TextView tv_title = (TextView) findViewById(R.id.tv_title);
tv_title.setText("预定研修室");
TextView tvTitle = (TextView) findViewById(R.id.tv_title);
tvTitle.setText("预定研修室");
final String roomId = getIntent().getStringExtra("roomId");
final String roomName = getIntent().getStringExtra("roomName");
TextView tv_room = (TextView) findViewById(R.id.tv_room);
tv_room.setText("研修室:" + roomName);
TextView tvRoom = (TextView) findViewById(R.id.tv_room);
tvRoom.setText("研修室:" + roomName);
btn_login = (Button) findViewById(R.id.btn_login);
btnLogin = (Button) findViewById(R.id.btn_login);
dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
@ -55,11 +58,10 @@ public class LibraryReservationActivity extends Activity {
@Override
public void onSuccess(List<Reservation> newsList) {
// toast("查询商品成功, 共" + newsList.size());
if (newsList.size() != 0) {
if (!newsList.isEmpty() /*newsList.size() != 0*/) {
String dateTime = newsList.get(0).getDateTime();
Logger logger = Logger.getLogger("lavasoft");
try {
if (dateFormat.parse(dateTime).before(new Date())) {
@ -68,12 +70,13 @@ public class LibraryReservationActivity extends Activity {
gameScore.delete(LibraryReservationActivity.this);
} else {
btn_login.setEnabled(false);
btn_login.setText("已经预定" + (TextUtils.isEmpty(dateTime) ? "" : (" " + dateTime)));
btnLogin.setEnabled(false);
btnLogin.setText("已经预定" + (TextUtils.isEmpty(dateTime) ? "" : (" " + dateTime)));
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
//e.printStackTrace();
logger.log(Level.SEVERE, "something may be wrong", e);
}
}
@ -86,7 +89,7 @@ public class LibraryReservationActivity extends Activity {
}
});
btn_login.setOnClickListener(new OnClickListener() {
btnLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@ -112,8 +115,8 @@ public class LibraryReservationActivity extends Activity {
public void onSuccess() {
// TODO Auto-generated method stub
toast("预定成功");
btn_login.setEnabled(false);
btn_login.setText("已经预定 " + dateTime);
btnLogin.setEnabled(false);
btnLogin.setText("已经预定 " + dateTime);
}

View File

@ -5,6 +5,9 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.stone.shop.R;
import com.stone.shop.model.Reservation;
import com.stone.shop.model.User;
@ -20,13 +23,13 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.listener.DeleteListener;
//import cn.bmob.v3.listener.DeleteListener;
import cn.bmob.v3.listener.FindListener;
import cn.bmob.v3.listener.SaveListener;
public class ReservationActivity extends Activity {
private Button btn_login;
private Button btnLogin;
private SimpleDateFormat dateFormat;
@Override
@ -34,16 +37,16 @@ public class ReservationActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_reservation);
TextView tv_title = (TextView) findViewById(R.id.tv_title);
tv_title.setText("教室预定");
TextView tvTitle = (TextView) findViewById(R.id.tv_title);
tvTitle.setText("教室预定");
final String roomId = getIntent().getStringExtra("roomId");
final String roomName = getIntent().getStringExtra("roomName");
TextView tv_room = (TextView) findViewById(R.id.tv_room);
tv_room.setText("教室:" + roomName);
TextView tvRoom = (TextView) findViewById(R.id.tv_room);
tvRoom.setText("教室:" + roomName);
btn_login = (Button) findViewById(R.id.btn_login);
btnLogin = (Button) findViewById(R.id.btn_login);
dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
@ -54,9 +57,11 @@ public class ReservationActivity extends Activity {
bmobQuery.findObjects(ReservationActivity.this, new FindListener<Reservation>() {
@Override
public void onSuccess(List<Reservation> newsList) {
// toast("查询商品成功, 共" + newsList.size());
if (newsList.size() != 0) {
if (!newsList.isEmpty()) {
String dateTime = newsList.get(0).getDateTime();
Logger logger = Logger.getLogger("lavasoft");
try {
if (dateFormat.parse(dateTime).before(new Date())) {
@ -64,12 +69,14 @@ public class ReservationActivity extends Activity {
gameScore.setObjectId(newsList.get(0).getObjectId());
gameScore.delete(ReservationActivity.this);
} else {
btn_login.setEnabled(false);
btn_login.setText("已经预定" + (TextUtils.isEmpty(dateTime) ? "" : (" " + dateTime)));
btnLogin.setEnabled(false);
btnLogin.setText("已经预定" + (TextUtils.isEmpty(dateTime) ? "" : (" " + dateTime)));
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
//e.printStackTrace();
logger.log(Level.SEVERE, "something may be wrong", e);
}
}
}
@ -79,12 +86,10 @@ public class ReservationActivity extends Activity {
}
});
btn_login.setOnClickListener(new OnClickListener() {
btnLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
DateTimePickDialogUtil dateTimePicKDialog = new DateTimePickDialogUtil(ReservationActivity.this,
dateFormat.format(new Date()));
dateTimePicKDialog.dateTimePicKDialog(new DateTimeListener() {
@ -92,7 +97,6 @@ public class ReservationActivity extends Activity {
@Override
public void onDateTimeChane(final String dateTime) {
// TODO Auto-generated method stub
Reservation reservation = new Reservation();
reservation.setRoomId(roomId);
reservation.setRoomName(roomName);
@ -100,19 +104,15 @@ public class ReservationActivity extends Activity {
reservation.setDateTime(dateTime);
reservation.save(ReservationActivity.this, new SaveListener() {
@Override
public void onSuccess() {
// TODO Auto-generated method stub
toast("预定成功");
btn_login.setEnabled(false);
btn_login.setText("已经预定 " + dateTime);
btnLogin.setEnabled(false);
btnLogin.setText("已经预定 " + dateTime);
}
@Override
public void onFailure(int arg0, String arg1) {
// TODO Auto-generated method stub
toast("预定失败");
}
});