这是我的mainLayout,点击btnStart我尝试设置scrollView就像去了,然后linearLoading可见。
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btnGetDni:
/*some validation*/
break;
case R.id.btnGetSign:
/*some validation*/
break;
case R.id.btnStart :
scrollView.setVisibility(View.GONE);
linearLayoutLoading.setVisibility(View.VISIBLE);
startAnim();
/*some validations*/
if (something is wrong){
scrollView.setVisibility(View.VISIBLE);
linearLayoutLoading.setVisibility(View.GONE);
stopAnim();
}else{
if(something is wrong ){
scrollView.setVisibility(View.VISIBLE);
linearLayoutLoading.setVisibility(View.GONE);
stopAnim();
}else{
if (something is wrong){
scrollView.setVisibility(View.VISIBLE);
linearLayoutLoading.setVisibility(View.GONE);
stopAnim();
}else{
if (something is wrong){
scrollView.setVisibility(View.VISIBLE);
linearLayoutLoading.setVisibility(View.GONE);
stopAnim();
}else{
if (something is wrong){
scrollView.setVisibility(View.VISIBLE);
linearLayoutLoading.setVisibility(View.GONE);
stopAnim();
}else{
insert();
}
}
}
}
}
break;
default :
break;
}
}
这是我改变可见性状态的地方。
private void insert() {
final LendService lendService = LendRetroFitUtils.getLendService();
/*collecting*/
Item item = new Item();
item.setUserID(idFacebook);
item.setSignedPaperPhoto(nuevoDNI);
item.setDniPhoto(newSign);
item.setCel_brand(brandCellphone);
item.setCel_model(modelCellphone);
item.setAndroid_version(versionCellphone);
.
.
.
/*getting information*/
List<GpsList> listGpsList = new ArrayList<>();
lendService.insertUsers(item).enqueue(new Callback<Item>() {
Gson gson= new Gson() ;
@Override
public void onResponse(Call<Item> call, Response<Item> response) {
Log.i("Response Code", ""+ response.code());
switch (response.code() ){
case 404:
stopTransition();
Toast.makeText(getApplicationContext(),"Usuario incorrecto en Facebook",Toast.LENGTH_LONG).show();
break;
case 403 :
stopTransition();
Toast.makeText(getApplicationContext(),"El número pin es incorrecto",Toast.LENGTH_LONG).show();
break;
case 418 :
stopTransition();
Intent openBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse("/*url*/"));
startActivity(openBrowser);
break;
case 422:
stopTransition();
String errorBodyRaw = null;
try {
errorBodyRaw = response.errorBody().string();
} catch (IOException e) {
e.printStackTrace();
}
String body = errorBodyRaw.substring(0,errorBodyRaw.length());
Log.i(" LOG ::::::", "body"+body+"n");
JsonObject jsonObjectParsed= new JsonParser().parse(errorBodyRaw).getAsJsonObject();
ResponseErrorItem obj= gson.fromJson(jsonObjectParsed,ResponseErrorItem.class);
if (obj.getStatus() != null){
/*some validations on error*/
}
break;
case 500:
stopTransition();
Toast.makeText(getApplicationContext(),"error message",Toast.LENGTH_LONG).show();
break;
default :
stopTransition();
Toast.makeText(getApplicationContext(),"error message",Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Call<Item> call, Throwable t) {
Log.i("onFailure",""+call);
Log.i("onFailure",""+t);
stopTransition();
Log.e("Main Activity", "Unable to submit post to API.");
if (call.isCanceled()){
Log.e("Main Activity", "request was aborted");
}else {
Log.e("Main Activity", "Unable to submit post to API.");
}
}
});
}
在插入内部()我正在进行改造请求。主要问题是动画从服务获得响应后启动。 这是方法insert()
void startAnim(){
avi.show();
// or avi.smoothToShow();
}
void stopAnim(){
avi.hide();
// or avi.smoothToHide();
}
startAnim()和stopAnim()
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/background_segm.hpp>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
const std::string filename = "/home/yurychu/my_video.avi";
VideoCapture capture(filename);
Mat frame;
Ptr<BackgroundSubtractor> pMOG;
pMOG = createBackgroundSubtractorMOG2();
namedWindow("FG mask MOG 2");
while (1) {
if (!capture.read(frame)) {
cerr << "Unable to read next frame. Exiting..." << endl;
exit(EXIT_FAILURE);
}
Mat fgMaskMOG2;
pMOG->apply(frame, fgMaskMOG2);
imshow("FG mask MOG 2", fgMaskMOG2);
waitKey(33);
}
destroyAllWindows();
return 0;
}