Address a few warnings and suggestions for Android sample app
Summary: ^ Reviewed By: LukeDefeo Differential Revision: D39575170 fbshipit-source-id: 8be293fe31521531e634132e4ca454da32aad73f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
84dc95b27b
commit
1fac19facc
@@ -26,66 +26,36 @@ public class AnimationsActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_animations);
|
||||
|
||||
btnBlink = (Button) findViewById(R.id.btnBlink);
|
||||
btnRotate = (Button) findViewById(R.id.btnRotate);
|
||||
btnMove = (Button) findViewById(R.id.btnMove);
|
||||
btnBounce = (Button) findViewById(R.id.btnBounce);
|
||||
btnSequential = (Button) findViewById(R.id.btnSequential);
|
||||
txtBlink = (TextView) findViewById(R.id.txt_blink);
|
||||
txtRotate = (TextView) findViewById(R.id.txt_rotate);
|
||||
txtMove = (TextView) findViewById(R.id.txt_move);
|
||||
txtBounce = (TextView) findViewById(R.id.txt_bounce);
|
||||
txtSeq = (TextView) findViewById(R.id.txt_seq);
|
||||
btnBlink = findViewById(R.id.btnBlink);
|
||||
btnRotate = findViewById(R.id.btnRotate);
|
||||
btnMove = findViewById(R.id.btnMove);
|
||||
btnBounce = findViewById(R.id.btnBounce);
|
||||
btnSequential = findViewById(R.id.btnSequential);
|
||||
txtBlink = findViewById(R.id.txt_blink);
|
||||
txtRotate = findViewById(R.id.txt_rotate);
|
||||
txtMove = findViewById(R.id.txt_move);
|
||||
txtBounce = findViewById(R.id.txt_bounce);
|
||||
txtSeq = findViewById(R.id.txt_seq);
|
||||
|
||||
animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
|
||||
// blink
|
||||
btnBlink.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
txtBlink.setVisibility(View.VISIBLE);
|
||||
txtBlink.startAnimation(animBlink);
|
||||
}
|
||||
v -> {
|
||||
txtBlink.setVisibility(View.VISIBLE);
|
||||
txtBlink.startAnimation(animBlink);
|
||||
});
|
||||
|
||||
animRotate = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate);
|
||||
|
||||
// Rotate
|
||||
btnRotate.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
txtRotate.startAnimation(animRotate);
|
||||
}
|
||||
});
|
||||
btnRotate.setOnClickListener(v -> txtRotate.startAnimation(animRotate));
|
||||
animMove = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
|
||||
// Move
|
||||
btnMove.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
txtMove.startAnimation(animMove);
|
||||
}
|
||||
});
|
||||
|
||||
btnMove.setOnClickListener(v -> txtMove.startAnimation(animMove));
|
||||
|
||||
animBounce = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
|
||||
// Slide Down
|
||||
btnBounce.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
txtBounce.startAnimation(animBounce);
|
||||
}
|
||||
});
|
||||
animSequential = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.sequential);
|
||||
// Sequential
|
||||
btnSequential.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
txtSeq.startAnimation(animSequential);
|
||||
}
|
||||
});
|
||||
btnBounce.setOnClickListener(v -> txtBounce.startAnimation(animBounce));
|
||||
animSequential = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.sequential);
|
||||
|
||||
btnSequential.setOnClickListener(v -> txtSeq.startAnimation(animSequential));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ public class ButtonsActivity extends FragmentActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_buttons);
|
||||
|
||||
text = (TextView) findViewById(R.id.count);
|
||||
text = findViewById(R.id.count);
|
||||
|
||||
button = (Button) findViewById(com.facebook.flipper.sample.R.id.btn_inc);
|
||||
dialogOld = (Button) findViewById(R.id.dialog_old_api);
|
||||
dialogFragment = (Button) findViewById(R.id.dialog_fragment);
|
||||
button = findViewById(com.facebook.flipper.sample.R.id.btn_inc);
|
||||
dialogOld = findViewById(R.id.dialog_old_api);
|
||||
dialogFragment = findViewById(R.id.dialog_fragment);
|
||||
button.setOnClickListener(view -> ButtonsActivity.this.text.setText(String.valueOf(++count)));
|
||||
|
||||
dialogFragment.setOnClickListener(
|
||||
|
||||
@@ -24,6 +24,8 @@ public class FlipperSampleApplication extends Application {
|
||||
Fresco.initialize(this);
|
||||
|
||||
final FlipperClient client = AndroidFlipperClient.getInstance(this);
|
||||
assert client != null;
|
||||
|
||||
final FlipperInitializer.IntializationResult initializationResult =
|
||||
FlipperInitializer.initFlipperPlugins(this, client);
|
||||
|
||||
|
||||
@@ -15,39 +15,39 @@ import android.widget.TextView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class FragmentTestFragment extends Fragment {
|
||||
View mView;
|
||||
int mTicker;
|
||||
View view;
|
||||
int ticker;
|
||||
|
||||
public FragmentTestFragment() {
|
||||
mTicker = 0;
|
||||
ticker = 0;
|
||||
}
|
||||
|
||||
private void updateTicker() {
|
||||
try {
|
||||
ViewGroup viewGroup = (ViewGroup) mView;
|
||||
ViewGroup viewGroup = (ViewGroup) view;
|
||||
TextView textView = (TextView) viewGroup.getChildAt(1);
|
||||
String text = String.valueOf(mTicker++);
|
||||
String text = String.valueOf(ticker++);
|
||||
|
||||
textView.setText(text);
|
||||
} finally {
|
||||
// 100% guarantee that this always happens, even if
|
||||
// your update method throws an exception
|
||||
mView.postDelayed(
|
||||
view.postDelayed(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateTicker();
|
||||
}
|
||||
},
|
||||
10000);
|
||||
1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
mView = inflater.inflate(R.layout.fragment_test, container, false);
|
||||
mView.postDelayed(
|
||||
view = inflater.inflate(R.layout.fragment_test, container, false);
|
||||
view.postDelayed(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -56,6 +56,6 @@ public class FragmentTestFragment extends Fragment {
|
||||
},
|
||||
1000);
|
||||
|
||||
return mView;
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ListActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_list);
|
||||
|
||||
listView = (ListView) findViewById(R.id.list);
|
||||
listView = findViewById(R.id.list);
|
||||
|
||||
list = new ArrayList<>();
|
||||
list.add("Apple");
|
||||
@@ -33,7 +33,7 @@ public class ListActivity extends Activity {
|
||||
list.add("Orange");
|
||||
list.add("Lychee");
|
||||
list.add("Guava");
|
||||
list.add("Peech");
|
||||
list.add("Peach");
|
||||
list.add("Melon");
|
||||
list.add("Watermelon");
|
||||
list.add("Papaya");
|
||||
|
||||
@@ -29,7 +29,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
final FlipperClient client = AndroidFlipperClient.getInstanceIfInitialized();
|
||||
if (client != null) {
|
||||
final ExampleFlipperPlugin samplePlugin = client.getPluginByClass(ExampleFlipperPlugin.class);
|
||||
samplePlugin.setActivity(this);
|
||||
if (samplePlugin != null) {
|
||||
samplePlugin.setActivity(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@ package com.facebook.flipper.sample;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
public class TestDialogFragment extends DialogFragment {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// Use the Builder class for convenient dialog construction
|
||||
|
||||
Reference in New Issue
Block a user