-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from AlanCheen/develop
Develop 0.6.0 feature
- Loading branch information
Showing
25 changed files
with
411 additions
and
183 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
app/src/main/java/me/yifeiyuan/flapdev/DifferActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package me.yifeiyuan.flapdev; | ||
|
||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.support.annotation.NonNull; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.recyclerview.extensions.AsyncListDiffer; | ||
import android.support.v7.util.DiffUtil; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.Log; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import me.yifeiyuan.flap.FlapAdapter; | ||
import me.yifeiyuan.flapdev.simpletext.SimpleTextModel; | ||
|
||
/** | ||
* todo support | ||
* AsyncListDiffer | ||
* ListAdapter | ||
*/ | ||
public class DifferActivity extends AppCompatActivity { | ||
|
||
private static final String TAG = "DifferActivity"; | ||
|
||
private FlapAdapter flapAdapter; | ||
private AsyncListDiffer<SimpleTextModel> differ; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_differ); | ||
|
||
RecyclerView recyclerView = findViewById(R.id.rv_items); | ||
|
||
flapAdapter = new FlapAdapter(); | ||
|
||
List<SimpleTextModel> models = new ArrayList<>(); | ||
|
||
models.add(new SimpleTextModel("Android")); | ||
models.add(new SimpleTextModel("Java")); | ||
models.add(new SimpleTextModel("Kotlin")); | ||
|
||
flapAdapter.setModels(models); | ||
|
||
recyclerView.setAdapter(flapAdapter); | ||
|
||
differ = new AsyncListDiffer<SimpleTextModel>(flapAdapter, new DiffUtil.ItemCallback<SimpleTextModel>() { | ||
@Override | ||
public boolean areItemsTheSame(@NonNull final SimpleTextModel simpleTextModel, @NonNull final SimpleTextModel t1) { | ||
Log.d(TAG, "areItemsTheSame() called with: simpleTextModel = [" + simpleTextModel + "], t1 = [" + t1 + "]"); | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean areContentsTheSame(@NonNull final SimpleTextModel simpleTextModel, @NonNull final SimpleTextModel t1) { | ||
Log.d(TAG, "areContentsTheSame() called with: simpleTextModel = [" + simpleTextModel + "], t1 = [" + t1 + "]"); | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
changeModels(); | ||
} | ||
|
||
private void changeModels() { | ||
new Handler().postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
List<SimpleTextModel> newModels = new ArrayList<>(); | ||
newModels.add(new SimpleTextModel("iOS")); | ||
newModels.add(new SimpleTextModel("OC")); | ||
newModels.add(new SimpleTextModel("Kotlin")); | ||
flapAdapter.setModels(newModels); | ||
differ.submitList(newModels); | ||
} | ||
}, 5000); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/me/yifeiyuan/flapdev/FlapApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package me.yifeiyuan.flapdev; | ||
|
||
import android.app.Application; | ||
import android.util.Log; | ||
|
||
import me.yifeiyuan.flap.Flap; | ||
import me.yifeiyuan.flapdev.simpleimage.SimpleImageItem; | ||
import me.yifeiyuan.flapdev.simpleimage.SimpleImageModel; | ||
import me.yifeiyuan.flapdev.simpletext.SimpleTextItem; | ||
import me.yifeiyuan.flapdev.simpletext.SimpleTextModel; | ||
|
||
/** | ||
* Flap | ||
* Created by 程序亦非猿 on 2018/12/13. | ||
*/ | ||
public class FlapApplication extends Application { | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
Flap.setDebug(true); | ||
|
||
long t1 = System.currentTimeMillis(); | ||
|
||
Flap.getDefault().register(SimpleTextModel.class, new SimpleTextItem.SimpleTextItemFactory()); | ||
Flap.getDefault().register(SimpleImageModel.class, new SimpleImageItem.SimpleImageItemFactory()); | ||
|
||
long t2 = System.currentTimeMillis(); | ||
|
||
Log.e("Flap", "Init Flap time cost :" + (t2 - t1)); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.