2017-11-04 10 views
0

私はバックエンドとして解析を使用しています。そして私は10秒ごとに自分の活動を反復しています。そして、限り、私はリストにparseobjectsを保存し、それを使用して、新しいリストがクラスを解析するかどうかを知ることを知っている。今、私は 解析クラスに新しい行が追加されているかどうかを確認するには

  • は(もし(新しい行が追加された場合)(行が削除される場合)
  • 更新リサイクラービューを
  • 更新リサイクラービューを通知し、更新リサイクルビューを表示されている3つのことをやりたいです上記のいずれの条件も発生しません)

私は2つのArrayListを作成しました。以下は

private List<Rqst_G_S> list = new ArrayList<>(); // Parse List 
    private List<Rqst_G_S> updatedList = new ArrayList<>(); //Local List 

IAMのアプリが最初に実行されている場合、通知が表示されているが、解析リストは、通知が表示されていないされ、更新リストよりも大きいときはいつでも後.ANYは、私が何を推測

if (updatedList.size() > list.size()) { 
      recyclerView.setNestedScrollingEnabled(false); 
      VR_Adapter load = new VR_Adapter(ViewRequests.this, list); 
      LinearLayoutManager layoutManager = new LinearLayoutManager(ViewRequests.this); 
      recyclerView.setLayoutManager(layoutManager); 
      recyclerView.setAdapter(load); 
      updatedList = list; 

      Log.i("sandeep123", String.valueOf(updatedList.size() + "1 " + list.size())); 

     } else if (updatedList.size() < list.size()){ 
      Intent i = new Intent(ViewRequests.this, ViewRequests.class); 
      PendingIntent pendingIntent = PendingIntent.getActivity(ViewRequests.this, (int) System.currentTimeMillis(), i, PendingIntent.FLAG_ONE_SHOT); 

      NotificationCompat.Builder noti = null; 
      noti = new NotificationCompat.Builder(getApplicationContext()) 
        .setContentTitle("Requester Requested You") 
        .setContentText("From ") 
        .setStyle(new NotificationCompat.BigTextStyle().bigText("From ")) 
        .setAutoCancel(true) 
        // .setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.clean)) 
        .setOnlyAlertOnce(true) 
        .setOngoing(false) 
        .setPriority(Notification.PRIORITY_MAX) 
        .setContentIntent(pendingIntent) 
        .setColor(Color.parseColor("#1ABC9C")) 
        .setSmallIcon(R.drawable.icon); 


      NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
      assert noti != null; 

      notificationManager.notify((int) SystemClock.currentThreadTimeMillis(), noti.build()); 
      recyclerView.setNestedScrollingEnabled(false); 
      VR_Adapter load = new VR_Adapter(ViewRequests.this, list); 
      LinearLayoutManager layoutManager = new LinearLayoutManager(ViewRequests.this); 
      recyclerView.setLayoutManager(layoutManager); 
      recyclerView.setAdapter(load); 
      updatedList = list; 

      Log.i("sandeep1234", String.valueOf(updatedList.size() + "2 " + list.size())); 
     }else { 
      recyclerView.setNestedScrollingEnabled(false); 
      VR_Adapter load = new VR_Adapter(ViewRequests.this, list); 
      LinearLayoutManager layoutManager = new LinearLayoutManager(ViewRequests.this); 
      recyclerView.setLayoutManager(layoutManager); 
      recyclerView.setAdapter(load); 
      Log.i("sandeepabc", String.valueOf(updatedList.size() + "1 " + list.size())); 
     } 

をやって何です間違っている。

答えて

0

あなたの質問は非常にあいまいな言語を使用しています。 しかし、私はパースバックエンドから更新されたリストをフェッチし、あなたのUIでそれを更新したいと思いますか?そうであれば、プロセスは以下のようになります。

1.アクティビティが開始されたら、投稿 をrunnableに送信して、バックエンドからリストをフェッチするように、handlerを開始します。 handler.postDelayed()〜 を使用して、目的の時刻の後にフェッチを実行します。

2.更新されたオブジェクトのリストが利用可能になったら、recylerviewを作成するために使用したデータセットを新しいリストで上書きし、アダプタでnotifyDatasetChanged()を使用します。

関連する問題