We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i try to use with webview
but not open
import android.annotation.SuppressLint; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.ValueCallback; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.yalantis.contextmenu.lib.ContextMenuDialogFragment; import com.yalantis.contextmenu.lib.MenuObject; import com.yalantis.contextmenu.lib.MenuParams; import com.yalantis.contextmenu.lib.interfaces.OnMenuItemClickListener; import com.yalantis.contextmenu.lib.interfaces.OnMenuItemLongClickListener; import org.xwalk.core.XWalkPreferences; import org.xwalk.core.XWalkResourceClient; import org.xwalk.core.XWalkUIClient; import org.xwalk.core.XWalkView; import java.util.ArrayList; import java.util.List; import static com.github.crazyorr.embeddedcrosswalk.R.string.url; public class MainActivity extends AppCompatActivity implements OnMenuItemClickListener, OnMenuItemLongClickListener { private XWalkView mXWalkView; private SwipeRefreshLayout swipe; private ProgressBar progressBar; private ContextMenuDialogFragment mMenuDialogFragment; private FragmentManager fragmentManager; @SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initToolbar(); initMenuFragment(); progressBar = (ProgressBar) findViewById(R.id.ProgressBar); swipe= (SwipeRefreshLayout) findViewById(R.id.swipe); swipe.setColorSchemeResources(R.color.orange, R.color.green, R.color.blue, R.color.purple); swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() {mXWalkView.reload(url);} }); loadweb(); } public void loadweb(){ mXWalkView = (XWalkView) findViewById(R.id.webview); mXWalkView.setResourceClient(new ResourceClient(mXWalkView)); mXWalkView.setUIClient(new XWalkUIClient(mXWalkView) { @Override public void onPageLoadStarted(XWalkView view, String url) { progressBar.setVisibility(ProgressBar.VISIBLE); } @Override public void onPageLoadStopped(XWalkView view, String url, XWalkUIClient.LoadStatus status) { progressBar.setVisibility(view.GONE); swipe.setRefreshing(false); } }); XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true); mXWalkView.getSettings().setJavaScriptEnabled(true); mXWalkView.loadUrl("http:google.com"); } private void initToolbar() { Toolbar mToolbar = (Toolbar) findViewById(R.id.my_toolbar); setSupportActionBar(mToolbar); if (getSupportActionBar() != null) { getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); } mToolbar.setNavigationIcon(R.drawable.btn_back); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); } private void initMenuFragment() { MenuParams menuParams = new MenuParams(); menuParams.setActionBarSize((int) getResources().getDimension(R.dimen.tool_bar_height)); menuParams.setMenuObjects(getMenuObjects()); menuParams.setClosableOutside(false); mMenuDialogFragment = ContextMenuDialogFragment.newInstance(menuParams); mMenuDialogFragment.setItemClickListener(this); mMenuDialogFragment.setItemLongClickListener(this); } private List<MenuObject> getMenuObjects() { List<MenuObject> menuObjects = new ArrayList<>(); MenuObject close = new MenuObject(); close.setResource(R.drawable.icn_close); MenuObject send = new MenuObject("Send message"); send.setResource(R.drawable.icn_1); MenuObject like = new MenuObject("Like profile"); Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.icn_2); like.setBitmap(b); MenuObject addFr = new MenuObject("Add to friends"); BitmapDrawable bd = new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.icn_3)); addFr.setDrawable(bd); MenuObject addFav = new MenuObject("Add to favorites"); addFav.setResource(R.drawable.icn_4); MenuObject block = new MenuObject("Block user"); block.setResource(R.drawable.icn_5); menuObjects.add(close); menuObjects.add(send); menuObjects.add(like); menuObjects.add(addFr); menuObjects.add(addFav); menuObjects.add(block); return menuObjects; } class ResourceClient extends XWalkResourceClient { public ResourceClient(XWalkView xwalkView) { super(xwalkView); } public void onProgressChanged(XWalkView view, int progressInPercent){ progressBar.setProgress(progressInPercent); if (progressInPercent == 100){ } super.onProgressChanged(view, progressInPercent); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.context_menu: if (fragmentManager.findFragmentByTag(ContextMenuDialogFragment.TAG) == null) { mMenuDialogFragment.show(fragmentManager, ContextMenuDialogFragment.TAG); } break; } return super.onOptionsItemSelected(item); } @Override public void onMenuItemClick(View clickedView, int position) { Toast.makeText(this, "Clicked on position: " + position, Toast.LENGTH_SHORT).show(); } @Override public void onMenuItemLongClick(View clickedView, int position) { Toast.makeText(this, "Long clicked on position: " + position, Toast.LENGTH_SHORT).show(); } @Override public void onBackPressed() { mXWalkView.evaluateJavascript("onBackPressed()", new ValueCallback<String>() { @Override public void onReceiveValue(final String value) { if (!Boolean.valueOf(value)) { MainActivity.super.onBackPressed(); } } }); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
i try to use with webview
but not open
The text was updated successfully, but these errors were encountered: