Sketchware-Pro / Sketchware-Pro

Sketchware Pro's sources in Java. Now anyone can contribute to Sketchware Pro.
https://sketchware.pro
Other
863 stars 254 forks source link

Cannot be resolved bug #663

Closed IamHomen closed 10 months ago

IamHomen commented 1 year ago

Screenshot_20221129-185227 is this a bug??

hasrat-ali commented 1 year ago

How? can you explain better?

IamHomen commented 1 year ago

How? can you explain better?

im just making the project and when i added SwipeRefreshLayout and run the project this happen and remove the SwipeRefreshLayout but this is not fix😅

IamHomen commented 1 year ago

How? can you explain better?

Screenshot_20221130-051523

hasrat-ali commented 1 year ago

I think your custom blocks is broken or mis-configured.

IamHomen commented 1 year ago

I think your custom blocks is broken or mis-configured.

no its all okay until i add SwipeRefreshLayout and this happen😔 even the map variable is cannot be resolved.

hasrat-ali commented 1 year ago

Can you show the source code?

IamHomen commented 1 year ago

Can you show the source code?

package com.mrcain.asura;

import android.animation.; import android.app.; import android.content.; import android.content.res.; import android.graphics.; import android.graphics.drawable.; import android.media.; import android.net.; import android.os.; import android.text.; import android.text.style.; import android.util.; import android.view.; import android.view.View.; import android.view.animation.; import android.webkit.; import android.widget.; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.Adapter; import androidx.recyclerview.widget.RecyclerView.ViewHolder; import com.bumptech.glide.Glide; import com.google.android.material.appbar.AppBarLayout; import java.io.; import java.text.; import java.util.; import java.util.ArrayList; import java.util.HashMap; import java.util.regex.; import meorg.jsoup.; import org.json.*; import androidx.core.widget.NestedScrollView; import androidx.core.view.MenuItemCompat;

public class MainActivity extends AppCompatActivity {

private Toolbar _toolbar;
private AppBarLayout _app_bar;
private CoordinatorLayout _coordinator;
private DrawerLayout _drawer;
private HashMap<String, Object> popular_map = new HashMap<>();

private ArrayList<HashMap<String, Object>> popular_today_listmap = new ArrayList<>();

private NestedScrollView nsv1;
private LinearLayout linear2;
private TextView textview1;
private RecyclerView recyclerview1;

private RequestNetwork rn_asura_popular;
private RequestNetwork.RequestListener _rn_asura_popular_request_listener;

@Override
protected void onCreate(Bundle _savedInstanceState) {
    super.onCreate(_savedInstanceState);
    setContentView(R.layout.main);
    initialize(_savedInstanceState);
    initializeLogic();
}

private void initialize(Bundle _savedInstanceState) {
    _app_bar = findViewById(R.id._app_bar);
    _coordinator = findViewById(R.id._coordinator);
    _toolbar = findViewById(R.id._toolbar);
    setSupportActionBar(_toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    _toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View _v) {
            onBackPressed();
        }
    });
    _drawer = findViewById(R.id._drawer);
    ActionBarDrawerToggle _toggle = new ActionBarDrawerToggle(MainActivity.this, _drawer, _toolbar, R.string.app_name, R.string.app_name);
    _drawer.addDrawerListener(_toggle);
    _toggle.syncState();

    LinearLayout _nav_view = findViewById(R.id._nav_view);

    nsv1 = findViewById(R.id.nsv1);
    linear2 = findViewById(R.id.linear2);
    textview1 = findViewById(R.id.textview1);
    recyclerview1 = findViewById(R.id.recyclerview1);
    rn_asura_popular = new RequestNetwork(this);

    _rn_asura_popular_request_listener = new RequestNetwork.RequestListener() {
        @Override
        public void onResponse(String _param1, String _param2, HashMap<String, Object> _param3) {
            final String _tag = _param1;
            final String _response = _param2;
            final HashMap<String, Object> _responseHeaders = _param3;
            try {
                org.jsoup.nodes.Document listupd = org.jsoup.Jsoup.parse(_response);
                org.jsoup.select.Elements div1 = listupd.getElementsByClass("tt");
                org.jsoup.select.Elements div2 = listupd.getElementsByClass("epxs");
                org.jsoup.select.Elements img = listupd.select("img[src*=asura.gg]");
                org.jsoup.select.Elements a = listupd.select("div.bsx a[href]");
                org.jsoup.select.Elements span = listupd.getElementsByClass("type");
                recyclerview1.setAdapter(new Recyclerview1Adapter(popular_today_listmap));
                recyclerview1.setLayoutManager(new LinearLayoutManager(MainActivity.this));
                recyclerview1.setLayoutManager(new LinearLayoutManager(MainActivity.this,LinearLayoutManager.HORIZONTAL, false));

                for (int i = 0; i < (int)(div1.size()); i++) {
                    popular_map = new HashMap<>();
                    popular_map.put("title", div1.get(i).text());
                    popular_map.put("chapter", div2.get(i).text());
                    popular_map.put("cover", img.get(i).attr("src"));
                    popular_map.put("link", a.get(i).attr("href"));
                    popular_map.put("type", span.get(i).text());
                    popular_today_listmap.add(popular_map);
                }
            } catch (Exception e) {
                SketchwareUtil.showMessage(getApplicationContext(), e.toString());
            }
        }

        @Override
        public void onErrorResponse(String _param1, String _param2) {
            final String _tag = _param1;
            final String _message = _param2;
            SketchwareUtil.showMessage(getApplicationContext(), _message);
        }
    };
}

private void initializeLogic() {
    _rn();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();  
            inflater.inflate(R.menu.menu, menu);  
            MenuItem searchViewItem = menu.findItem(R.id.app_bar_search);  
            final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem);  
            searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {  
                    @Override  
                    public boolean onQueryTextSubmit(String query) {  
                            searchView.clearFocus();  
                     _search(query);

                            return false;  
              }

                    @Override  
                    public boolean onQueryTextChange(String newText) {  

                            return false;  
                        }  
                }); 
    return super.onCreateOptionsMenu(menu);
}

@Override
public void onBackPressed() {
    if (_drawer.isDrawerOpen(GravityCompat.START)) {
        _drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}
public void _rn() {
    rn_asura_popular.startRequestNetwork(RequestNetworkController.GET, "https://asura.gg/manga/?page=1&order=update", "A", _rn_asura_popular_request_listener);
}

public void _search(final String _query) {
    SketchwareUtil.showMessage(getApplicationContext(), _query);
}

public class Recyclerview1Adapter extends RecyclerView.Adapter<Recyclerview1Adapter.ViewHolder> {

    ArrayList<HashMap<String, Object>> _data;

    public Recyclerview1Adapter(ArrayList<HashMap<String, Object>> _arr) {
        _data = _arr;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater _inflater = getLayoutInflater();
        View _v = _inflater.inflate(R.layout.popular_items, null);
        RecyclerView.LayoutParams _lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        _v.setLayoutParams(_lp);
        return new ViewHolder(_v);
    }

    @Override
    public void onBindViewHolder(ViewHolder _holder, final int _position) {
        View _view = _holder.itemView;

        final androidx.cardview.widget.CardView cardview1 = _view.findViewById(R.id.cardview1);
        final LinearLayout linear1 = _view.findViewById(R.id.linear1);
        final ImageView imageview1 = _view.findViewById(R.id.imageview1);
        final TextView title = _view.findViewById(R.id.title);
        final TextView type = _view.findViewById(R.id.type);
        final TextView chapter = _view.findViewById(R.id.chapter);

        title.setSelected(true);
        cardview1.setRadius((float)10);
        cardview1.setCardElevation((float)3);
        cardview1.setPreventCornerOverlap(true);
        type.setBackground(new GradientDrawable() { public GradientDrawable getIns(int a, int b) { this.setCornerRadius(a); this.setColor(b); return this; } }.getIns((int)8, 0xFF9C27B0));
        try {
            if (popular_today_listmap.get((int)_position).containsKey("title")) {
                title.setText(popular_today_listmap.get((int)_position).get("title").toString());
            }
            else {

            }
            if (popular_today_listmap.get((int)_position).containsKey("chapter")) {
                chapter.setText(popular_today_listmap.get((int)_position).get("chapter").toString());
            }
            else {

            }
            if (popular_today_listmap.get((int)_position).containsKey("cover")) {
                Glide.with(getApplicationContext()).load(Uri.parse(popular_today_listmap.get((int)_position).get("cover").toString())).into(imageview1);
            }
            else {
                imageview1.setImageResource(R.drawable.default_image);
            }
            if (popular_today_listmap.get((int)_position).containsKey("type")) {
                type.setText(popular_today_listmap.get((int)_position).get("type").toString().toUpperCase());
            }
            else {

            }
            cardview1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View _view) {
                    if (popular_today_listmap.get((int)_position).containsKey("link")) {
                        SketchwareUtil.showMessage(getApplicationContext(), popular_today_listmap.get((int)_position).get("link").toString());
                    }
                    else {

                    }
                }
            });
        } catch (Exception e) {
            SketchwareUtil.showMessage(getApplicationContext(), e.toString());
        }
        RecyclerView.LayoutParams _lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            _view.setLayoutParams(_lp);
    }

    @Override
    public int getItemCount() {
        return _data.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public ViewHolder(View v) {
            super(v);
        }
    }
}

@Deprecated
public void showMessage(String _s) {
    Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show();
}

@Deprecated
public int getLocationX(View _v) {
    int _location[] = new int[2];
    _v.getLocationInWindow(_location);
    return _location[0];
}

@Deprecated
public int getLocationY(View _v) {
    int _location[] = new int[2];
    _v.getLocationInWindow(_location);
    return _location[1];
}

@Deprecated
public int getRandom(int _min, int _max) {
    Random random = new Random();
    return random.nextInt(_max - _min + 1) + _min;
}

@Deprecated
public ArrayList<Double> getCheckedItemPositionsToArray(ListView _list) {
    ArrayList<Double> _result = new ArrayList<Double>();
    SparseBooleanArray _arr = _list.getCheckedItemPositions();
    for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) {
        if (_arr.valueAt(_iIdx))
        _result.add((double)_arr.keyAt(_iIdx));
    }
    return _result;
}

@Deprecated
public float getDip(int _input) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics());
}

@Deprecated
public int getDisplayWidthPixels() {
    return getResources().getDisplayMetrics().widthPixels;
}

@Deprecated
public int getDisplayHeightPixels() {
    return getResources().getDisplayMetrics().heightPixels;
}

}

hasrat-ali commented 1 year ago

Did you a added any custom import statement?

hasrat-ali commented 1 year ago

Did you notice a . before ; in import statement?

hasrat-ali commented 1 year ago

There should be a * or a qualifier name after . and before ;

IamHomen commented 1 year ago

There should be a * or a qualifier name after . and before ;

it seems like theres a problem in copy paste, but on my source code it has * and this is my only custom import Screenshot_20221130-134245

seifaldeen1 commented 1 year ago

How do I add an array parameter?

في الثلاثاء، ١٤ فبراير ٢٠٢٣, ١٢:٤٨ م Hakan @.***> كتب:

i have the same problem.. i just added swiperefreshlayout (and code to hide the spinner when it loads) and got this: [image: Screenshot_2023-02-14-12-40-14] https://user-images.githubusercontent.com/103432992/218697762-3d38d644-8e11-4f99-8bd3-7a72d5734f19.jpg entire source code:

import android.Manifest; import android.animation.; import android.app.; import android.app.Activity; import android.app.DialogFragment; import android.app.Fragment; import android.app.FragmentManager; import android.content.; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.; import android.graphics.; import android.graphics.drawable.; import android.media.; import android.net.; import android.net.Uri; import android.os.; import android.os.Bundle; import android.text.; import android.text.style.; import android.util.; import android.view.; import android.view.View.; import android.view.animation.; import android.webkit.; import android.widget.; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.ListView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener; import java.io.; import java.io.InputStream; import java.text.; import java.util.; import java.util.ArrayList; import java.util.HashMap; import java.util.regex.; import org.json.;

public class MainActivity extends Activity {

private double TempCounter = 0; private String CurrentDir = ""; private String FilePath = ""; private double FileSize = 0; private String tempString = "";

private ArrayList<HashMap<String, Object>> FileList = new ArrayList<>(); private ArrayList Files = new ArrayList<>();

private ListView listview1; private SwipeRefreshLayout swiperefreshlayout1;

private Intent ActivityStarter = new Intent();

@Override protected void onCreate(Bundle _savedInstanceState) { super.onCreate(_savedInstanceState); setContentView(R.layout.main); initialize(_savedInstanceState);

  if (Build.VERSION.SDK_INT >= 23) {
      if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
          requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, 1000);
      } else {
          initializeLogic();
      }
  } else {
      initializeLogic();
  }

}

@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == 1000) { initializeLogic(); } }

private void initialize(Bundle _savedInstanceState) { listview1 = findViewById(R.id.listview1); swiperefreshlayout1 = findViewById(R.id.swiperefreshlayout1);

  listview1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> _param1, View _param2, int _param3, long _param4) {
          final int _position = _param3;
          if (FileUtil.isDirectory(FileList.get((int)_position).get("FilePath").toString())) {
              _LoadDir(FileList.get((int)_position).get("FilePath").toString());
          }
          else {
              try{
                  ActivityStarter.setAction(Intent.ACTION_VIEW);
                  ActivityStarter.setData(Uri.parse("file://".concat(FileList.get((int)_position).get("FilePath").toString())));
                  ActivityStarter.setType(_GetMimeType(FileList.get((int)_position).get("FilePath").toString()));
                  SketchwareUtil.showMessage(getApplicationContext(), "file://".concat(FileList.get((int)_position).get("FilePath").toString()));
                  startActivity(ActivityStarter);
              }catch(Exception e){
                  SketchwareUtil.showMessage(getApplicationContext(), "Cannot view file");
              }
          }
      }
  });

  listview1.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
      @Override
      public boolean onItemLongClick(AdapterView<?> _param1, View _param2, int _param3, long _param4) {
          final int _position = _param3;

          return true;
      }
  });

  swiperefreshlayout1.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
      @Override
      public void onRefresh() {
          _LoadDir(CurrentDir);
          swiperefreshlayout1.setRefreshing(false);
      }
  });

}

private void initializeLogic() { _LoadDir("/storage/emulated/0"); }

@Override public void onBackPressed() { _LoadDir(CurrentDir.substring((int)(0), (int)((CurrentDir.length() - Uri.parse(CurrentDir).getLastPathSegment().length()) - 0))); } public void _AddFile(final String _FilePath) { { HashMap<String, Object> _item = new HashMap<>(); _item.put("FilePath", _FilePath); FileList.add(_item); }

  listview1.setAdapter(new Listview1Adapter(FileList));
  ((BaseAdapter)listview1.getAdapter()).notifyDataSetChanged();

}

public void _LoadDir(final String _Path) { CurrentDir = _Path; FileList.clear(); listview1.setAdapter(new Listview1Adapter(FileList)); ((BaseAdapter)listview1.getAdapter()).notifyDataSetChanged(); FileUtil.listDir(_Path, Files); TempCounter = 0; for(int _repeat12 = 0; _repeat12 < (int)(Files.size()); _repeat12++) { if (FileUtil.isDirectory(Files.get((int)(TempCounter)))) { _AddFile(Files.get((int)(TempCounter))); TempCounter++; } } TempCounter = 0; for(int _repeat26 = 0; _repeat26 < (int)(Files.size()); _repeat26++) { if (!FileUtil.isDirectory(Files.get((int)(TempCounter)))) { _AddFile(Files.get((int)(TempCounter))); } TempCounter++; } }

public boolean _IsExtension(final String _Path, final String _Extension) { return (_Path.substring((int)(_Path.length() - _Extension.length()), (int)(_Path.length())).equals(_Extension)); }

public String _GetMimeType(final String _Path) { String extension = _Path.substring(_Path.lastIndexOf(".")); String mimeTypeMap = MimeTypeMap.getFileExtensionFromUrl(extension); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeTypeMap); return mimeType; }

public class Listview1Adapter extends BaseAdapter {

  ArrayList<HashMap<String, Object>> _data;

  public Listview1Adapter(ArrayList<HashMap<String, Object>> _arr) {
      _data = _arr;
  }

  @Override
  public int getCount() {
      return _data.size();
  }

  @Override
  public HashMap<String, Object> getItem(int _index) {
      return _data.get(_index);
  }

  @Override
  public long getItemId(int _index) {
      return _index;
  }

  @Override
  public View getView(final int _position, View _v, ViewGroup _container) {
      LayoutInflater _inflater = getLayoutInflater();
      View _view = _v;
      if (_view == null) {
          _view = _inflater.inflate(R.layout.filelistitem, null);
      }

      final LinearLayout linear1 = _view.findViewById(R.id.linear1);
      final ImageView Icon = _view.findViewById(R.id.Icon);
      final LinearLayout linear2 = _view.findViewById(R.id.linear2);
      final TextView Filename = _view.findViewById(R.id.Filename);
      final TextView Info = _view.findViewById(R.id.Info);

      FilePath = _data.get((int)_position).get("FilePath").toString();
      Filename.setText(Uri.parse(_data.get((int)_position).get("FilePath").toString()).getLastPathSegment());
      if (FileUtil.isDirectory(_data.get((int)_position).get("FilePath").toString())) {
          Icon.setImageResource(R.drawable.folder);
          Info.setText("Folder");
      }
      else {
          Icon.setImageResource(R.drawable.file);
          java.io.File file = new java.io.File(FilePath);
          FileSize = file.length();
          Info.setText(String.valueOf((long)(Math.floor(FileSize / 1024))).concat("KB"));
      }

      return _view;
  }

}

@Deprecated public void showMessage(String _s) { Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); }

@Deprecated public int getLocationX(View _v) { int _location[] = new int[2]; _v.getLocationInWindow(_location); return _location[0]; }

@Deprecated public int getLocationY(View _v) { int _location[] = new int[2]; _v.getLocationInWindow(_location); return _location[1]; }

@Deprecated public int getRandom(int _min, int _max) { Random random = new Random(); return random.nextInt(_max - _min + 1) + _min; }

@Deprecated public ArrayList getCheckedItemPositionsToArray(ListView _list) { ArrayList _result = new ArrayList(); SparseBooleanArray _arr = _list.getCheckedItemPositions(); for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { if (_arr.valueAt(_iIdx)) _result.add((double)_arr.keyAt(_iIdx)); } return _result; }

@Deprecated public float getDip(int _input) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); }

@Deprecated public int getDisplayWidthPixels() { return getResources().getDisplayMetrics().widthPixels; }

@Deprecated public int getDisplayHeightPixels() { return getResources().getDisplayMetrics().heightPixels; } }```

— Reply to this email directly, view it on GitHub https://github.com/Sketchware-Pro/Sketchware-Pro/issues/663#issuecomment-1429434735, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3MW3UYTUVK5JK7GHAP3QKDWXNIHFANCNFSM6AAAAAASOKW3CU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

JavkhlanK commented 1 year ago

@HAKANKOKCU your problem isn't related to this one, and neither is a bug. You just have to enable AppCompat.

@seifaldeen1 don't ask in more than one opened Issue about a problem, otherwise you're spamming.

JavkhlanK commented 10 months ago

It doesn't look like any more info about the issue will be sent anytime soon, so I'll close this.

Please re-open this or a new Issue only with more details.