Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onStickerSelectEventListener issue #9

Open
maheeraeron opened this issue Jun 29, 2020 · 3 comments
Open

onStickerSelectEventListener issue #9

maheeraeron opened this issue Jun 29, 2020 · 3 comments

Comments

@maheeraeron
Copy link

maheeraeron commented Jun 29, 2020

Hello, I am trying to use your library for an app I am making in Android with Kotlin (even though this was made in Java, I am able to invoke any function used here in Kotlin as well)

I have my timeTable set up with two dummy schedules. I added the schedules to the time table, so their stickers DO show up on the timeTableView UI.

After that, I made a binding by doing timeTable.setOnStickerSelectListener. I am able to access IDX and an array list of stickers.

My issue is that when I click on a sticker, IDX is still 0. Is that supposed to happen? Is IDX supposed to represent a unique ID for each sticker? How can I capture the sticker that was just selected properly, and convert that to a Schedule object?

@devbrianmedina
Copy link

devbrianmedina commented Jan 30, 2021

I had the same problem.
The error is in the file "TimetableView.java"

Affected lines:

int count = specIdx < 0 ? ++stickerCount : specIdx;
int finalCount = count;
count = count + 1;

So was my code that solves it:

private void add(final ArrayList schedules, int specIdx) {
int count = specIdx < 0 ? ++stickerCount : specIdx;
Sticker sticker = new Sticker();
for (Schedule schedule : schedules) {
TextView tv = new TextView(context);

       RelativeLayout.LayoutParams param = createStickerParam(schedule);
       tv.setLayoutParams(param);
       tv.setPadding(10, 0, 10, 0);
       tv.setText(schedule.getClassTitle() + "\n" + schedule.getClassPlace());
       tv.setTextColor(Color.parseColor("#FFFFFF"));
       tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_STICKER_FONT_SIZE_DP);
       tv.setTypeface(null, Typeface.BOLD);

       int finalCount = count;
       tv.setOnClickListener(new OnClickListener() {
           @Override
           public void onClick(View v) {
               if(stickerSelectedListener != null){
                   stickerSelectedListener.OnStickerSelected(finalCount, schedules);
               }
           }
       });

       sticker.addTextView(tv);
       sticker.addSchedule(schedule);
       stickers.put(count, sticker);
       stickerBox.addView(tv);
       count = count + 1;
   }
   setStickerColor();

}

@Chrineri
Copy link

@BrianMedina0903 how did you override the method?

@shashankdaima
Copy link

Thanks @devbrianmedina

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants