Skip to content

Instantly share code, notes, and snippets.

@greggyNapalm
Created June 3, 2022 13:13
Show Gist options
  • Save greggyNapalm/2b8091fade2e09dd32d1488a7a90be7c to your computer and use it in GitHub Desktop.
Save greggyNapalm/2b8091fade2e09dd32d1488a7a90be7c to your computer and use it in GitHub Desktop.
package com.example.xsupplydemo;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import com.google.android.material.tabs.TabLayout;
import android.widget.TextView;
import com.x.sdk.xSdk;
public class MainActivity extends AppCompatActivity {
private TabLayout tabLayout;
private ViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tabLayout = findViewById(R.id.tablayout);
viewPager = findViewById(R.id.viewpager);
tabLayout.setupWithViewPager(viewPager);
VPAdapater vpAdapater = new VPAdapater(getSupportFragmentManager(), FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
LogFragment logFragment = new LogFragment();
//vpAdapater.addFragment(new LogFragment(), "Logs");
vpAdapater.addFragment(logFragment, "Logs");
vpAdapater.addFragment(new InfoFragment(), "Info");
viewPager.setAdapter(vpAdapater);
xSdk sdkInstance = xSdk.getInstance(this,"deadbeef");
sdkInstance.start();
sdkInstance.setLoggingEnabled(true);
logFragment.setTextViewText("Hello\r\nValera!");
//sdkInstance.setLoggingHandler((level, msg) -> runOnUiThread(() -> txtView.setText(txtView.getText().toString() + "\r\n" + msg)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment