Program: 39067
Project: 39067
Buggy source:
@Override protected void onCreate(@Nullable Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  wallpaperManager=WallpaperManager.getInstance(FullWallpaperViewActivity.this);
  setContentView(R.layout.fullscreen_activity_view);
  ActivityCaller=getIntent().getStringExtra("String_Node_Str");
  pos=getIntent().getIntExtra("String_Node_Str",0);
  Log.i("String_Node_Str",String.valueOf(pos));
  downloadWallBtn=findViewById(R.id.downloadWallBtn);
  setWallBtn=findViewById(R.id.setWallBtn);
  disableAdBlock=findViewById(R.id.disableAdBlock);
  toolbar=findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  viewPager=findViewById(R.id.view_pager);
  if (ActivityCaller.equals("String_Node_Str")) {
    path=getIntent().getStringArrayListExtra("String_Node_Str");
    fullScreenSwipeAdapter=new FullScreenSwipeAdapter(FullWallpaperViewActivity.this,path,pos);
    Log.i("String_Node_Str",String.valueOf(pos));
    viewPager.setAdapter(fullScreenSwipeAdapter);
    viewPager.setCurrentItem(pos);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
      @Override public void onPageScrolled(      int position,      float positionOffset,      int positionOffsetPixels){
        String id[]=path.get(pos).split("String_Node_Str");
        String title="String_Node_Str" + id[1];
        getSupportActionBar().setTitle(title);
        toolbar.setTitleTextColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.white));
        toolbar.setPadding(0,getStatusBarHeight(),0,0);
        toolbar.setBackgroundColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.translucentBlackColor));
        toolbar.setNavigationIcon(R.drawable.back_arrow);
        toolbar.setNavigationOnClickListener(new View.OnClickListener(){
          @Override public void onClick(          View view){
            onBackPressed();
          }
        }
);
      }
      @Override public void onPageSelected(      int position){
        if (pos > position) {
          pos--;
          Log.i("String_Node_Str",String.valueOf(pos));
        }
 else         if (pos < position) {
          pos++;
          Log.i("String_Node_Str",String.valueOf(pos));
        }
      }
      @Override public void onPageScrollStateChanged(      int state){
      }
    }
);
    downloadWallBtn.setVisibility(View.GONE);
    setWallBtn.setVisibility(View.VISIBLE);
  }
 else {
    arrayList=getIntent().getParcelableArrayListExtra("String_Node_Str");
    fullScreenSwipeAdapter=new FullScreenSwipeAdapter(FullWallpaperViewActivity.this,arrayList);
    viewPager.setAdapter(fullScreenSwipeAdapter);
    viewPager.setCurrentItem(pos);
    viewPager.setOnTouchListener(new View.OnTouchListener(){
      private float pointX;
      private float pointY;
      private int tolerance=50;
      @Override public boolean onTouch(      View v,      MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
          return false;
case MotionEvent.ACTION_DOWN:
        pointX=event.getX();
      pointY=event.getY();
    Log.i("String_Node_Str",String.valueOf(pointX));
  Log.i("String_Node_Str",String.valueOf(pointY));
break;
case MotionEvent.ACTION_UP:
boolean sameX=pointX + tolerance > event.getX() && pointX - tolerance < event.getX();
boolean sameY=pointY + tolerance > event.getY() && pointY - tolerance < event.getY();
Log.i("String_Node_Str",String.valueOf(sameX));
Log.i("String_Node_Str",String.valueOf(sameY));
if (sameX && sameY) {
if (fullscreen == false) {
toolbar.setVisibility(View.INVISIBLE);
disableAdBlock.setVisibility(View.INVISIBLE);
bannerAd.setVisibility(View.INVISIBLE);
downloadWallBtn.setVisibility(View.INVISIBLE);
setWallBtn.setVisibility(View.INVISIBLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
fullscreen=true;
}
 else if (fullscreen == true) {
toolbar.setVisibility(View.VISIBLE);
if (isAdblock) {
disableAdBlock.setVisibility(View.VISIBLE);
}
bannerAd.setVisibility(View.VISIBLE);
downloadWallBtn.setVisibility(View.VISIBLE);
setWallBtn.setVisibility(View.VISIBLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
fullscreen=false;
}
}
}
return false;
}
}
);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
String title="String_Node_Str" + String.valueOf(arrayList.get(position).getWallId());
getSupportActionBar().setTitle(title);
toolbar.setTitleTextColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.white));
toolbar.setPadding(0,getStatusBarHeight(),0,0);
toolbar.setBackgroundColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.translucentBlackColor));
toolbar.setNavigationIcon(R.drawable.back_arrow);
toolbar.setNavigationOnClickListener(new View.OnClickListener(){
@Override public void onClick(View view){
onBackPressed();
}
}
);
encodedUrlFull=arrayList.get(position).getWallpaperFullURL();
}
@Override public void onPageSelected(int position){
if ((arrayList.size() - position <= 2)) {
Log.i("String_Node_Str","String_Node_Str");
Log.i("String_Node_Str",String.valueOf(pageCount));
Intent intent=new Intent("String_Node_Str");
LocalBroadcastManager.getInstance(FullWallpaperViewActivity.this).sendBroadcast(intent);
Log.i("String_Node_Str","String_Node_Str");
viewPager.invalidate();
}
}
@Override public void onPageScrollStateChanged(int state){
}
}
);
}
MobileAds.initialize(FullWallpaperViewActivity.this,getResources().getString(R.string.FULLSCREEN_BANNER_ID));
bannerAd=new AdView(FullWallpaperViewActivity.this);
bannerAd=findViewById(R.id.bannerAdView);
final AdRequest adRequest=new AdRequest.Builder().addTestDevice("String_Node_Str").addTestDevice("String_Node_Str").addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
bannerAd.loadAd(adRequest);
bannerAd.setAdListener(new AdListener(){
@Override public void onAdFailedToLoad(int i){
disableAdBlock.setVisibility(View.VISIBLE);
isAdblock=true;
}
@Override public void onAdLoaded(){
super.onAdLoaded();
isAdblock=false;
disableAdBlock.setVisibility(View.GONE);
}
}
);
encodedUrlFull=getIntent().getStringExtra("String_Node_Str");
encodedUrlThumb=getIntent().getStringExtra("String_Node_Str");
wallId=getIntent().getIntExtra("String_Node_Str",0);
fileType="String_Node_Str" + getIntent().getStringExtra("String_Node_Str");
setWallBtn.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View view){
new setWall(getApplicationContext()).execute();
}
}
);
downloadWallBtn.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View view){
switch (ActivityCaller) {
case "String_Node_Str":
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
toast=makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + fileType,Toast.LENGTH_SHORT);
toast.show();
break;
case "String_Node_Str":
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + fileType,Toast.LENGTH_SHORT);
toast.show();
break;
case "String_Node_Str":
try {
AlertDialog.Builder builder=new AlertDialog.Builder(FullWallpaperViewActivity.this,R.style.MyDialogTheme);
builder.setCancelable(false);
builder.setTitle("String_Node_Str");
builder.setItems(options,new DialogInterface.OnClickListener(){
@Override public void onClick(DialogInterface dialog,int which){
switch (which) {
case 0:
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + "String_Node_Str"+ fileType,Toast.LENGTH_SHORT);
toast.show();
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
Log.i("String_Node_Str",encodedUrlFull);
break;
case 1:
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + "String_Node_Str"+ fileType,Toast.LENGTH_SHORT);
toast.show();
encodedUrlFull=encodedUrlFull.replace("String_Node_Str","String_Node_Str");
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
Log.i("String_Node_Str",encodedUrlFull);
break;
case 2:
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + "String_Node_Str"+ fileType,Toast.LENGTH_SHORT);
toast.show();
encodedUrlFull=encodedUrlFull.replace("String_Node_Str","String_Node_Str");
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
Log.i("String_Node_Str",encodedUrlFull);
break;
}
}
}
);
builder.setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
@Override public void onClick(DialogInterface dialog,int which){
}
}
);
builder.show();
}
 catch (Exception e) {
Log.i("String_Node_Str",e.toString());
}
break;
}
}
}
);
Fresco.initialize(this);
}

Fixed version (ground truth):
@Override protected void onCreate(@Nullable Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  wallpaperManager=WallpaperManager.getInstance(FullWallpaperViewActivity.this);
  setContentView(R.layout.fullscreen_activity_view);
  ActivityCaller=getIntent().getStringExtra("String_Node_Str");
  pos=getIntent().getIntExtra("String_Node_Str",0);
  Log.i("String_Node_Str",String.valueOf(pos));
  downloadWallBtn=findViewById(R.id.downloadWallBtn);
  setWallBtn=findViewById(R.id.setWallBtn);
  disableAdBlock=findViewById(R.id.disableAdBlock);
  toolbar=findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  viewPager=findViewById(R.id.view_pager);
  encodedUrlFull=getIntent().getStringExtra("String_Node_Str");
  encodedUrlThumb=getIntent().getStringExtra("String_Node_Str");
  wallId=getIntent().getIntExtra("String_Node_Str",0);
  fileType="String_Node_Str" + getIntent().getStringExtra("String_Node_Str");
  if (ActivityCaller.equals("String_Node_Str")) {
    path=getIntent().getStringArrayListExtra("String_Node_Str");
    fullScreenSwipeAdapter=new FullScreenSwipeAdapter(FullWallpaperViewActivity.this,path,pos);
    Log.i("String_Node_Str",String.valueOf(pos));
    viewPager.setAdapter(fullScreenSwipeAdapter);
    viewPager.setCurrentItem(pos);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
      @Override public void onPageScrolled(      int position,      float positionOffset,      int positionOffsetPixels){
        String id[]=path.get(pos).split("String_Node_Str");
        String title="String_Node_Str" + id[1];
        getSupportActionBar().setTitle(title);
        toolbar.setTitleTextColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.white));
        toolbar.setPadding(0,getStatusBarHeight(),0,0);
        toolbar.setBackgroundColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.translucentBlackColor));
        toolbar.setNavigationIcon(R.drawable.back_arrow);
        toolbar.setNavigationOnClickListener(new View.OnClickListener(){
          @Override public void onClick(          View view){
            onBackPressed();
          }
        }
);
      }
      @Override public void onPageSelected(      int position){
        if (pos > position) {
          pos--;
          Log.i("String_Node_Str",String.valueOf(pos));
        }
 else         if (pos < position) {
          pos++;
          Log.i("String_Node_Str",String.valueOf(pos));
        }
      }
      @Override public void onPageScrollStateChanged(      int state){
      }
    }
);
    downloadWallBtn.setVisibility(View.GONE);
    setWallBtn.setVisibility(View.VISIBLE);
  }
 else {
    arrayList=getIntent().getParcelableArrayListExtra("String_Node_Str");
    fullScreenSwipeAdapter=new FullScreenSwipeAdapter(FullWallpaperViewActivity.this,arrayList);
    Log.i("String_Node_Str",String.valueOf(arrayList.size()));
    viewPager.setAdapter(fullScreenSwipeAdapter);
    viewPager.setCurrentItem(pos);
    viewPager.setOnTouchListener(new View.OnTouchListener(){
      private float pointX;
      private float pointY;
      private int tolerance=50;
      @Override public boolean onTouch(      View v,      MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
          return false;
case MotionEvent.ACTION_DOWN:
        pointX=event.getX();
      pointY=event.getY();
    Log.i("String_Node_Str",String.valueOf(pointX));
  Log.i("String_Node_Str",String.valueOf(pointY));
break;
case MotionEvent.ACTION_UP:
boolean sameX=pointX + tolerance > event.getX() && pointX - tolerance < event.getX();
boolean sameY=pointY + tolerance > event.getY() && pointY - tolerance < event.getY();
Log.i("String_Node_Str",String.valueOf(sameX));
Log.i("String_Node_Str",String.valueOf(sameY));
if (sameX && sameY) {
if (fullscreen == false) {
toolbar.setVisibility(View.INVISIBLE);
disableAdBlock.setVisibility(View.INVISIBLE);
bannerAd.setVisibility(View.INVISIBLE);
downloadWallBtn.setVisibility(View.INVISIBLE);
setWallBtn.setVisibility(View.INVISIBLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
fullscreen=true;
}
 else if (fullscreen == true) {
toolbar.setVisibility(View.VISIBLE);
if (isAdblock) {
disableAdBlock.setVisibility(View.VISIBLE);
}
bannerAd.setVisibility(View.VISIBLE);
downloadWallBtn.setVisibility(View.VISIBLE);
setWallBtn.setVisibility(View.VISIBLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
fullscreen=false;
}
}
}
return false;
}
}
);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
String title="String_Node_Str" + String.valueOf(arrayList.get(position).getWallId());
getSupportActionBar().setTitle(title);
toolbar.setTitleTextColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.white));
toolbar.setPadding(0,getStatusBarHeight(),0,0);
toolbar.setBackgroundColor(ContextCompat.getColor(FullWallpaperViewActivity.this,R.color.translucentBlackColor));
toolbar.setNavigationIcon(R.drawable.back_arrow);
toolbar.setNavigationOnClickListener(new View.OnClickListener(){
@Override public void onClick(View view){
onBackPressed();
}
}
);
}
@Override public void onPageSelected(int position){
if ((arrayList.size() - position <= 2)) {
Log.i("String_Node_Str","String_Node_Str");
Log.i("String_Node_Str",String.valueOf(pageCount));
Intent intent=new Intent("String_Node_Str");
LocalBroadcastManager.getInstance(FullWallpaperViewActivity.this).sendBroadcast(intent);
Log.i("String_Node_Str","String_Node_Str");
viewPager.invalidate();
}
encodedUrlFull=arrayList.get(position).getWallpaperFullURL();
wallId=arrayList.get(position).getWallId();
Log.i("String_Node_Str",String.valueOf(pos));
Log.i("String_Node_Str",encodedUrlFull);
}
@Override public void onPageScrollStateChanged(int state){
}
}
);
}
MobileAds.initialize(FullWallpaperViewActivity.this,getResources().getString(R.string.FULLSCREEN_BANNER_ID));
bannerAd=new AdView(FullWallpaperViewActivity.this);
bannerAd=findViewById(R.id.bannerAdView);
final AdRequest adRequest=new AdRequest.Builder().addTestDevice("String_Node_Str").addTestDevice("String_Node_Str").addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
bannerAd.loadAd(adRequest);
bannerAd.setAdListener(new AdListener(){
@Override public void onAdFailedToLoad(int i){
disableAdBlock.setVisibility(View.VISIBLE);
isAdblock=true;
}
@Override public void onAdLoaded(){
super.onAdLoaded();
isAdblock=false;
disableAdBlock.setVisibility(View.GONE);
}
}
);
setWallBtn.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View view){
new setWall(getApplicationContext()).execute();
}
}
);
downloadWallBtn.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View view){
switch (ActivityCaller) {
case "String_Node_Str":
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
toast=makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + fileType,Toast.LENGTH_SHORT);
toast.show();
break;
case "String_Node_Str":
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + fileType,Toast.LENGTH_SHORT);
toast.show();
break;
case "String_Node_Str":
try {
AlertDialog.Builder builder=new AlertDialog.Builder(FullWallpaperViewActivity.this,R.style.MyDialogTheme);
builder.setCancelable(false);
builder.setTitle("String_Node_Str");
builder.setItems(options,new DialogInterface.OnClickListener(){
@Override public void onClick(DialogInterface dialog,int which){
switch (which) {
case 0:
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + "String_Node_Str"+ fileType,Toast.LENGTH_SHORT);
toast.show();
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
Log.i("String_Node_Str",encodedUrlFull);
break;
case 1:
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + "String_Node_Str"+ fileType,Toast.LENGTH_SHORT);
toast.show();
encodedUrlFull=encodedUrlFull.replace("String_Node_Str","String_Node_Str");
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
Log.i("String_Node_Str",encodedUrlFull);
break;
case 2:
toast=Toast.makeText(getApplicationContext(),"String_Node_Str" + "String_Node_Str" + String.valueOf(wallId) + "String_Node_Str"+ fileType,Toast.LENGTH_SHORT);
toast.show();
encodedUrlFull=encodedUrlFull.replace("String_Node_Str","String_Node_Str");
new DownloadHandler.ImageDownloadAndSave(getApplicationContext()).execute(encodedUrlFull,"String_Node_Str" + String.valueOf(wallId) + fileType);
Log.i("String_Node_Str",encodedUrlFull);
break;
}
}
}
);
builder.setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
@Override public void onClick(DialogInterface dialog,int which){
}
}
);
builder.show();
}
 catch (Exception e) {
Log.i("String_Node_Str",e.toString());
}
break;
}
}
}
);
}