title: Using recyclerview, Content of ftp is not displayed on the screen until phone is locked and unlocked again
body: <p>I want to display content from ftp using recycler view. However, the data is not reflecting in view unless I lock and unlock the phone once, while the application is running. I want to display the data as soon as the application launches using recycler view. Please help!</p>
  
  <p>This is how my code looks like</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.example.nishant.ftp1;
  
  import android.annotation.SuppressLint;
  import android.content.res.Configuration;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.app.Activity;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  import android.widget.Toast;
  
  import org.apache.commons.net.ftp.*;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class MainActivity extends Activity {
  
      public FTPClient mFTPClient = null;
      Button but;
      private RecyclerView.LayoutManager layoutManager;
      private ArrayList&lt;FileListObject&gt; fileList = new ArrayList&lt;&gt;();
      private RecyclerAdapter adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
          recyclerView.setHasFixedSize(true);
  
          layoutManager = new LinearLayoutManager(this);
          recyclerView.setLayoutManager(layoutManager);
  
          adapter = new RecyclerAdapter(fileList, this);
  
          recyclerView.setAdapter(adapter);
          new setUpList().execute();
      }
  
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
  
          RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
          recyclerView.setHasFixedSize(true);
  
          layoutManager = new LinearLayoutManager(this);
          recyclerView.setLayoutManager(layoutManager);
  
          Log.v("rec","in recycler");
          adapter = new RecyclerAdapter(fileList, this);
          recyclerView.setAdapter(adapter);
      }
  
  
     public class setUpList extends AsyncTask&lt;Object, Void, Object&gt; {
  
         String host = "test.rebex.net", username = "demo", password = "password";
         int port = 21;
  
         @Override
         protected Object doInBackground(Object[] objects) {
             try {
                 mFTPClient = new FTPClient();
                 // connecting to the host
                 mFTPClient.connect(host,port);
  
                 // Now check the reply code, if positive mean connection success
                  if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {
  
                     Log.v("wwww","Connected");
                     // Login using username &amp; password
                     boolean status = mFTPClient.login(username, password);
                     mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
                     mFTPClient.enterLocalPassiveMode();
  
                     String toppath=null;
  
                     try {
                         FTPFile[] ftpDirs = mFTPClient.listFiles("/pub/example/");
                         for (int i = 0; i &lt; ftpDirs.length; i++) 
                          {
                              toppath = ftpDirs[0].getName();
                              Log.d("CONNECT", "Directories in the ftp server are "+ ftpDirs[i].getName());
                              /*FileListObject fileListObject = new FileListObject(ftpDirs[i].getName());
                              fileList.add(fileListObject);*/
                              fileList.add(new FileListObject(ftpDirs[i].getName()));
                              // adapter.notifyDataSetChanged();
                          }
                          adapter.notifyDataSetChanged();
                      } catch (Exception e) {
                         e.printStackTrace();
                      }
                     return status;
                  }
              } catch (Exception e) {
                 return e;
              }
             return null;
          }
  
          public void onPostExecute(Object res) {
              if (res instanceof Exception) {
                 int d = Toast.LENGTH_SHORT;
                 Toast toast = Toast.makeText(getApplicationContext(), "" + res, d);
                 toast.show();
             }
         }
     }
  }
  </code></pre>
  
  <p>RecyclerAdapter.java</p>
  
  <pre><code>package com.example.nishant.ftp1;
  
  /**
   * Created by Nishant on 1/24/2018.
   */
  
  
  import android.content.Context;
  import android.content.Intent;
  import android.net.Uri;
  import android.support.v7.widget.RecyclerView;
  import android.text.Html;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * Created by Hitayu on 18-01-2018.
   */
  
  public class RecyclerAdapter extends RecyclerView.Adapter&lt;RecyclerAdapter.ViewHolder&gt; {
  
      private ArrayList&lt;FileListObject&gt; fileList = new ArrayList&lt;&gt;();
      private Context context;
  
      public RecyclerAdapter(ArrayList&lt;FileListObject&gt; fileList, Context context) {
          this.fileList = fileList;
          this.context = context;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_recycler_view,parent,false);
  
          return new ViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
  
          final FileListObject objec = fileList.get(position);
          Log.v("mmm",objec.getName());
          holder.fileText.setText(Html.fromHtml("&lt;u&gt;"+objec.getName()+"&lt;/u&gt;"));
  
          /*holder.linearLayout.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(objec.getLocation()));
                  context.startActivity(intent);
              }
          });*/
      }
  
      @Override
      public int getItemCount() {
          return fileList.size();
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder{
  
          public TextView fileText;
          public LinearLayout linearLayout;
  
          public ViewHolder(View itemView) {
              super(itemView);
  
              fileText = (TextView) itemView.findViewById(R.id.file);
              linearLayout = (LinearLayout) itemView.findViewById(R.id.layout);
          }
      }
  }
  </code></pre>
  
  <p>FileListObject.java</p>
  
  <pre><code>package com.example.nishant.ftp1;
  
  /**
   * Created by Nishant on 1/24/2018.
   */
  
  public class FileListObject {
      String name;
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public FileListObject(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>Manifests</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.nishant.ftp1"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"
              android:screenOrientation="portrait"&gt;
  
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>layout/activity_main.xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#F6F6F6"
      android:orientation="vertical"
      tools:context="com.example.nishant.ftp1.MainActivity"&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/recycler_view"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>layout/layout_recycler_view.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  
  &lt;LinearLayout android:id="@+id/layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;TextView
          android:id="@+id/file"
          android:layout_width="match_parent"
          android:textColor="@color/colorPrimaryDark"
          android:layout_height="wrap_content"
          android:textSize="18sp"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>