<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hyunjin Cho</title>
    <description>The latest articles on DEV Community by Hyunjin Cho (@hyunjin).</description>
    <link>https://dev.to/hyunjin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F762302%2F5e73f8bb-37b6-456c-a78b-96e0717ab991.jpeg</url>
      <title>DEV Community: Hyunjin Cho</title>
      <link>https://dev.to/hyunjin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hyunjin"/>
    <language>en</language>
    <item>
      <title>Aug 03rd, 2022</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Wed, 03 Aug 2022 18:46:45 +0000</pubDate>
      <link>https://dev.to/hyunjin/aug-03rd-2022-5589</link>
      <guid>https://dev.to/hyunjin/aug-03rd-2022-5589</guid>
      <description>&lt;p&gt;reacthook helps function component to use lifecycle and state.&lt;/p&gt;

&lt;p&gt;useEffect and useCallback are two examples of reacthook.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  useEffect
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;useEffect must be practiced after a page rendering.&lt;br&gt;
useEffect must be practiced after the linked state is updated.&lt;/p&gt;

&lt;p&gt;There are some ways to use this useEffect&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useEffect(() =&amp;gt; {})&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useEffect(() =&amp;gt; {}, [])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const [name, setName] = useState('hyun')&lt;br&gt;
useEffect(()=&amp;gt;, [name])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The first one is the most basic. &lt;br&gt;
but because there is no dependency (the second parameter in other ways), this useEffect will be practiced any time.&lt;/p&gt;

&lt;p&gt;The second one is practiced only once after the page rendering.&lt;/p&gt;

&lt;p&gt;The third one is practiced after the page rendering and when the state, that is, dependency(name) is updated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;clean-up&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useEffect(() =&amp;gt;{&lt;br&gt;
   console.log('mount')&lt;br&gt;
   return () =&amp;gt; {&lt;br&gt;
      console.log('unmount')}&lt;br&gt;
}, [])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;return ~ ('unmount')} returns function for clean-up&lt;/p&gt;

&lt;p&gt;when mounting, &lt;br&gt;
sending props to local state, request API, using library, setInterval, setTimeout....&lt;/p&gt;

&lt;p&gt;when unmounting,&lt;br&gt;
clearing the registered work(clearInterval, clearTimeout)...&lt;/p&gt;

</description>
      <category>useeffect</category>
      <category>reacthook</category>
    </item>
    <item>
      <title>April 5th, 2022</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Tue, 05 Apr 2022 21:22:10 +0000</pubDate>
      <link>https://dev.to/hyunjin/april-5th-2022-55hf</link>
      <guid>https://dev.to/hyunjin/april-5th-2022-55hf</guid>
      <description>&lt;p&gt;inside JavaScript,&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;function *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function test() {}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;also function can be value. That is, the function for the object's property is called &lt;strong&gt;method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;objectA = {&lt;br&gt;
    B : function() {}&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method is a function for the object's property&lt;br&gt;
Function is a function itself.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function includes method.&lt;br&gt;
Function is independent from object while a method is not.&lt;br&gt;
Method can access the data inside the class/object&lt;/p&gt;




&lt;p&gt;Property and Method&lt;/p&gt;

&lt;p&gt;Object is a case made of properties&lt;/p&gt;

&lt;p&gt;property is made of key-value pair&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;if value is function, we call that as method.&lt;/strong&gt;&lt;br&gt;
key is an identifier for identifying a property&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const person = {&lt;br&gt;
    name = 'hyunjin',&lt;br&gt;
    say = function (){console.log('hi')}&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;name = property, say = method&lt;/p&gt;

&lt;p&gt;the main who practice method is the object&lt;br&gt;
the main who practice function is the function itself.&lt;/p&gt;

</description>
      <category>function</category>
      <category>method</category>
    </item>
    <item>
      <title>April 5th, 2022</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Tue, 05 Apr 2022 20:59:41 +0000</pubDate>
      <link>https://dev.to/hyunjin/april-5th-2022-293n</link>
      <guid>https://dev.to/hyunjin/april-5th-2022-293n</guid>
      <description>&lt;p&gt;*&lt;em&gt;CORS *&lt;/em&gt;&lt;br&gt;
Cross-Origin Resource Sharing&lt;/p&gt;

&lt;p&gt;a HTTP header based mechanism used when requesting resource to another origin from an origin&lt;/p&gt;

&lt;p&gt;origin : like address for server&lt;/p&gt;

&lt;p&gt;&lt;a href="https://google.com:80"&gt;https://google.com:80&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;protocol : https://&lt;br&gt;
host : google.com&lt;br&gt;
port : :80&lt;/p&gt;

&lt;p&gt;the system that compare origins is activated under browser. That is, when the server receives the request from another origin, the server sends response unless there is a restriction that the server will take request from same origin. Then, browser will compare the response whether CORS is violated or not. &lt;/p&gt;

&lt;p&gt;browser : &lt;a href="https://hyunin.com"&gt;https://hyunin.com&lt;/a&gt;&lt;br&gt;
server : &lt;a href="https://server.com"&gt;https://server.com&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;send request to server &lt;/li&gt;
&lt;li&gt;send response to the browser&lt;/li&gt;
&lt;li&gt;the browser check if the origin is different or not. If different, the response is thrown.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Because of that, this CORS does not work between server communication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working of CORS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;when requesting resources from another origin, the application-browser- use HTTP protocol and the request header includes Origin with value&lt;/p&gt;

&lt;p&gt;Origin: &lt;a href="https://hyunjin.com"&gt;https://hyunjin.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then when the server send response, the response header includes Access-Control-Allow-Origin with allowed value. The browser will compare ACAO and request origin&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. when requesting preflight&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;preflight means the pre-request before actual request for checking if it is safe to send request. For this, OPTIONS method is used. &lt;/p&gt;

&lt;p&gt;browser send pre-request(OPTIONS/resources - Origin:&lt;a href="https://hyunjin.com"&gt;https://hyunjin.com&lt;/a&gt;) to the server&lt;br&gt;
the server send response(200 ok Access-Control-Allow-Origin: *) to the browser. &lt;br&gt;
browser send actual request to the server&lt;br&gt;
the server send response&lt;/p&gt;

&lt;p&gt;more specifically,&lt;br&gt;
In preflight,&lt;br&gt;
there are origin, Access-Control-Request-headers, Access-Control-Request-Method&lt;br&gt;
In the response to the preflight,&lt;br&gt;
there are Access-Control-Allow-Origin&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. simple request&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No preflight and others are same&lt;/p&gt;

&lt;p&gt;the condition for this,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the request method should be one of GET, HEAD, POST&lt;/li&gt;
&lt;li&gt;only Accept, Accept-Language, Content-Language, Content-Type, DPR, Downlink, Save-Data, Viewport-Width, Width should be used&lt;/li&gt;
&lt;li&gt;when content-type, application/x-www-form-urlencoded, multipart/form-data, text/plain&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;resource: &lt;a href="https://evan-moon.github.io/2020/05/21/about-cors/"&gt;https://evan-moon.github.io/2020/05/21/about-cors/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cors</category>
    </item>
    <item>
      <title>March 21, 2022</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Fri, 01 Apr 2022 04:37:35 +0000</pubDate>
      <link>https://dev.to/hyunjin/march-21-2022-5aj0</link>
      <guid>https://dev.to/hyunjin/march-21-2022-5aj0</guid>
      <description>&lt;p&gt;absolute vs relative &lt;/p&gt;

&lt;p&gt;absolute - px&lt;br&gt;
relative - %, v*, em, rem&lt;/p&gt;

&lt;p&gt;(16px is the pixel that the browser provides default)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;em&lt;/strong&gt;&lt;br&gt;
1em = 16px&lt;/p&gt;

&lt;p&gt;for example,&lt;br&gt;
parent &amp;gt; child&lt;/p&gt;

&lt;p&gt;.parent{&lt;br&gt;
    font-size: 8em;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;.child{&lt;br&gt;
   font-size: 0.5em;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;parent font size - 16px * 8 = 128px&lt;br&gt;
child font size - 128px(parent font size) * 0.5 = 64px&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;rem&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;root&lt;/strong&gt; em&lt;/p&gt;

&lt;p&gt;root = html&lt;/p&gt;

&lt;p&gt;parent &amp;gt; child&lt;/p&gt;

&lt;p&gt;.parent{&lt;br&gt;
    font-size: 8rem;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;.child{&lt;br&gt;
   font-size: 0.5rem;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;parent font size - 16px * 8 = 128px&lt;br&gt;
child font size - 16px * 0.5 = 8px&lt;/p&gt;

</description>
      <category>rem</category>
      <category>em</category>
      <category>css</category>
    </item>
    <item>
      <title>March 31th, 2022</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Thu, 31 Mar 2022 22:20:50 +0000</pubDate>
      <link>https://dev.to/hyunjin/march-31th-2022-d05</link>
      <guid>https://dev.to/hyunjin/march-31th-2022-d05</guid>
      <description>&lt;p&gt;React Hook - &lt;strong&gt;useEffect&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;can be used in component life cycle.. (mount, unmount, update...)&lt;br&gt;
After the page is rendering, the useEffect must be run once.&lt;br&gt;
When the dependencies that set in the array, the useEffect is run.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;useEffect(()=&amp;gt;{})&lt;/li&gt;
&lt;li&gt;useEffect(()=&amp;gt;{}, [])&lt;/li&gt;
&lt;li&gt;useEffect(()=&amp;gt;{}, [dependency])&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;1 -&amp;gt; basic, but not used usually. no dependency, loading anytime&lt;br&gt;
2 -&amp;gt; After the page rendering, the useEffect has be used only once.&lt;br&gt;
3 -&amp;gt; After the page rendering, the useEffect has run one time and run again when the dependency (value in the array) is changed. &lt;/p&gt;

&lt;p&gt;What to do in useEffect&lt;/p&gt;

&lt;p&gt;useEffect(() =&amp;gt; {&lt;br&gt;
    console.log('mount')&lt;br&gt;
    return () =&amp;gt; {&lt;br&gt;
      console.log('unmount)}&lt;br&gt;
, []}&lt;/p&gt;

&lt;p&gt;1st param = function &lt;br&gt;
2nd param = dependency array&lt;/p&gt;

&lt;p&gt;return part is clean up part&lt;/p&gt;

&lt;p&gt;when mount, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;set props to state&lt;/li&gt;
&lt;li&gt;request API&lt;/li&gt;
&lt;li&gt;use library&lt;/li&gt;
&lt;li&gt;iteration with setInterval&lt;/li&gt;
&lt;li&gt;work with setTimeOut&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;when unmount,&lt;/p&gt;

&lt;p&gt;clean the registered work(clearInterval, clearTimeout)&lt;br&gt;
clean the library instance&lt;/p&gt;

&lt;p&gt;When not setting props that are used in useEffect to dependency array, the function in useEffect cannot point out the latest props.&lt;/p&gt;

&lt;p&gt;React Hook - &lt;strong&gt;useCallback&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;reuse the already created function&lt;/p&gt;

&lt;p&gt;When defining the function like the before, the function is created every time the rendering.&lt;/p&gt;

&lt;p&gt;const onRemove = id =&amp;gt; {&lt;br&gt;
  setUsers(users.filter(user =&amp;gt; user.id !== id));&lt;br&gt;
}; &lt;/p&gt;

&lt;p&gt;const onRemove = &lt;strong&gt;useCallback&lt;/strong&gt;(id =&amp;gt;{&lt;br&gt;
    setUsers(users.filter(user =&amp;gt; user.id !== id));&lt;br&gt;
}, [users])&lt;/p&gt;

</description>
      <category>react</category>
      <category>useeffect</category>
      <category>usecallback</category>
    </item>
    <item>
      <title>[PWA] Useful website</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Wed, 22 Dec 2021 21:48:40 +0000</pubDate>
      <link>https://dev.to/hyunjin/pwa-useful-website-di3</link>
      <guid>https://dev.to/hyunjin/pwa-useful-website-di3</guid>
      <description>&lt;p&gt;The step...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Host my application using github or ngrok
&lt;a href="https://ngrok.com/"&gt;https://ngrok.com/&lt;/a&gt;
(for running the exe file, i used powershell)&lt;/li&gt;
&lt;li&gt;Go to this website: &lt;a href="https://www.pwabuilder.com/"&gt;https://www.pwabuilder.com/&lt;/a&gt;
it will check my application is enough for PWA&lt;/li&gt;
&lt;li&gt;It will show my application is not enough
3-1. Create manifest.json and service worker using that website
3-2. Also recommend this: &lt;a href="https://manifest-gen.netlify.app/"&gt;https://manifest-gen.netlify.app/&lt;/a&gt;
3-3. The netlify is better when creating manifest.json file. &lt;/li&gt;
&lt;li&gt;Downloading a new package from &lt;a href="https://www.pwabuilder.com/"&gt;https://www.pwabuilder.com/&lt;/a&gt; after being done of creating needed files and move to my application folder.&lt;/li&gt;
&lt;li&gt;Following this step: &lt;a href="https://github.com/pwa-builder/pwabuilder-web/blob/V2/src/assets/next-steps.md"&gt;https://github.com/pwa-builder/pwabuilder-web/blob/V2/src/assets/next-steps.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;and test it again and it will show my application is enough for PWA&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>pwa</category>
    </item>
    <item>
      <title>[Android Studio] Duplicate value</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Sat, 04 Dec 2021 23:22:47 +0000</pubDate>
      <link>https://dev.to/hyunjin/android-studio-duplicate-value-2pki</link>
      <guid>https://dev.to/hyunjin/android-studio-duplicate-value-2pki</guid>
      <description>&lt;p&gt;Three arrayList:&lt;br&gt;
Two for ArrayList - will take information of movie&lt;br&gt;
One for ArrayList - will take movie id of the movie&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Add all movie information object from database to reviewedArrayList(ArrayList)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;While looping the reviewedArrayList, check if the movieIDArrayList(ArrayList) contains the movie id. When it does not have it, add it to movieIDArrayList and add the information object containing the movie id to newList(ArrayList) and if not, skip it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give newList which does not have duplicated value(movie id) to somewhere that I want to use.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  public void onDataChange(@NonNull DataSnapshot snapshot) {
                reviewedArrayList = new ArrayList&amp;lt;&amp;gt;();
                movieIDArrayList = new ArrayList&amp;lt;&amp;gt;();
                newList = new ArrayList&amp;lt;&amp;gt;();
                for(DataSnapshot childSnapshot: snapshot.getChildren()){
                    Playlist playlist = childSnapshot.getValue(Playlist.class);
                    reviewedArrayList.add(playlist);

                    for(int i=0; i &amp;lt; reviewedArrayList.size(); i++){
                        String mID = reviewedArrayList.get(i).mID;
                        if(!movieIDArrayList.contains(mID)){
                            movieIDArrayList.add(mID);
                            newList.add(reviewedArrayList.get(i));
                        }
                    }

                }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>android</category>
    </item>
    <item>
      <title>[Python] TypeError 'module' object is not callable in Python</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Thu, 02 Dec 2021 21:42:31 +0000</pubDate>
      <link>https://dev.to/hyunjin/python-typeerror-module-object-is-not-callable-in-python-533j</link>
      <guid>https://dev.to/hyunjin/python-typeerror-module-object-is-not-callable-in-python-533j</guid>
      <description>&lt;p&gt;'module' object is not callable&lt;/p&gt;

&lt;p&gt;-&amp;gt; when module name and class name are confused, this error raised&lt;/p&gt;

&lt;p&gt;For example,&lt;/p&gt;

&lt;p&gt;I have DBCM class inside dbcm.py and import DBCM class like this,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import dbcm

# do something with dbcm
with dbcm(slef.db_name, sql):
 .....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will raise that typeerror. &lt;/p&gt;

&lt;p&gt;How to solve it,&lt;/p&gt;

&lt;p&gt;Be clear which one is module and which one is class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from dbcm import DBCM as db_cm

with db_cm(self.db_name, sql):
 ....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modified by Keoni Garner - Thank you!:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from dbcm import DBCM

with DBCM(self.db_name, sql):
 ....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resource: &lt;a href="https://www.stechies.com/typeerror-module-object-is-not-callable/"&gt;https://www.stechies.com/typeerror-module-object-is-not-callable/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>typeerror</category>
    </item>
    <item>
      <title>Android Studio/Firebase(1)</title>
      <dc:creator>Hyunjin Cho</dc:creator>
      <pubDate>Thu, 25 Nov 2021 21:30:57 +0000</pubDate>
      <link>https://dev.to/hyunjin/android-studiofirebase1-10f1</link>
      <guid>https://dev.to/hyunjin/android-studiofirebase1-10f1</guid>
      <description>&lt;p&gt;Structure&lt;br&gt;
root &lt;/p&gt;

&lt;h2&gt;
  
  
  -- Comments
&lt;/h2&gt;

&lt;h3&gt;
  
  
  -- movidID
&lt;/h3&gt;

&lt;h4&gt;
  
  
  -- commentID
&lt;/h4&gt;

&lt;h2&gt;
  
  
  -- Playlist
&lt;/h2&gt;

&lt;h3&gt;
  
  
  -- userID
&lt;/h3&gt;

&lt;h4&gt;
  
  
  -- playlistID
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//rootNode
FirebaseDatabase rootNode = FirebaseDatabase.getInstance();
//reference
DatabaseReference reference;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  // When adding one movie to the playlist
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reference = rootNode.getReference("Playlist").child(userID).push();

Playlist playlist = new Playlist(id, userID, img_path, playRef.getKey());

reference .setValue(playlist).addOnSuccessListener(new OnSuccessListener&amp;lt;Void&amp;gt;() {
                @Override
                public void onSuccess(Void unused) {
                    // work of button for adding and removing
                    btn_playlist.setVisibility(View.INVISIBLE);
                    btn_playlist.setEnabled(false);
                    btn_remove.setVisibility(View.VISIBLE);
                    btn_remove.setEnabled(true);
                }
            })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  // When removing one movie from the playlist
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DatabaseReference playcheckref = rootNode.getReference().child("Playlist").child(userID);

playcheckref.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                for(DataSnapshot dataSnapshot : snapshot.getChildren()) {

// if there is the clicked movie in the list                   if(Objects.requireNonNull(dataSnapshot.getValue(Playlist.class)).getmID().equals(id)){
                        btn_playlist.setVisibility(View.INVISIBLE);
                        btn_playlist.setEnabled(false);
                        btn_remove.setVisibility(View.VISIBLE);
                        btn_remove.setEnabled(true);

// grab the playlist movie id
                        String vID = Objects.requireNonNull(dataSnapshot.getValue(Playlist.class)).getvID();
                        btn_remove.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                btn_playlist.setVisibility(View.VISIBLE);
                                btn_playlist.setEnabled(true);
                                btn_remove.setVisibility(View.INVISIBLE);
                                btn_remove.setEnabled(false);

                                DatabaseReference removeRef = rootNode.getReference("Playlist").child(userID).child(vID);
                                removeRef.setValue(null);

                                Toast.makeText(MovieDetail.this, "Successfully deleted" + Objects.requireNonNull(dataSnapshot.getValue(Playlist.class)).getvID(), Toast.LENGTH_SHORT).show();
                            }
                        });

                    } else{
                        btn_playlist.setOnClickListener(addMovieToList);
                    }
                }
            }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>android</category>
      <category>firebase</category>
    </item>
  </channel>
</rss>
