|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package com.fongmi.android.tv.ui.activity; |
|
|
|
|
|
|
|
|
|
import android.content.Intent; |
|
|
|
|
import android.text.TextUtils; |
|
|
|
|
import android.view.MenuItem; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
@ -20,6 +21,8 @@ import com.fongmi.android.tv.server.Server; |
|
|
|
|
import com.fongmi.android.tv.ui.fragment.SettingFragment; |
|
|
|
|
import com.fongmi.android.tv.ui.fragment.VodFragment; |
|
|
|
|
import com.fongmi.android.tv.utils.Notify; |
|
|
|
|
import com.fongmi.android.tv.utils.Utils; |
|
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder; |
|
|
|
|
import com.google.android.material.navigation.NavigationBarView; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
@ -31,6 +34,14 @@ public class MainActivity extends BaseActivity implements NavigationBarView.OnIt |
|
|
|
|
private List<Fragment> mFragments; |
|
|
|
|
private boolean confirm; |
|
|
|
|
|
|
|
|
|
private VodFragment getVodFragment() { |
|
|
|
|
return (VodFragment) getSupportFragmentManager().findFragmentByTag("0"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private SettingFragment getSettingFragment() { |
|
|
|
|
return (SettingFragment) getSupportFragmentManager().findFragmentByTag("1"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected ViewBinding getBinding() { |
|
|
|
|
return mBinding = ActivityMainBinding.inflate(getLayoutInflater()); |
|
|
|
|
@ -51,12 +62,6 @@ public class MainActivity extends BaseActivity implements NavigationBarView.OnIt |
|
|
|
|
initConfig(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void checkAction(Intent intent) { |
|
|
|
|
boolean hasPush = ApiConfig.get().getSite("push_agent") != null; |
|
|
|
|
boolean hasAction = intent.getAction() != null && intent.getAction().equals(Intent.ACTION_SEND) && intent.getType().equals("text/plain"); |
|
|
|
|
if (hasPush && hasAction) DetailActivity.start(this, "push_agent", intent.getStringExtra(Intent.EXTRA_TEXT), ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void initEvent() { |
|
|
|
|
mBinding.navigation.setOnItemSelectedListener(this); |
|
|
|
|
@ -93,12 +98,26 @@ public class MainActivity extends BaseActivity implements NavigationBarView.OnIt |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private VodFragment getVodFragment() { |
|
|
|
|
return (VodFragment) getSupportFragmentManager().findFragmentByTag("0"); |
|
|
|
|
private void checkAction(Intent intent) { |
|
|
|
|
boolean hasPush = ApiConfig.get().getSite("push_agent") != null; |
|
|
|
|
boolean hasAction = intent.getAction() != null && intent.getAction().equals(Intent.ACTION_SEND) && intent.getType().equals("text/plain"); |
|
|
|
|
if (hasPush && hasAction) DetailActivity.start(this, "push_agent", intent.getStringExtra(Intent.EXTRA_TEXT), ""); |
|
|
|
|
else checkClip(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private SettingFragment getSettingFragment() { |
|
|
|
|
return (SettingFragment) getSupportFragmentManager().findFragmentByTag("1"); |
|
|
|
|
private void checkClip() { |
|
|
|
|
CharSequence text = Utils.getClip(); |
|
|
|
|
if (TextUtils.isEmpty(text)) return; |
|
|
|
|
showDialog(text.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void showDialog(String text) { |
|
|
|
|
new MaterialAlertDialogBuilder(this).setMessage(getString(R.string.home_open_url, text)) |
|
|
|
|
.setNegativeButton(R.string.dialog_negative, (dialog, which) -> Utils.clearClip()) |
|
|
|
|
.setPositiveButton(R.string.dialog_positive, (dialog, which) -> { |
|
|
|
|
DetailActivity.start(MainActivity.this, "push_agent", text, ""); |
|
|
|
|
Utils.clearClip(); |
|
|
|
|
}).show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setConfirm() { |
|
|
|
|
|